Sound channels
BlitzMax Forums/BlitzMax Beginners Area/Sound channels
| ||
I have a sound effect in my game that I only want to play if it is not already playing. There doesn't seem to be a soundplaying() function, but there is a channelplaying(). So I think I can do this if I assign the sound to a channel before playing it? Up until now I have always just played sounds without using allocChannel() - presumably this just goes to a default channel in this case? Could someone tell me exactly how allocating sound channels works please? If I want to play 2 sounds at the same time should I be using the allocChannel()? Any explanations would be much appreciated. |
| ||
Yes, use AllocChannel to allocate a special channel just to play that particular sound effect with. Usually you don't need to care about channels and every time you play a sound one gets allocated from a pool which is then recycled when the sound finishes playing. A more correct naming system would be to call sounds Samples, and Channels sounds as the channel is the object responsible for making the sound and the sample is just the shape of the waveform being used. |
| ||
Brilliant - thanks for the clear explanation, skid. |
| ||
I usually allocate a single channel in the intialization part of my program, and play all my sounds through that one channel. But I'm not sure if you can use one channel to play multiple sounds at the same time though I would assume not. |