I am loading mp3 files into memory and playing them back. The thing is, i need to stop a particular sound. I am guessing it should be possible, but i’ve tried a couple of things and no success.
i have something like this
after initializing, loading the files, and playing one of them back, say, like this
result = system->createSound(this->get_sound_name(i),
FMOD_HARDWARE, 0, &sound[i]);
result = system->playSound(FMOD_CHANNEL_FREE, sound[i], false,
it plays back great, but the thing is, when selecting the option that should playback the sound, it just plays it over the existing one, without stopping playback first.
Thank you for your help!
- horacv asked 9 years ago
I think that the disconnect that you’re having here is that there are actually two constructs: Sounds and Channels.
A Sound contains information about the audio data. This includes such things as the file pointer, the sample rate information, stuff like that.
When you play a Sound (with System::playSound()) the runtime playing information lives in a Channel. The Channel has information about where in the Sound it is, what volume it’s playing at, 3D position information, etc.
If you only want one instance of any given sound in your program, then I would suggest having your internal sound object contain both an FMOD::Sound* and an FMOD::Channel*. When you want to stop the sound (to play another one, or to reload the data or whatever), you can just call Channel::stop() on the channel pointer.
Hope that helps.
- Adiss answered 9 years ago
have you tried using:
or whatever it is in C++
when you are using FMOD_CHANNEL_FREE iit isnt going to stop playback on previous sounds becuase it finds a free channel to play on. You need to either specify a channel or stop playback first.
hope that helps
Thank you very much for your replies.
The thing is, everything regarding sound is encapsulated in one class in my program. I was wondering how FMOD identifies each sound it loads, ie. say i load arrrrrgh.mp3 once, and then i try to load it again, but prior to loading it i could query something like: get_id(sound); and this way determine if a particular sound is playing and stopping only that one and not any other that may be playing.
Please login first to submit.