Game Audio Module
A C++ audio system using miniaudio with Python bindings
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
audio::AudioGroup Class Reference

Controls multiple sounds as a single unit. More...

#include <audio_group.h>

Public Member Functions

 ~AudioGroup ()
 Destructor.
 

Static Public Member Functions

static std::unique_ptr< AudioGroupCreate (ma_engine *engine)
 Factory method for creating AudioGroup instances.
 

Private Member Functions

 AudioGroup (ma_engine *engine)
 Private constructor - use Create() instead.
 
void FadeVolume (float targetVolume, std::chrono::milliseconds duration)
 Fades the group volume to a target over duration.
 
std::chrono::milliseconds GetFadeDuration () const
 Gets the duration of the current fade.
 
std::chrono::steady_clock::time_point GetFadeEndTime () const
 Gets the end time of the current fade.
 
ma_sound_group * GetHandle ()
 Gets the underlying miniaudio sound group handle.
 
float GetStartVolume () const
 Gets the starting volume for the current fade.
 
float GetTargetVolume () const
 Gets the target volume for the current fade.
 
float GetVolume () const
 Gets the current volume for this group.
 
bool IsFading () const
 Checks if the group is currently fading.
 
void SetFadingState (bool fading)
 Allows AudioManager to set fading state directly.
 
void SetVolume (float volume)
 Sets the volume for this group.
 

Private Attributes

float volume_
 Current volume level.
 
Fade State
float target_volume_ {0.0f}
 Target volume for fade.
 
float start_volume_ {0.0f}
 Starting volume for fade.
 
bool is_fading_ {false}
 Whether currently fading.
 
std::chrono::steady_clock::time_point fade_end_time_
 When the fade will end.
 
std::chrono::milliseconds fade_duration_ {0}
 Duration of the fade.
 
miniaudio Resources
ma_sound_group * sound_group_
 miniaudio sound group handle
 
ma_engine * engine_
 Reference to miniaudio engine.
 

Friends

class AudioManager
 Allow AudioManager to access private members for control.
 
class AudioSystem
 Allow AudioSystem to create groups.
 
class Sound
 Allow Sound to access the group handle.
 

Detailed Description

Controls multiple sounds as a single unit.

AudioGroup allows collective control over multiple sounds (e.g., all music or all sound effects). This enables group volume adjustment, fading, and other operations to be applied to multiple sounds simultaneously.

Groups are mapped to miniaudio sound groups internally.

Constructor & Destructor Documentation

◆ AudioGroup()

audio::AudioGroup::AudioGroup ( ma_engine *  engine)
explicitprivate

Private constructor - use Create() instead.

Parameters
enginePointer to the miniaudio engine

◆ ~AudioGroup()

audio::AudioGroup::~AudioGroup ( )

Destructor.

Cleans up miniaudio resources

Member Function Documentation

◆ Create()

static std::unique_ptr< AudioGroup > audio::AudioGroup::Create ( ma_engine *  engine)
inlinestatic

Factory method for creating AudioGroup instances.

This static factory method ensures proper initialization and encapsulation of AudioGroup objects.

Parameters
enginePointer to the miniaudio engine
Returns
std::unique_ptr<AudioGroup> Unique pointer to a new AudioGroup

◆ FadeVolume()

void audio::AudioGroup::FadeVolume ( float  targetVolume,
std::chrono::milliseconds  duration 
)
private

Fades the group volume to a target over duration.

Parameters
targetVolumeTarget volume level (0.0 to 1.0)
durationDuration of the fade in milliseconds

◆ GetFadeDuration()

std::chrono::milliseconds audio::AudioGroup::GetFadeDuration ( ) const
inlineprivate

Gets the duration of the current fade.

Returns
std::chrono::milliseconds Duration in milliseconds

◆ GetFadeEndTime()

std::chrono::steady_clock::time_point audio::AudioGroup::GetFadeEndTime ( ) const
inlineprivate

Gets the end time of the current fade.

Returns
std::chrono::steady_clock::time_point When the fade will complete

◆ GetHandle()

ma_sound_group * audio::AudioGroup::GetHandle ( )
inlineprivate

Gets the underlying miniaudio sound group handle.

Returns
ma_sound_group* Pointer to the miniaudio sound group

◆ GetStartVolume()

float audio::AudioGroup::GetStartVolume ( ) const
inlineprivate

Gets the starting volume for the current fade.

Returns
float Starting volume level

◆ GetTargetVolume()

float audio::AudioGroup::GetTargetVolume ( ) const
inlineprivate

Gets the target volume for the current fade.

Returns
float Target volume level

◆ GetVolume()

float audio::AudioGroup::GetVolume ( ) const
inlineprivate

Gets the current volume for this group.

Returns
float Current volume level (0.0 to 1.0)

◆ IsFading()

bool audio::AudioGroup::IsFading ( ) const
inlineprivate

Checks if the group is currently fading.

Returns
bool True if currently fading, false otherwise

◆ SetFadingState()

void audio::AudioGroup::SetFadingState ( bool  fading)
inlineprivate

Allows AudioManager to set fading state directly.

Parameters
fadingWhether the group is fading

◆ SetVolume()

void audio::AudioGroup::SetVolume ( float  volume)
private

Sets the volume for this group.

Parameters
volumeVolume level (0.0 to 1.0)

Friends And Related Symbol Documentation

◆ AudioManager

friend class AudioManager
friend

Allow AudioManager to access private members for control.

◆ AudioSystem

friend class AudioSystem
friend

Allow AudioSystem to create groups.

◆ Sound

friend class Sound
friend

Allow Sound to access the group handle.

Member Data Documentation

◆ engine_

ma_engine* audio::AudioGroup::engine_
private

Reference to miniaudio engine.

◆ fade_duration_

std::chrono::milliseconds audio::AudioGroup::fade_duration_ {0}
private

Duration of the fade.

◆ fade_end_time_

std::chrono::steady_clock::time_point audio::AudioGroup::fade_end_time_
private

When the fade will end.

◆ is_fading_

bool audio::AudioGroup::is_fading_ {false}
private

Whether currently fading.

◆ sound_group_

ma_sound_group* audio::AudioGroup::sound_group_
private

miniaudio sound group handle

◆ start_volume_

float audio::AudioGroup::start_volume_ {0.0f}
private

Starting volume for fade.

◆ target_volume_

float audio::AudioGroup::target_volume_ {0.0f}
private

Target volume for fade.

◆ volume_

float audio::AudioGroup::volume_
private

Current volume level.


The documentation for this class was generated from the following files: