[directmusic] Re: Understanding Audiopath Creation in Script

  • From: "Todor Fay" <todor@xxxxxxxxxxxxx>
  • To: <directmusic@xxxxxxxxxxxxx>
  • Date: Mon, 26 May 2003 06:55:01 -0700

Hi Andreas,

When you release an AudioPath, it does in fact linger around for
something like half a second, so this would explain what you are seeing.
AudioPaths do this so you won't get an annoying click if there's any
sound still in the path at the time of destruction. 

The solution is to use the same AudioPath over and over. This would also
be more cpu efficient. 

You should keep a pool of AudioPaths that you create up front, set to a
max number that ensures the AudioPaths are all created from hardware
sound buffers, so it doesn't spill over to software. Numbers like 24 are
very safe with today's hardware. Keep the AudioPaths deactivated when
not in use, so they don't eat cpu unnecessarily. Grab a path from the
pool every time you need one and then return it when done. 

For GDC 2001, we added 3D sound effect to 3D Donuts using this
technique. The code also does automatic AudioPath swapping to handle
more objects than there are AudioPaths, by comparing distances from the
Listener. This code is free to use, though I don't know where it is
posted these days. Somebody on the list might be able to point you to
it. However, it does more than you need, so it's not critical. 

Along the same lines, I wrote programming chapters for the upcoming
book, "DirectX Audio Exposed" from WordWare, and there's a chapter
dedicated to this, also with sample code. Unfortunately, it won't be out
till end of summer.

I notice your AudioPath has the name "Ap_reverb". I'm assuming this is a
shared reverb, and not a reverb in the path itself. If each path has its
own reverb, the cpu cost is very high. Just in case...

Todor Fay
NewBlue, Inc.

-----Original Message-----
From: directmusic-bounce@xxxxxxxxxxxxx
[mailto:directmusic-bounce@xxxxxxxxxxxxx] On Behalf Of Andreas Seebeck
Sent: Monday, May 26, 2003 6:21 AM
To: directmusic@xxxxxxxxxxxxx
Subject: [directmusic] Understanding Audiopath Creation in Script


Hello,

we are making a game were also sfx is managed by dm. As we have to give
each
played sound its own volume, we make it this way right now:
e.g.:
sub playhit
         set ap = Ap_reverb.create
         ap.setvolume vsfx
         dummy.play IsSecondary, ap
end sub

Now the program sometimes generates an error when trying to create the
audiopath. It seems to be dependend on how fast the ap's are created
(How
many sounds/segments are started in a time).

As we have thousands of soundeffects starting during a game it would be
good
to know
if an ap is destroyed after usage automatically,
and if there is a maximum amount of used ap's

Does anybody know?

Thanks in advance,
Andreas Seebeck






Other related posts: