Selected work

C++ Audio Subsystem

An audio subsystem I added to the supplied XCube2D framework.

XCube2D coursework walkthrough. Watch on YouTube ↗
Role
Audio subsystem programmer
Framework
Supplied XCube2D engine
Repository activity
December 2025–January 2026
Tools
C++, SDL2 / SDL_mixer

My contribution

  • Added named audio layers to MyEngineSystem, with volume and mute controls for each layer.
  • Added checks for the audio backend, sound layer and resource before playback, plus separate music playback controls.

Development started before the repository’s first commit.

Programming notes

Audio layers

Each named layer stores its own volume and mute state.

Creating a layer checks for an existing name. Volume changes are clamped to the 0–1 range.

MyEngineSystem.h

struct AudioLayer
{
    float volume = 1.0f;
    bool muted = false;
};

Playback checks

Play returns if the audio backend or requested layer is missing, the layer is muted, or the sound resource cannot be found.

For valid requests, it converts the layer volume to the mixer range and calls the audio backend. Music uses separate play and stop methods, with a loop setting.

MyEngineSystem.cpp

if (!audio) return; //audio engine not initialised

//layer must exist to apply mixing rules (volume/mute)
if (!HasLayer(layer)) return; //layer not found