0
0

Hi,

I noticed some performance problems in my game related to playing sounds. During gameplay, when lots of sounds are being played/streamed, I noticed that when I call FMOD_System_PlaySound(..) on a streaming sound, it’s regularly taking 3-5ms, however it’s also not uncommon to see spikes of up to 20ms. I’d say that 60 percent of the time, it’s in the 3-5ms range, and 40% of the time it’s around 20ms.

Then, I ran a test where I created a single streaming sound. Without anything else going on, it regularly spends 3-4ms inside FMOD_System_PlaySound. I don’t see any spikes up to 20ms any more in this isolated test with nothing else happening except for the single sound. However, 3-4ms is still extremely slow.

Can anyone explain why this is so slow? Am I doing something stupid? I assume I am; I’m rather new to fmod so it’s likely that I’ve made a mistake somewhere. I’m running fmod version 4.04.30 on win32.

Any help/suggestions would be appreciated.

On a related note, I’ve noticed that creating a new stream is extremely slow as well (i’ve got another thread about that..). Initially, I was trying to create my streaming sounds on the fly (just calling into FMOD_System_CreateSound), however this was far too slow. I assumed that if I created my streams in advanced and re-used them that I would be able to avoid this huge performance penalty, but I was wrong.

thanks,
sam

  • You must to post comments
0
0

If you just want to create and play a stream without blocking, then that is pretty easy, you just open your stream with FMOD_NONBLOCKING.

It is only when you -restart- a stream after it has ended where it will do a blocking reflush.

There is a tutorial "FMOD_NONBLOCKING flag and asynchronously loading data" in the documentation which you might find useful.

  • You must to post comments
0
0

[quote="brett":1j5lkvtq]If you just want to create and play a stream without blocking, then that is pretty easy, you just open your stream with FMOD_NONBLOCKING.

It is only when you -restart- a stream after it has ended where it will do a blocking reflush.

There is a tutorial "FMOD_NONBLOCKING flag and asynchronously loading data" in the documentation which you might find useful.[/quote:1j5lkvtq]

Ok, just so I’m clear, it is impossible to avoid the delay when -restarting- a stream after it has ended. So I should basically never keep my streams around; I should delete it when I’m done and if I need it again I should create a new stream?

-sam

  • You must to post comments
0
0

I just discovered something else which might shed some light on the problem I’m having..

My initial test was streaming in a sound that was compressed using OGG. As I said, playing the sound took about 3-4ms in my standalone test.

I just ran the standalone test with sound that was just raw sound samples: 16bit, 44khz, stereo. For this sound, FMOD_System_PlaySound usually takes about 10ms, however about 40% of the time, it spikes up to 20-25ms.

does this help at all? hmm…

-sam

  • You must to post comments
0
0

Currently yes, it will flush inside playSound if you restart a stream.
That is the only way you can do it, or try releasing and opening but thats not very efficient.
I guess we could add a function to flush a stream that respects FMOD_NONBLOCKING, and puts the stream into a non ready state (so that you can only play it when it has finished flushing, just like you would if you opened it non blocking).

  • You must to post comments
0
0

Have you tried FMOD_NONBLOCKING? Can you send us your standalone test so we can reproduce your results here?

  • You must to post comments
0
0

FYI, jerbare’s issue was unrelated and resolved offline. It was due to using FMOD Designer to access wav files on network shares.

  • You must to post comments
0
0

I’ve tried both creating the streaming sound with FMOD_NONBLOCKING and without; it doesn’t seem to make a difference.

I don’t have this in a standalone test yet, I’ll work on that.

One question: have you guys (fmod?) timed how long, on average, these calls take in your own test apps? I’m curious if the timings I’m reporting here are above/below/or about average..

thanks,
sam

  • You must to post comments
0
0

Regarding jerbare’s unrelated issue, by "resolved offline" do you mean this issue has been fixed, or will Soundminer metadata from wavs accessed on network drives still cause crashes?

thanks

  • You must to post comments
0
0

In release mode :

System::createStream() = <1-4ms (depends on format e.g. ogg is slower than wav)
System::playSound() = <1-1ms

What timing functions are you using? We use QueryPerformanceCounter. Are you running in release or debug mode? If you have FMOD logging enabled then this will slow things down. Can you provide us with the standalone test you used that "usually takes about 10ms, however about 40% of the time, it spikes up to 20-25ms"?

  • You must to post comments
0
0

Soundminer metadata never caused crashes, jerbare reported that he was getting periodic freezes when using FMOD Designer to access .wav files containing Soundminer metadata on a network share.

The metadata wasn’t the issue, FMOD handles it just fine. The issue is the network share – windows queues file operations on network shares so that Closehandle() sometimes blocks for up to a second at a time. We can possibly work around this limitation of windows but probably not soon.

For now either work locally or put up with a few pauses.

  • You must to post comments
0
0

Hi Andrew-

I don’t think I’m running fmod in logging mode. How do I check? I am running in release mode. I’m also using QueryPerformanceCounter for my timings.

I modified one of the examples provided to show what I’m seeing. The example is "playstream" example.

Here are the changes I made:

[code:3u5ksvyv]
if (kbhit())
{
key = getch();

switch (key)
{
    case ' ' :
    {
        if ( channel != NULL )
        {
            FMOD_Channel_Stop(channel);
            channel = NULL;
        }
        else
        {
            StopWatch tStopWatch;
            float flTime;

            StopWatchReset(&amp;tStopWatch);
            result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound, 0, &amp;channel);
            flTime = StopWatchCheck(&amp;tStopWatch);

            printf(&quot;FMOD_System_PlaySound took %.2f ms\n&quot;, flTime * 1000.0f);
            ERRCHECK(result);
        }
        break;
    }
}

}
[/code:3u5ksvyv]

Basically, this stops and then plays the channel, the way I was describing in my post.

Using the same mp3 file that it was already playing in the sample, here’s the output I get:

[code:3u5ksvyv]

PlayStream Example. Copyright (c) Firelight Technologies 2004-2005.

Press space to pause, Esc to quit

FMOD_System_PlaySound took 3.16 ms
FMOD_System_PlaySound took 3.08 ms
FMOD_System_PlaySound took 3.07 ms
FMOD_System_PlaySound took 3.08 ms
FMOD_System_PlaySound took 3.06 ms
FMOD_System_PlaySound took 3.16 ms
FMOD_System_PlaySound took 3.16 ms
FMOD_System_PlaySound took 3.11 ms
Time 00:04:07/00:11:54 : Playing
[/code:3u5ksvyv]

If I switch the sound to a wave file i have that is 44khz, 16bit, stereo, and about 90 seconds long, then this is the output I get:

[code:3u5ksvyv]

PlayStream Example. Copyright (c) Firelight Technologies 2004-2005.

Press space to pause, Esc to quit

FMOD_System_PlaySound took 0.23 ms
FMOD_System_PlaySound took 11.73 ms
FMOD_System_PlaySound took 0.23 ms
FMOD_System_PlaySound took 0.26 ms
FMOD_System_PlaySound took 11.69 ms
FMOD_System_PlaySound took 0.23 ms
FMOD_System_PlaySound took 11.65 ms
FMOD_System_PlaySound took 11.67 ms
FMOD_System_PlaySound took 11.69 ms
FMOD_System_PlaySound took 11.66 ms
FMOD_System_PlaySound took 11.68 ms
FMOD_System_PlaySound took 11.66 ms
FMOD_System_PlaySound took 23.36 ms
FMOD_System_PlaySound took 23.35 ms
FMOD_System_PlaySound took 11.68 ms
FMOD_System_PlaySound took 11.68 ms
FMOD_System_PlaySound took 23.37 ms
Time 00:03:88/01:31:39 : Playing
[/code:3u5ksvyv]

And here is the output if I use one of our .OGG file that is about 7 minutes long:

[code:3u5ksvyv]

PlayStream Example. Copyright (c) Firelight Technologies 2004-2005.

Press space to pause, Esc to quit

FMOD_System_PlaySound took 3.81 ms
FMOD_System_PlaySound took 3.77 ms
FMOD_System_PlaySound took 3.77 ms
FMOD_System_PlaySound took 3.77 ms
FMOD_System_PlaySound took 3.78 ms
FMOD_System_PlaySound took 3.82 ms
FMOD_System_PlaySound took 3.78 ms
FMOD_System_PlaySound took 3.80 ms
Time 00:08:19/06:57:68 : Playing
[/code:3u5ksvyv]

So in every case here on my computer, the system is taking well over the 1ms is should take to play a sound, and in the case of the .wav file, something really crazy is going on– sometimes it is fast and other times it’s very slow. Can you try to reproduce this on your end and let me know your results?

thanks,
sam

  • You must to post comments
0
0

Can you send me that wav? support@fmod.org

Cheers,

  • You must to post comments
0
0

If you start and then stop a stream it has to seek and reflush the buffer. This is normal to take some time, unless you pre-flush your stream somewhere else. The very first time the flush happens in the createSound call, then the first playsound is free.

  • You must to post comments
0
0

This sounds similar…

I sent an email to support@fmod.org yesterday about a similar issue, but I tracked down what the issue was for our scenario: BEXT and/or SNDM metadata stored in our sound library WAV files for the Soundminer application.

In the email I included some sample WAV files and an FDP which should demonstrate the issues.

I’ll paste my email here:

[quote:396xnphc]Greetings,

I’ve come across a pretty obscure bug in FMOD that I just tracked down and isolated.

I am experiencing periodic freezes in our application when certain events are triggered. I finally noticed that these events were also freezing for up to several seconds even within the FMOD Designer application itself. I am using the latest FMOD Designer 1.4.51 (Nov 24 2006)

It is related to WAV files that have specific metadata stored within them. In my case the files contained:
– Broadcast WAV (bext chunk)
– Soundminer (sndm chunk)

The metadata is used from the Soundminer application for sound library and asset management. It allows you to search its database based on keywords and thesaurus matching. When you add files to Soundminer it scans for this specific metadata and stores it in its database for fast searching. The files contain the metadata so that other applications can make use of it, or in case you need to reimport the data.

As soon as I made copies of these files and explicitly removed the metadata – using Adobe Audition v2.0 – the problem went away.

More specifically, the sounds play without any hitch from within their Sound definitions. It is only when they are brought in to an Event as a sound instance that they cause freezing.

Lastly, my current application/project makes use of the FEV files and references the WAV files directly within our editing environment. I cannot determine if this problem occurs when we implement FSB functionality since we haven’t gotten to that point yet.

Attached is some sample content which should reproduce the problem for you. I can usually feverishly press the play button over and over to hear all the variations of any sound definition I’ve created, and you’ll notice especially with the "drippyVerb" event that at times it will pause for several seconds.

Ideally this extra data would be stripped from the files before finishing any project, but during development it could be nice to maintain the metadata – and some people may be interested

Let me know if there is anything else I can do to assist.[/quote:396xnphc]

  • You must to post comments
0
0

[quote="brett":35fwsfqp]If you start and then stop a stream it has to seek and reflush the buffer. This is normal to take some time, unless you pre-flush your stream somewhere else. The very first time the flush happens in the createSound call, then the first playsound is free.[/quote:35fwsfqp]

Is there a way to pre-flush a stream or to make it do this to my stream asynchronously when I play it?

What I’m trying to do is use fmod to create and play streaming sounds without it breaking our framerate. Is this possible with fmod? Is there an example somewhere or can you describe to me the best way to do this?

thanks,
sam

  • You must to post comments
Showing 15 results
Your Answer

Please first to submit.