0
0

Hi,
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
[code:1iyphoh3]
FMOD::Sound** sound;
[/code:1iyphoh3]
after initializing, loading the files, and playing one of them back, say, like this
[code:1iyphoh3]
result = system->createSound(this->get_sound_name(i),
FMOD_HARDWARE, 0, &sound[i]);
.
.
result = system->playSound(FMOD_CHANNEL_FREE, sound[i], false,
&channel);
[/code:1iyphoh3]
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!

  • You must to post comments
0
0

have you tried using:
FMOD_Channel_Stop(fmodChannel);
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

  • You must to post comments
0
0

you can use FMOD_CHANNEL_REUSE instead of FREE as long as you pass the old channel handle in, and it will do what you want.

  • You must to post comments
0
0

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.
Thanks

  • You must to post comments
0
0

the sound pointer identifies each open sound.

  • You must to post comments
0
0

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.

  • You must to post comments
0
0

Thank you very much for all your help. Sorry i couldn’t reply earlier. School got in the way.
I’ve solved the problem. I just needed to read a bit more in the manual and it would have worked from the begining.
Again, thank you very much.

  • You must to post comments
Showing 6 results
Your Answer

Please first to submit.