By jlnr (dev)
Date 2011-08-07 06:07
Hey guys.
It is really hard to explain what a "sample instance" is, and I think the name is terrible too.
A Sample
is an immutable piece of memory that can be played back, and a SampleInstance
is one running process of sending this buffer to your speakers (which can be paused, for example). Obviously, there can be many instances of the same sample at the same time.
What about renaming the latter class to Channel
? At first I thought it was technically wrong because it may actually be stereo, but in the eyes of the mixer, it is still one input channel. Otherwise, does Playback
make more sense?
me being one of those who asked the difference, I think that the word Instance makes more sense than channel or playback.
maybe you could name it SamplePlayback? sounds less tech
Sir, regardless of name, can you give a real example of how one can use a instance? I want to make it so two samples of the same kind CAN'T be played at the same time. I guess Sample Instance is my ticket, but can't figure it out.
Thanks.
By lol_o2
Date 2011-08-07 19:34
Just use Sample.play
It plays a sample, but also returns a Sample Instance
_
Some exapmle:
@boom=Sample.new(window, 'boom.wav')
@instance = @boom.play
And @instance is a Sample Instance of @boom
By jlnr (dev)
Date 2011-08-07 19:38
Oh, sounds like something that has many use cases actually. Just keep one @instance
variable per "kind" of Sample as lol_o2 said. Then, if there is an instance and it is still .playing?
, you can either not play new samples, or .stop
the running instance first. See the docs from libgosu.org for the full interface of SampleInstance
.
'Track' might be more legitimate, although I tend to prefer simpler names - 'Playback' (or SamplePlayback) would be nicer to read imo.
By Jwosty
Date 2011-08-08 02:49
Yeah, Track would make lots of sense. I'm debating which one I like better -- Playback or Track but the latter is winning as of now.
I like both "Track" and "Channel." I'm leaning toward the latter, but there are arguments against both.
How about "Outburst"? Instead of Outburst#stop, you could use Outburst#stifle ;-)
Loading...