Not logged inGosu Forums
Forum back to Help Search Register Login
Up Topic Gosu / Gosu Exchange / Sample vs SampleInstance/Channel/Playback
- - 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?
Parent - - By Dahrkael Date 2011-08-07 14:58
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
Parent - - By kaBOOM Date 2011-08-07 19:23
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.

Parent - By lol_o2 Date 2011-08-07 19:34
Just use
It plays a sample, but also returns a Sample Instance

Some exapmle:, 'boom.wav')
@instance =

And @instance is a Sample Instance of @boom
Parent - 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 for the full interface of SampleInstance.
Parent - - By Basic Date 2011-08-07 19:20
'Track' might be more legitimate, although I tend to prefer simpler names - 'Playback' (or SamplePlayback) would be nicer to read imo.
Parent - 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.
Parent - By RunnerPack Date 2011-08-08 04:36
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 ;-)
Up Topic Gosu / Gosu Exchange / Sample vs SampleInstance/Channel/Playback

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill