Middleware-agnostic audio system for Flax Engine.
This repository contains two modules:
AudioSystem(runtime): request pipeline, scene actors, and gameplay scriptsAudioSystemEditor(editor): settings UI, toolbar integration, and build deploy hook
Repository: https://github.com/SparkyStudios/FlaxAudioSystemPlugin
- Middleware abstraction via
AudioMiddleware(implement your own backend as a native plugin) - Threaded request processing (
AudioSystem+AudioTranslationLayer) with main-thread callbacks - Scene actors:
AudioProxyActor: spatial audio entity that tracks transformAudioListenerActor: spatial listener (supports default listener + override actors)AudioBoxEnvironmentActor/AudioSphereEnvironmentActor: environment zones with falloff
- Gameplay scripts:
AudioTriggerScript: play/stop triggers, optional obstruction/occlusion raycastsAudioRtpcScript: set/reset RTPC valuesAudioSwitchStateScript: set switch statesAudioAnimationScript+AudioAnimEvent: trigger audio from animation events
- Editor integration:
- “Audio System” settings with master gain + mute
- game cooking deploy hook that forwards to middleware (
DeployFiles)
- Flax Engine
>= 0.0.6167(see AudioSystem.flaxproj)
Add this project as a reference to your Flax game project, then rebuild.
- Clone this repository somewhere on disk (commonly next to your game project).
- Edit your game
.flaxprojand add a reference toAudioSystem.flaxproj:
{
"References": [
{ "Name": "path/to/FlaxAudioSystemPlugin/AudioSystem.flaxproj" }
]
}- Regenerate project files and build (or open the project in Flax Editor and let it compile).
This repository provides the audio system, but does not ship with an actual middleware backend. To get sound, you need to load a backend plugin that implements AudioMiddleware and registers it with the system.
In your backend plugin (or game code), register the middleware and start the audio system:
#include <AudioSystem/Core/AudioSystem.h>
#include <AudioSystem/Core/AudioMiddleware.h>
void BindAudioMiddleware(AudioMiddleware* middleware)
{
auto* audioSystem = AudioSystem::Get();
audioSystem->RegisterMiddleware(middleware);
audioSystem->Startup();
}If your backend uses a JSON configuration asset, forward it to the system:
AudioSystem::Get()->LoadConfiguration(TEXT("Content/Audio/MiddlewareConfig.json"));- Place an
AudioListenerActorin the scene (often parented to the camera). - Set
IsDefault = trueto make it the scene-wide default listener (used by obstruction/occlusion).
- Place an
AudioProxyActorwhere you want a spatial emitter. - Add
AudioTriggerScripton the same actor and setPlayTriggerNameto a trigger registered by your middleware. - Call
Play()from code or enablePlayOnActivate.
- Add an
AudioBoxEnvironmentActororAudioSphereEnvironmentActorand setEnvironmentNameto drive environment sends for proxies inside the zone. - Add
AudioRtpcScriptfor runtime parameters. - Add
AudioSwitchStateScriptfor switch states.
For common operations from gameplay scripts, use AudioManager:
using AudioSystem;
using FlaxEngine;
AudioManager.Play(actor, "Footstep");
AudioManager.SetRtpc(actor, "Speed", 0.75f);
AudioManager.SetSwitchState(actor, "Surface_Stone");Apache License 2.0 (https://www.apache.org/licenses/LICENSE-2.0).