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;
};
An audio subsystem I added to the supplied XCube2D framework.
Development started before the repository’s first commit.
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;
};
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