[directmusic] Re: DirectMusic Unbearably Slow

  • From: Bryan Cool <bryanc@xxxxxxxxxxxxxxx>
  • To: directmusic@xxxxxxxxxxxxx
  • Date: Tue, 11 May 2004 19:08:04 +0100

Wow, thanks for the instantaneous reply! Sorry I wasn't able to respond 
sooner; I wanted to get you some numbers.

I would love to stick as many sounds as possible into one AudioPath, but 
as I understand it, since there's one AudioPath per 3D buffer, I'll need 
a separate AudioPath for each sound that's positioned uniquely in 3D 
space. It seems like the only exception here is that similar sounds can 
possibly share buffers through DuplicateSoundBuffer and still retain 
separate 3D positions. Non-3D sounds could probably better utilize the 
many-sounds-in-one-AudioPath method, right?

Initially I removed culling because the code in the book immediately 
failed if no hardware buffers were available. I realize that's not the 
best way to handle things--and that there's a very real need for 
culling--so I'll be putting culling back in soon, probably adding a 
weighting value for volume, as well.

After testing, I found out I was calling SetAllParameters every frame 
for every sound. I moved this to calling it only on creation of the 
sound (these particular sounds shouldn't be moving), and this at least 
doubled the frame rate (in a place where 50 is normal, I was getting 12, 
and it brought me up to 30 or so). Apparently this was the big thing 
that killed my framerate. I guess I've been in Direct3D mode too long, 
where batching is always better. Also, I used DS3D_DEFERRED, so I 
figured that would help, too. It may have helped, but not significantly. 
Looks like it's better to set just one or two things per frame (and even 
then, probably every few frames instead of each frame) than to batch it 
all. And certainly don't set things unless you absolutely have to.

    -Bryan

Todor Fay wrote:

>My first hunch is there are too many AudioPaths. Each AudioPath feeds a
>DSound Buffer. The overhead of mixing multiple sounds into one AudioPath
>is much less than the overhead of streaming one Buffer, because the
>software synth is very efficient. (Ideally, you can take advantage of
>this by playing complex layered sounds into each AudioPath.)
>
>I'm curious as to why you removed the culling of AudioPaths. The reason
>for culling is specifically to keep the cpu hit contained.
>
>You also mentioned that you get frame rate dips with only a few sounds
>playing. Are the AudioPaths still active? If so, they continue to stream
>the DirectSound buffers. So, make sure that you only have the AudioPaths
>that are currently making sound activated. 
>
>Finally, your experiment with "no virtualization" was a good idea.
>However, I wouldn't be surprised if that's being ignored by a poorly
>behaving driver. So, try creating a mono or stereo default AudioPath and
>see how it does cpu wise. I'm not suggesting that's what you want,
>because it isn't. But, it would help identify the source of the problem.
>
>
>How many AudioPaths do you have running when things get bad?
>
>Hopefully, something in this will help isolate the problem,
>
>Todor
>  
>

Other related posts: