Jump to content


Photo

Fmod Stop Sound And Play The Same Sound


  • Please log in to reply
5 replies to this topic

#1 Prickly_AI

Prickly_AI

    GMC Member

  • New Member
  • 64 posts

Posted 08 April 2010 - 10:01 AM

It's too difficult to caption in the topic name but here's my problem. I want to make the sound stop when I play the same sound. Don't understand? For example when I click the object, a 3 second sound plays. Clicking again will play but clicking rapidly will also repeat the sound. FMODinit() won't help because it will affect other sounds.

Do you have ideas?

-Pri._AI
  • 0

#2 daremes

daremes

    GMC Member

  • New Member
  • 5 posts

Posted 15 August 2010 - 12:39 PM

It's too difficult to caption in the topic name but here's my problem. I want to make the sound stop when I play the same sound. Don't understand? For example when I click the object, a 3 second sound plays. Clicking again will play but clicking rapidly will also repeat the sound. FMODinit() won't help because it will affect other sounds.

Do you have ideas?

-Pri._AI


I have the very same problem! I'm working on project for kids in my class.
What I'm trying to do is that everytime I press a key (or let's say...left mouse-click) it should start the sound loop assigned to the left mouse-click and immediately stop the previous loop (the same loop sound). I need to do the same for right click and it mustn't affect the left-click loop (wheter it's playing or not). And the timing is essential because the player has to sync two music themes (start 1 theme and then start 2). I'm sorry for my lousy english but I think you'll get the idea. Every opinion appreciated.
  • 0

#3 MasterOfKings

MasterOfKings

    The True Master

  • GMC Member
  • 4888 posts
  • Version:GM8

Posted 15 August 2010 - 12:51 PM

I have never used FMOD... Isn't there some check function, similar to that of the built-in if (sound_isplaying()) {}?

-MoK
  • 0

#4 LSnK

LSnK

    NaN

  • GMC Member
  • 1188 posts

Posted 15 August 2010 - 04:50 PM

The FMOD playback functions return a sound instance ID. There are also functions to manipulate specific sound instances.

When you play the sound, store the ID in a variable somewhere.
sound_id = FMODSoundPlay( sound );

Next time you want to play the sound, check if the last instance is still playing. If so then stop it.
if FMODInstanceIsPlaying( sound_id )
then { FMODInstanceStop( sound_id ); }

sound_id = FMODSoundPlay( sound );

  • 0

#5 daremes

daremes

    GMC Member

  • New Member
  • 5 posts

Posted 15 August 2010 - 09:30 PM

The FMOD playback functions return a sound instance ID. There are also functions to manipulate specific sound instances.

When you play the sound, store the ID in a variable somewhere.

sound_id = FMODSoundPlay( sound );

Next time you want to play the sound, check if the last instance is still playing. If so then stop it.
if FMODInstanceIsPlaying( sound_id )
then { FMODInstanceStop( sound_id ); }

sound_id = FMODSoundPlay( sound );


Thank you very much! I haven't try it yet but it sounds very promising!
  • 0

#6 _175771

_175771

    GMC Member

  • GMC Member
  • 30 posts
  • Version:Unknown

Posted 13 December 2011 - 06:34 PM

I've been stuck on the same thing! This saved me! Thank you so much LSnK!
  • 0




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users