Skip to content

Added audio system with support for polyphony and spatialisation - #73

Open
jonjondev wants to merge 9 commits into
mainfrom
feature/audio
Open

jonjondev wants to merge 9 commits into
mainfrom
feature/audio

Conversation

@jonjondev

Copy link
Copy Markdown
Member

Description

This PR introduces a new module to the engine for audio, providing an audio system that can be included by other library or executable targets to manage sound playback. The change also introduces the miniaudio library dependency, functioning as a backend for the decoding playback functionality which is entirely abstracted away from the interface to avoid bleeding the dependency to dependent code. The following features are currently supported by the system:

  • WAV and MP3 formats at either 44 or 44.1kHz
  • Clip looping
  • Voice polyphony
  • Listener spatialisation
  • Sound spatialisation

The system functions by exposing the ability to create and register sound players that can contain and update configuration and the appropriate clip data (which uses raw data from pack files) to the audio system as so:

Siege::PackFile* packFile = Siege::ResourceSystem::GetInstance().GetPackFile();
Siege::SoundPlayer exampleSoundPlayer.clipData = packFile->FindData("example.wav");
exampleSoundPlayer.looping = true;
exampleSoundPlayer.maxPolyphony = 1;
exampleSoundPlayer.disableSpatialisation = true;
exampleSoundPlayer.Play();

The system can then attempt to assign the requested sound player out to a free voice to run playback of the sound. If the sound is above its max polyphony threshold or a free voice is not found, it will ignore the request. The sound player can also be updated each frame by its owner to modify its spatialisation in which its location must be set. Because the audio work is kicked over to the audio thread for processing, the system must take care to handle callbacks and requests moving between the game and audio. The system otherwise functions similarly to other engine modules with lifetime hooks for use as part of the game loop.

The system's usage has been added to the examples with test data. Opening the game example, the user can now press the c key to play click.wav (spatialised), the f key to play call_to_adventure.mp3 (looping), and the g key to stop call_to_adventure.mp3. Changing scenes will also clear any playing audio for the entities.

The PR has been...

  • provided a reasonable name that is not just the branch name (e.g "Added Vulkan render delegate")
  • linked to its related issue
  • assigned a reviewer from the team
  • labelled appropriately

The code has been...

  • made mergable and free of conflicts in relation to master (according to GitHub)
  • tested in a packaged state using the package targets
  • pulled to the reviewer's machine and reasonably tested

@jonjondev
jonjondev requested a review from Raelr November 8, 2026 22:39
@jonjondev jonjondev added the Audio Relating to the engine's audio system label Nov 8, 2026
@jonjondev jonjondev changed the title Added audio system module with support for polyphony and spatialisation Added audio system with support for polyphony and spatialisation Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Audio Relating to the engine's audio system

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant