Post news RSS DevBlog 21 - Making an Audio System

Creating a gameplay interface to limited audio resources. With such large battles, there are more entities attempting to use audio than can be supported. So audio must be managed to create the illusion that all ships are playing audio.

Posted by on

Adding audio to my engine.
I used OpenAL as the API is similar to OpenGL, the graphics API of this project.
I've added sounds to ship engines, lasers, explosions, UI, and more.
OpenAL makes Doppler effects easy, it just works out of the box.
I know there isn't sound in space, but I'm take a more stylized approach and wanted sounds.

I also made the audio system work with time dilation.
We can scale the pitch of audio by the current time dilation factor.
This has the effect of making the sounds sound deeper in slowmo, and higher in fast speed.

I created the entire system with a top down approach.
To know how it works, you can to the AudioSystem::tickAudioPipeline function.

sa vid21 audio system topdown de

Gameplay code doesn't need to know the internal details of how the audio system is processing data.
It should just be concerned with playing audio.
So gameplay code will spawn an audio emitter class, which internally registers with the audio system.
The audio system will give the emitter hardware resources, if appropriate.
Here is what gameplay code interfaces with.

sa vid21 audio system gameplay h

I also created some debugging tools.
You can enable a cheat that creates visual shapes at emitter locations.
This can be used to get an idea of what is causing a sound and where it is at.
I also created conditional logging that can be used to track emitter states.
This type of logging was perhaps the most useful in diagnosing problems.
example of conditional logging that helped find hard bugs:

sa vid21 audio debug conditional

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.