<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Pingwah Leronz wrote:
<blockquote cite="mid:COL117-W4296643F5D6E704F165A2DFE4D0@phx.gbl"
 type="cite">
  <style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
  </style><br>
and Cars are to be able to emit several sounds at once , an ambient
engine roar, horn beeps, drivers yelling etc.<br>
  <em>Also there's to be literally <u>millions</u> of cars </em>(OK,
in the project itself , they're not cars :) ), so a method of culling
sound emitters from the set needs to be there.&nbsp; <br>
Criteria for adding and removing Cars from the audio set is simply
proximity to a viewing position, and the cars themselves are stored in
something like<br>
</blockquote>
<br>
Wow.&nbsp; <u><i>Millions</i></u> is a lot of cars (or whatever :-) ).<br>
<br>
You're obviously not going to be able to mix and play that many sounds
in real time, so there will be some culling done.&nbsp; You've got the right
approach in either case, in that you're allocating buffers and
dynamically assigning them to sources.&nbsp; Either way would work, but the
second method is probably closer to the "better" way.&nbsp; I've referred to
this as "virtualized sources", because you effectively are representing
lots of logical sources and then assigning real sources to them
dynamically.<br>
<br>
Listener proximity is often an adequate metric for determining which
sounds should be auralized.&nbsp; In my case, each update cycle I actually
compute the effective gain (using the attenuation formula from the
spec) for each virtual source, and then sort them by effective gain.&nbsp; I
also throw in a user-defined "priority" metric (picked from LOW,
NORMAL, HIGH, and ALWAYS_ON).&nbsp; The sounds with ALWAYS_ON priority are
guaranteed sources, regardless
of effective gain (obviously, you can't have too many of these). First,
each virtual source is checked to see if it is in a playing state (it
is removed from further processing if not).&nbsp; Next, the sounds are
sorted by priority, then by effective gain.&nbsp; Finally, real sources are
assigned to the sounds at the top of the list.<br>
<br>
This method is probably a bit too expensive for you if you really have
to deal with millions of virtual sources.&nbsp; You might need to add in an
extra layer of cheap, coarse level processing to deal with culling out
most of the sources before you get to a method as fine-grained as
this.&nbsp; This might involve some kind of spatial subdivision, where you
ignore sounds that lie outside of some radius, or something like that.<br>
<br>
You might also consider a form of clustering.&nbsp; This technique pre-mixes
sounds that lie some distance away, but are roughly in the same
direction.&nbsp; Say you have three sources to the northeast,&nbsp; two to the
west and five to the south.&nbsp; You could effectively auralize all of
these virtual sources using only three real sources.&nbsp; You simply
pre-mix the sound from the first three into one buffer, the next two
into a second buffer, and the last five into a third buffer, and then
play those three buffers on three real sources.<br>
<br>
In your case, I'm thinking you might not get enough of a soundfield by
just picking, say, the sixteen closest sources.&nbsp; You might try
pre-mixing some number of sources that are moderately distant into a
single, non-directional "ambient" buffer.&nbsp; This might better represent
the soundfield you'd really hear in that kind of situation.&nbsp; An easy
way to make a non-directional buffer is to mix the sounds into a stereo
buffer, with the same data in both left and right channels.<br>
<br>
That's all I can think of right now.&nbsp; Hope this helps!<br>
<br>
--"J"<br>
<br>
<br>
<br>
<blockquote cite="mid:COL117-W4296643F5D6E704F165A2DFE4D0@phx.gbl"
 type="cite">&nbsp;<br>
&nbsp;<br>
multimap &lt;classCoord*, classCar*&gt; mapCars;<br>
&nbsp;<br>
(again, they're not cars- let's say the track consists of many&nbsp;discrete
positions, each of which can contain many cars).<br>
&nbsp;<br>
I've been experimenting with two methods of handling this - the first
with a global controller:<br>
&nbsp;<br>
  <strong>Method 1</strong><br>
  <strong>---------------------------------</strong><br>
class classAudioController()<br>
{<br>
&nbsp;&nbsp;&nbsp;&nbsp; int MAX_SOUNDS = 150;<br>
&nbsp;&nbsp;&nbsp;&nbsp; multimap &lt;classCar*, ALuint&gt; mapSounds;&nbsp;&nbsp;&nbsp;&nbsp; //where ALuint
here is a ref to the standard openal source[MAX_SOURCES]<br>
&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp; //functions<br>
&nbsp;&nbsp;&nbsp;&nbsp; void AddCar(classCar* newCar, ALuint* newAudioSource);<br>
&nbsp;&nbsp;&nbsp;&nbsp; bool AssignBufferToSource(ALuint *intSource, ALbyte* filename);<br>
&nbsp;&nbsp;&nbsp;&nbsp; void UpdateAllPositionsAndVelocities();<br>
&nbsp;&nbsp;&nbsp;&nbsp; void UpdateCarsPositionAndVelocity(classCar* findCar);<br>
&nbsp;&nbsp;&nbsp;&nbsp; etc.<br>
&nbsp;<br>
&nbsp;<br>
};<br>
&nbsp;<br>
&nbsp;<br>
and also by a more object oriented<br>
&nbsp;<br>
  <strong>Method 2</strong><br>
  <strong>----------------------------------</strong><br>
classCar<br>
{<br>
&nbsp;&nbsp; //position, fuel, health etc.<br>
&nbsp;&nbsp; //....<br>
&nbsp;&nbsp; classAudioSource *soundSource[MAX_SOURCES];&nbsp;&nbsp; //remember, each car
can emit many simultaneous sounds<br>
&nbsp;<br>
&nbsp;<br>
}<br>
&nbsp;<br>
where classAudioSource is <br>
{<br>
&nbsp;&nbsp; ALuint intSource<br>
&nbsp;<br>
&nbsp;&nbsp; //funcs<br>
&nbsp;&nbsp; bool AssignBufferToThis(ALbyte *filename);<br>
&nbsp;&nbsp; void UpdatePosition(float x, float y, float z);<br>
&nbsp;&nbsp; void Play();<br>
&nbsp;&nbsp; void Stop();<br>
&nbsp;&nbsp; void PitchMod(float fltMod);<br>
&nbsp;&nbsp; void GainMod(float fltMod);<br>
&nbsp;&nbsp; void SetLooping(bool boolLooping);<br>
&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp; etc.<br>
&nbsp;<br>
}<br>
&nbsp;<br>
&nbsp;<br>
&nbsp;<br>
With Method 1, Cars are added and removed from the emitters map on
movement events, In method 2 classAudioSources are triggered to
Play/Stop based on listener proximity , again on movement events.<br>
I'm running into problems with both, mainly from unfamiliarity.<br>
&nbsp;<br>
If anyone here has input into handling large sets of sound sources in a
good OO-heavy way, or can point me to any reading that does I'd be
massively grateful.<br>
&nbsp;<br>
Thanks,<br>
Pingwah<br>
&nbsp;<br>
&nbsp;<br>
&nbsp;<br>
&nbsp;<br>
&nbsp;<br>
  <br>
  <hr>Find car news, reviews and more <a moz-do-not-send="true"
 href="http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fsecure%2Dau%2Eimrworldwide%2Ecom%2Fcgi%2Dbin%2Fa%2Fci%5F450304%2Fet%5F2%2Fcg%5F801459%2Fpi%5F1004813%2Fai%5F859641&amp;_t=762955845&amp;_r=tig_OCT07&amp;_m=EXT"
 target="_new">Looking to change your car this year?</a></blockquote>
<br>
</body>
</html>