Jump to content
  • Advertisement
Sign in to follow this  
swifty666

FMOD playSound latency

This topic is 2922 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi There,


I am currently working on a project that involves recording peoples reaction speeds to hearing audio tones, and also to record a person's spontaneous rhythm speed.

I using FMOD Ex v4.32.05 (according to the header file).

I have a quick simple shell setup that loads in some wav files and plays them when i press the 1-7 keys.

The time at which I press the key to the time I hear the sound is noticeably delayed. Perhaps by a quarter of a second. Is this a delay that is inevitable or could it be improved somehow by changing some FMOD setting? Such as to ensure the entire sound data is cached on the card ready for playing?

I have checked the wav files and there is no silent area at the beginning of them.

To Load my wav file I simply use:

m_pFMODSystem->createSound(filename, FMOD_HARDWARE, 0, ppSound);


and to play I simply use

m_pFMODSystem->playSound(FMOD_CHANNEL_FREE,pSound,false,0);


And I am not really doing much else.

I also have a decent enough sound card I would have thought, Creative SoundBlaster X-Fi.

Any suggestions?

Many Thanks

Share this post


Link to post
Share on other sites
Advertisement
Have you tried disabling hardware acceleration? It's not consistent across different platforms/hardware and in general is a pain to use. I recall it could cause delays, at least in FMOD - but I'm not sure as that was a while ago.

The FMOD docs recommend software mode. I even think I remember them saying they would remove hardware support if they were sure none of their clients relied on it. It's that complicated!

Share this post


Link to post
Share on other sites
Oh I didn't even consider trying software instead, I guess I was pretty naive to assume that because I have a sound card that cost a few quid, that it would be an actual improvement. (heh, I jest, I'm sure its an improvement for many things) [lol].

Thanks for the suggestion I'll give software mode a go when I get home and let you know.

For my purpose in this case I have no requirements for any sound effects or processing, I just need the lowest possible latency for getting audio to play on request.

Share this post


Link to post
Share on other sites
Is the delay actually when you're playing the sound or when you're creating it? Loading from disk will always tend to be pokey. Pre-loading short sounds into memory is important.

How long/big is the sound? Play sound will play the entire thing in one go. If the sound is lengthy (more than maybe 5 seconds) streaming the sound out (I forget the mechanism for this in fmod, it's been a while) will behave much better.

Share this post


Link to post
Share on other sites
The delay is from each time I call System::playSound(), after the sound has been loaded, which is a very short beep WAV file; maybe a second long at most.

I was hoping that I could load the sound onto the soundcard (or just in memory if software) which I assumed createSound() would handle, and playing it would then be a case of saying, play that sound, i.e. with playSound(), I imagine the latency to be very short if the sound data is already in memory.. I just have no idea if that's really how it works or how to ensure that's what's happening in FMOD. Not really done much sound work myself before, i'm really more of a graphics programmer.

Share this post


Link to post
Share on other sites
I'm not sure what to say. I loaded up one of my older projects that used fmod ex and played a ~1s wav. It was in C# and thus was using some added binding overhead, but took about 1.6s to play the entire wav, 1.7 if you include loading it. I'm not doing anything fancy... just load, play.

Share this post


Link to post
Share on other sites
Managed to find some info that helped. Apparently the latency is due to the buffer size and number of buffers. If you lower it, the latency is improved.

I'm using

m_pFMODSystem->setDSPBufferSize(512,2);

which has to be called before init. 512 is just enough to not have horrible distortions, and 2 is the minimum number of buffers, though the time between me pressing a key and hearing the sound is still noticeable, but it's not overly terrible. I'm still not convinced that there isn't a way to improve it though, I mean, I've never seen any problem in games that have a sound as a physics response for example, or a gunfire. You wouldn't expect to have a noticeable delay between clicking your mouse and hearing a gun shot, or seeing a ball hit a wall and hearing the bounce..

Share this post


Link to post
Share on other sites
Are you sure it's not your input handling?

A simple standalone app that plays a sound would better isolate the cause.

Share this post


Link to post
Share on other sites
Yea, I also added a printf just before the playsound call, so would expect to hear it the same time as I see the output, but still noticeably delayed..

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!