Skip to main content
GameDev.net gamedev.net
🔒 Locked

How is audio typically handled in production-ready audio middleware and / or game engines?

Started by ichitaraaa Mar 20, 2025 at 11:29 PM 4 replies 4.3k views
Original Post
ichitaraaa
ichitaraaa

Note: By “audio middleware”, I mean products like Fmod, Wwise or OpenAL. And by “game engines” I mean publicly available options like Unity, Unreal Engine and Godot, as well as in-house AAA game engines the likes of DICE’s Frostbite, Rockstar’s RAGE, id Software’s id Tech, or Capcom’s RE Engine.

The only experience that I have with audio is through DAWs and VST plugins. The game engine that I’m trying to create has absolutely no support for audio right now, but I’m interested in learning how to implement support for audio and how that plays into events and stuff, as well as threads. I would like to be able to have control over audio (like how audio effects work) but I’d like to make sure it’s robust, stable and able to run on different machines.

I’m curious - how do robust game engines handle this problem? Do they use middleware like Wwise, Fmod or OpenAL? Do they use APIs like XAudio2, DirectSound, Core Audio, Pulse Audio or ALSA? Do they just go to the lowest level and use audio APIs like WASAPI, MME or ASIO? Or do they go even deeper than that? I’m struggling to figure out how this all works. Am I missing anything?

Xai
Xai

Unfortunately, the answer is … all of the above. I personally have created programs that used DirectSound, SDL and OpenAL (many many years ago), and more recently Unity. Actually my very first job in the 90s was on gambling games that used a proprietary platform that just had a “LoadResourceFromFile()” and “PlaySound()” method. Sound is both very easy (to use the APIs) and very complex (under the hood). Most games that used Unity in the past added another audio system on top of it (think Unity 5 and earlier) but I'm not sure that's true anymore. Wwise was very popular. I believe all the proprietary engines just include the Audio features built in (RAGE, Frostbite, etc).

Obviously some of the main questions are - are you doing 3D and need 3d positional audio - then you'll want to use your engine's support for that probably. Or, are you doing 2D, and maybe just want stereo effects …

ichitaraaa
ichitaraaa

@Xai Thank you for going into detail for your answer!

I’m trying to do a 3D engine for what I personally want to create. So far I have a super simple renderer (still starting out) that renders two hard-coded 3D models with vertex position, index and color information, responds to user input (rotates both models), and that’s it. It’s far from what I want it to be, but I’d like to continuously improve it until it gets there.

Preferably, I would like something that is capable of real-time audio effects (like I’ve heard XAudio2 is capable of), something that is guaranteed to work on different PCs of the same type (games and game engines are supposed to do this), and with an API that strikes a good balance between simplicity and versatility.

Overall I feel it doesn’t matter if I’m doing stereo or surround sound - if it sounds good and runs well, that’s what I want. 3D / positional audio would be nice, but I haven’t implemented positional audio yet. I haven’t implemented audio at all. I’m not sure if my headphones even support surround sound, and I don’t have a dedicated sound card on my PC.

TooOld2rock-nRoll
TooOld2rock-nRoll

@undefined I have no professional experience, but tried my hand at making a more robust audio API for my engine, it is hard!

You can take a look if you like: https://notabug.org/TooOld2Rock-nRoll/ArcadeFighterDemo/src/master/lib/ArcadeFighter/inc/audio

What I learned is that any decent audio library will give you the tools to “just play” audio, which is what most projects require, unless you have an audio developer in the team.

Each will offer more or less supporting tools to accomplish different goals. I'm using SLD_Mixer and they make clear it has very little support (or interest) in 3D audio, but you can manipulate the live streaming pre and post processing which gives a nice path for creating custom effects and filters.

OpenAL was my second option, it is much more robust, but requires more work to “just play” something. (I may be completely wrong though!!!)

So I guess the answer, as normally is, depends on what are your requirements and limitations.

I wanted to use only FOSS solutions for a Linux native environment, SDL seamed the easiest way to go.

"No, you're never too old to rock and roll
If you're too young to die"
frob
frob

Professionally WWise is the one I've seen used the most times, but all of those mentioned have made appearances.

Like others said, the typical “best use” pattern is either sound emitters placed in the world, or general “play the music”. Animators need to link events with audio, so that needs to be present.

Easily controlling various audio streams (music, UI, environment, dialog, etc.) is important as well. Not just for each allowing a volume slider, but full control. When you pop open a menu that pauses the game you want the game sounds and dialog audio to pause, might want background music volume to drop by half but continue, and want UI effects at their regular volume. That needs to be easy.

ichitaraaa
ichitaraaa

@frob Like others said, the typical “best use” pattern is either sound emitters placed in the world, or general “play the music”. Animators need to link events with audio, so that needs to be present.

Thank you for sharing, but this isn’t what I was looking for. The question I’m trying to ask is: how do you get audio to actually play? I mean how do you get it through your speakers?

For example, I’m seeing this video about how to play .wav files in C++ with the winmm and mmsystem libraries using the PlaySound() function. Even taking into account the restrictions to the .wav format that this method has, and the thread stuff that I guess audiovisual applications need to manage in order to work, I’m like “it surely cannot be as simple as this in a proper game engine context, can it? It looks too good to be true”.

frob
frob

ichitaraaa said:
“it surely cannot be as simple as this in a proper game engine context, can it? It looks too good to be true”.


Yes, it really is.

If you look at windows functions like PlaySound, you do exactly that: give it a wav file and the audio is played.

In the 1990s there was far more to it, the game developers needed to process audio, do work with waveforms, keep audio buffers filled in typically either 1/8 or 1/10 second intervals, but those days are gone.

In most game engines, you put audio files in a directory and let the tools preprocess them, generating resources for the game. Create audio events and audio resources by simple drag-and-drop, or let it scan the directory. All the audio events and resources are magically created, where you can take the defaults or assign it to specific audio channels like UI audio channel or background music channel or environmental sound audio.

For positional audio you drop sound emitters with those resources into the world and they “just work”. The thing in the world makes sound. If you dropped an audio emitter on a boombox radio and set the volume levels appropriately, players will hear the music get louder as they approach, they'll hear the right and left ears appropriately if they're on headphones, they'll have full 7.1 audio sound correctly if that's their audio setup.

For triggered audio like on a button click, there are a couple steps. Attach audio events to something like OnClick event, and that's it. When you click it triggers the audio event, and the audio library plays it back at the audio channel's volume and speed. Broadcast the event with PostEvent( SND_UI_Click, target); and the UI click is played for you.

Works the same if you want it triggered by a proximity trigger, attach the audio event to the proximity trigger. Or if you want it on any other OnFoo event, just broadcast the event inside your handler. PostEvent( SND_Spooky_FloorCreak, target); and your creaky floor triggers. Many common ones are prebuilt, you can attach them to a game object with no work beyond setting the parameter properties.

Works the same if you want it tied to an animation, in the animation the animator can trigger an audio event on frame 27 or whatever. The animation tools in game engines let animators tag animation frames with audio events. Trigger the explosion sound on the correct frame, trigger the “ouch” voice line when the animation is a player recoiling in pain, trigger the creaky floor audio on the frame the foot touches the ground.

The audio systems in place now got popular in the late 90's because they were easy to use, and over the years they've gotten even easier to use. Sound designers can go deep into what the do, they can make complex playback options, pairing an audio event to a large number of audio varieties, chain up complex patterns, but from the gameplay perspective they are extremely easy to use.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.