Sign in to follow this  
THACO

playing SFX only once

Recommended Posts

THACO    234
I am using FMOD to play sounds, its great. The one problem I am using scripting to control characters and such which seems to be working well except for this problem. I have it setup so the script can call my C++ function to play a soundfx based on the file name. I currently would play a sound if X amount of time has passed since start of attack/animation. The only problem it will keep adding instances of that sound to play every frame after time X. I can't say just play it when you hit the exact time or an exact frame just incase due to time/machine performance it skips over that one specific time or framee. Any ideas, I can't just check if that sound is currently playing because multiple characters might want to use that sound so I would have to let the sound be played multiple times. Any idea or will I have to use some ugly hacks? -THACO

Share this post


Link to post
Share on other sites
Omaha    100
Well, first of all, you shouldn't check if time or frame is equal to something, use greater-than-or-equal because then you don't have to worry about the CPU hitting the time right on the nose.

Second of all, it sounds to me like the problem is in the interface between the script language and your C++ code, or within your sound playback code, in that it should be able to play a sound once, and then once it's done playing it, stop. The audio API you're using should be able to take care of the possibility of alot of stuff going on at once, and doing the mixing and buffer allocation.

Share this post


Link to post
Share on other sites
THACO    234
I think I found a solution to my problem. What I am doing now is just having a variable in the script that starts at zero when a new animation/action is started and each sound gets played when that variable reaches a certain number. It is incremented when a certain frame/time has been passed over. It isn't perfect but shouldn't cause to many problem

-THACO

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this