Let us start with a quick reminder from last chapter. When we use the playSound()
method and pass the address of an FMOD::Channel
pointer to the fourth parameter, we get a channel handle in return:
FMOD::Channel* channel; system->playSound(FMOD_CHANNEL_FREE, sound, false, &channel);
Through this handle, we can control the sound in many ways. This handle remains valid while the sound has not finished playing, or until we explicitly stop the sound. If we try to perform an operation on the channel after the sound has stopped, nothing happens. Instead, the method we called returns an error stating that the channel handle is invalid, or already in use by another sound, if that is the case.
Something that might be confusing is that this FMOD channel is not the same type we talked back in Chapter 1, Audio Concepts, when we discussed multi-channel audio. This is simply the name FMOD gives to each of the slots it uses to play sounds simultaneously.