Q2 OpenAL Developers thread

forum for discussion on implimenting A3D/EAX in game
mSparks
Advanced Member
Posts: 997
Joined: Fri Jan 03, 2003 2:54 pm
Location: North West UK
Contact:

Postby mSparks » Thu Jun 12, 2003 3:42 am

Hello everybody, and welcome.
As of this moment, the OpenAL engine for Q2 is drawing near a useable yet powerfull stage. Whilst it is currently true that some work remains in general optimisation and 'tweeking' of environments the <a href='http://www.cam-direct.co.uk/downloads/developer/q2wa3d.zip' target='_blank'>primary 'Alpha'</a> seems, as a generalisation, to be working well.
So as a preable to the straight downloadable source Its time to present the general description and how it is (and will be) implimented in game.

The core of the OpenAL implimentation is now handled by a seperate dll (namely q2a3d.dll), the source for which is available, as is the openAL code under the LGPL license. This DLL seeks to further simplify OpenAL implimentation in game, and provide a portable and powerfull 'front end' for implimenting OpenAL. The idea being, to work with this code within a project, direct access to the OpenAL structures can take place in the background and much of the work in starting/caching and updating sounds is handled transparently to the project that is using it.

The implimentation is therefore broken down into 3 sections:

Q2.exe <-> q2a3d.dll -> OpenAL.dll

This dll currently exports 6 functions, with simple requirements for implimetation, these are:

Code: Select all

int Init_A3D(void);
int A3D_cachefile(char *filename,void *A3D_buffer);
int A3D_StartSound(float origin[3], float forward[3],float listener_origin[3], char *filename,  float attenuation, float volume, int id,int Env);
int A3D_UpdateSound(int id,char *filename,float origin[3],float forward[3],float listener_origin[3],float attenuation);
void A3D_StopSound(int id);
void A3D_Shutdown(void);


Code: Select all

Init_A3D:

this function initialises openal, sets up all the internal variables and returns the level of EAX cababilities the system has. EAX capabilites are returned for referance within the engine (such as displaying infomation to the user).

Code: Select all

A3D_cachefile:

This function takes two pieces of infomation, the filename of the file being cached (stored in memory) and a pointer to the actual file (hence the file is opened by the caller, and as such must be closed by the caller, in the case of Q2, FS_LoadFile does this for us).
It then stores it in memory for later use by Startsound, returning true if the file was (or already is) cached, and false if something went wrong.

Code: Select all

A3D_StartSound:

This is the grunt of the dll, it takes (forward/side/hieght format) sound origin, listener origin, listener direction, the attenuation to apply to the sound, the overall sound volume, an (optional) ID which is used for updating and an integer representing the environment (currently 0 for standard and 2 for water). The actual sound played is matched by the filename which has to be precached to play.
If it returns false, the sound was not successfully started (e.g. by it nolonger being cached) in which case the caller must cache it and try to start it again. Currently the only EAX function that the engine can specify, is whether or not the person hearing the sound is underwater, this can be passed safely whether the machine has EAX capabilities or not (although if it doesn't the sound doesn't have as capable filters applied)


Code: Select all

A3D_UpdateSound:

used to update looping sounds, this function takes the filename, and ID it was given when started sets it as a looping sound and re-orientates the sound to the listener. sound origins are timestamped, so moving these sounds through space (without stopping them) will apply doppler shift

Code: Select all

A3D_Update:

takes the current listener origin an orientation, ro-orientates any playing sounds based on this new infomation and handles updating of any streamed sounds (ogg playback/raw pcm) called on a regular basis.

Code: Select all

A3D_StopSound:

This, simply stops the sound given its ID, and clears its internal assignments. Id is used because there is (more often than not) more than one source of a looping sound with the same filename.

Code: Select all

A3D_Shutdown:

cleans up before a shutdown.

Implimentation in Q2.

These functions exist in three areas of the Q2 code. Firstly (and simply) Init_A3D goes in S_Init.
Next code for A3D_StartSound (and A3D_cachefile) is placed in S_Startsound (effectivly replacing it).
A3D_cachefile will probably also go in S_registersound (although this hasn't been tested properly yet).

and the code to handle A3D_UpdateSound goes in S_Update.

It is planned for q2a3d.dll to also have access to a (per map) enviroment definition file, that specifies bounding boxes for the different environment effects, so further EAX environments can be handled completely transparently to the .exe. The function to initialise this will most likely be:

Code: Select all

A3D_Init_Env(char *filename);

where filename is the name of a file containing the environments bounding boxes and definitions.
© Mark 'mSparks' Parker 2010
<pubkey>AJXzWKeV59HaoUkmrCwP9f+kMr8aOIM
jMKy7ACsaRDCE/XuF0orj/jActtfWDMKjg/CixI7JP0Z6lbS99dc
86fxDIQOmfIU8BNYKPmlPA/uY3ZpT9/4iQY0XwKad5eJhDFW
cZ2Z4VUWJzlbuoX/QV4ihTVkr9JnyJb+fN9AOqXH9AQAB</pubkey>

User avatar
tiger@sound.net
Advanced Member
Posts: 68
Joined: Fri May 02, 2003 1:04 pm

Postby tiger@sound.net » Thu Jun 12, 2003 7:10 pm

... Hello mSparks...

( I am guessing that the "average player" should leave this work, alone, for your OpenAL developers around here?)

PS... I put those two modules: 3dquake2.exe and q2a3d.dll into your "Action Quake 2" directory, on my drive, with your OpenAL32.dll... I clicked the 3dquake2.exe and got "Error: Couldn't fall back to software refresh"... (The End.) But, using your aq2.exe was, still, A-Okay...

So,,, can we, players, help you with testing your new 3dquake2.exe, etc?

mSparks
Advanced Member
Posts: 997
Joined: Fri Jan 03, 2003 2:54 pm
Location: North West UK
Contact:

Postby mSparks » Thu Jun 12, 2003 11:10 pm

its a standard quake2.exe, its designed to go in a normal quake2 install.
If you fancy having a listen, I suggest you re-download, new builds have been being posted more or less every 2 hours.
© Mark 'mSparks' Parker 2010

<pubkey>AJXzWKeV59HaoUkmrCwP9f+kMr8aOIM
jMKy7ACsaRDCE/XuF0orj/jActtfWDMKjg/CixI7JP0Z6lbS99dc
86fxDIQOmfIU8BNYKPmlPA/uY3ZpT9/4iQY0XwKad5eJhDFW
cZ2Z4VUWJzlbuoX/QV4ihTVkr9JnyJb+fN9AOqXH9AQAB</pubkey>

mSparks
Advanced Member
Posts: 997
Joined: Fri Jan 03, 2003 2:54 pm
Location: North West UK
Contact:

Postby mSparks » Fri Jun 13, 2003 12:00 pm

ok so people are still having various problems getting it to work. almost all of these problems I cannot replicate here soooo.. time for some source:
Engine: (changes marked with A3D START/A3D END)
<a href='http://www.cam-direct.co.uk/downloads/developer/quake2-3.21a3d.zip' target='_blank'>http://www.cam-direct.co.uk/downloads/deve...ke2-3.21a3d.zip</a>
a3d functions/lib in /a3d

dll:
<a href='http://www.cam-direct.co.uk/downloads/developer/q2a3d08.zip' target='_blank'>http://www.cam-direct.co.uk/downloads/deve...per/q2a3d08.zip</a>
© Mark 'mSparks' Parker 2010

<pubkey>AJXzWKeV59HaoUkmrCwP9f+kMr8aOIM
jMKy7ACsaRDCE/XuF0orj/jActtfWDMKjg/CixI7JP0Z6lbS99dc
86fxDIQOmfIU8BNYKPmlPA/uY3ZpT9/4iQY0XwKad5eJhDFW
cZ2Z4VUWJzlbuoX/QV4ihTVkr9JnyJb+fN9AOqXH9AQAB</pubkey>

User avatar
tiger@sound.net
Advanced Member
Posts: 68
Joined: Fri May 02, 2003 1:04 pm

Postby tiger@sound.net » Sat Jun 14, 2003 12:44 am

mSparks wrote: its a standard quake2.exe, its designed to go in a normal quake2 install.
If you fancy having a listen, I suggest you re-download, new builds have been being posted more or less every 2 hours.


... Just re-downloaded your q2wa3d.zip...
Placed the 3dquake2.exe and q2a3d.dll into my quake2 directory...
And it executed very well, looked and sounded GREAT !!!

( Gee... I thought that the "Action Quake 2" directory was our place?)

Enjoyed a game of classic Quake 2 and that's all I know, from here.


... Thanks a Bunch...

mSparks
Advanced Member
Posts: 997
Joined: Fri Jan 03, 2003 2:54 pm
Location: North West UK
Contact:

Postby mSparks » Sun Jun 15, 2003 2:48 pm

:D
its not that action quake 2 directory is not our place... its just that for this part of the project the code is designed to be as 'portable' as possible. given that there is at least 3 quake 2 source building projects, and openal has proved powerfull yet tricky might as well, at least have the sound system more of a group project than individual design. doing it this way, means that The code, when ready, can go straight into our engine, it means that not only is much of the testing shared, but those who are testing it are not limited to using our install.
© Mark 'mSparks' Parker 2010

<pubkey>AJXzWKeV59HaoUkmrCwP9f+kMr8aOIM
jMKy7ACsaRDCE/XuF0orj/jActtfWDMKjg/CixI7JP0Z6lbS99dc
86fxDIQOmfIU8BNYKPmlPA/uY3ZpT9/4iQY0XwKad5eJhDFW
cZ2Z4VUWJzlbuoX/QV4ihTVkr9JnyJb+fN9AOqXH9AQAB</pubkey>

mSparks
Advanced Member
Posts: 997
Joined: Fri Jan 03, 2003 2:54 pm
Location: North West UK
Contact:

Postby mSparks » Mon Jan 12, 2004 4:19 pm

new additions to specification for next release

Code: Select all

void A3D_OggStreamStart(char *filename);

starts a streamed ogg file (reduced load time and memory usage)
only one stream is supported, and it can be stopped by either starting a new stream or issuing a

Code: Select all

void A3D_OggStreamStop(void);

n.b. non streamed ogg files (i.e. suitable for short ones, that cant be stopped) are already supported by A3D_StartSound: where both filenames are path relative, outside the mod folder and appended with the 'sound' directory:
e.g. "play music.ogg" plays "ltktbm\sound\music.ogg", not "ltktbm\action\sound\music.ogg"

a new function

Code: Select all

void A3D_StreamUpdate(void);

needs to be continually called each frame to progress the audio streams for both cinematic sounds and ogg files, and a new, as yet, unspecified function will be used to append data for the cinematic sound stream.

I plan to use the stream start/stop for playing menu and other background music
© Mark 'mSparks' Parker 2010

<pubkey>AJXzWKeV59HaoUkmrCwP9f+kMr8aOIM
jMKy7ACsaRDCE/XuF0orj/jActtfWDMKjg/CixI7JP0Z6lbS99dc
86fxDIQOmfIU8BNYKPmlPA/uY3ZpT9/4iQY0XwKad5eJhDFW
cZ2Z4VUWJzlbuoX/QV4ihTVkr9JnyJb+fN9AOqXH9AQAB</pubkey>

mSparks
Advanced Member
Posts: 997
Joined: Fri Jan 03, 2003 2:54 pm
Location: North West UK
Contact:

Postby mSparks » Tue Jan 13, 2004 2:25 pm

and finally, cinematic sounds:

Code: Select all

void A3D_PCMStream (int samples, int rate, int width, int channels, ALbyte *data)


a direct replacement for S_RawSamples to be called if the a3d engine is active. appends raw pcm data to a stream (seperate from the ogg stream), the A3D_StreamUpdate handles buffer queue removal, so theres no other changes required other than adding a call to A3D_StreamUpdate from the beginning of S_Q2A3DUpdate function in the engine specific code, which also handles the ogg stream.
© Mark 'mSparks' Parker 2010

<pubkey>AJXzWKeV59HaoUkmrCwP9f+kMr8aOIM
jMKy7ACsaRDCE/XuF0orj/jActtfWDMKjg/CixI7JP0Z6lbS99dc
86fxDIQOmfIU8BNYKPmlPA/uY3ZpT9/4iQY0XwKad5eJhDFW
cZ2Z4VUWJzlbuoX/QV4ihTVkr9JnyJb+fN9AOqXH9AQAB</pubkey>


Return to “OpenAL/EAX developement”

Who is online

Users browsing this forum: No registered users and 0 guests