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.
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.
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: