[Openal] suggestions on c++ game design with openAL most welcome

Pingwah Leronz pingwah_leronz at hotmail.com
Mon Jun 1 18:59:54 PDT 2009


First of all, hello everyone :)

 

 

I'm working on a c++ project that's moving into the early stages of audio design and facing what Im guessing would be a fairly common problem, and wondering if anyone has any advice or input about the best way to approach it.

 

For those interested - 

Let's say we have a car

class classCar()

{

    public:

    classCoords coordsPosition;

    classCoords coordsVelocity;

    float fltFuel;

    ...etc.

 

};

 

where classCoords is simply

coords

{

  public:

  float x, y, z;

 

};

 

and Cars are to be able to emit several sounds at once , an ambient engine roar, horn beeps, drivers yelling etc.

Also there's to be literally millions of cars (OK, in the project itself , they're not cars :) ), so a method of culling sound emitters from the set needs to be there.  

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

 

 

multimap <classCoord*, classCar*> mapCars;

 

(again, they're not cars- let's say the track consists of many discrete positions, each of which can contain many cars).

 

I've been experimenting with two methods of handling this - the first with a global controller:

 

Method 1

---------------------------------

class classAudioController()

{

     int MAX_SOUNDS = 150;

     multimap <classCar*, ALuint> mapSounds;     //where ALuint here is a ref to the standard openal source[MAX_SOURCES]

 

     //functions

     void AddCar(classCar* newCar, ALuint* newAudioSource);

     bool AssignBufferToSource(ALuint *intSource, ALbyte* filename);

     void UpdateAllPositionsAndVelocities();

     void UpdateCarsPositionAndVelocity(classCar* findCar);

     etc.

 

 

};

 

 

and also by a more object oriented

 

Method 2

----------------------------------

classCar

{

   //position, fuel, health etc.

   //....

   classAudioSource *soundSource[MAX_SOURCES];   //remember, each car can emit many simultaneous sounds

 

 

}

 

where classAudioSource is 

{

   ALuint intSource

 

   //funcs

   bool AssignBufferToThis(ALbyte *filename);

   void UpdatePosition(float x, float y, float z);

   void Play();

   void Stop();

   void PitchMod(float fltMod);

   void GainMod(float fltMod);

   void SetLooping(bool boolLooping);

   

   etc.

 

}

 

 

 

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.

I'm running into problems with both, mainly from unfamiliarity.

 

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.

 

Thanks,

Pingwah

 

 

 

 

 

_________________________________________________________________
Looking to change your car this year? Find car news, reviews and more
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&_t=762955845&_r=tig_OCT07&_m=EXT
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://opensource.creative.com/pipermail/openal/attachments/20090602/5371861a/attachment.html


More information about the Openal mailing list