R-Type
Distributed multiplayer game engine in C++
Loading...
Searching...
No Matches
Audio::SoundEffectManager Class Reference

Sound effect manager implementation using the graphics audio system. More...

#include <SoundEffectManager.hpp>

Inheritance diagram for Audio::SoundEffectManager:
Inheritance graph
Collaboration diagram for Audio::SoundEffectManager:
Collaboration graph

Public Member Functions

 SoundEffectManager (Graphics::IGraphics &graphics)
 Construct the sound effect manager.
 
 ~SoundEffectManager () override
 Destructor - unloads all sounds.
 
 SoundEffectManager (const SoundEffectManager &)=delete
 
SoundEffectManageroperator= (const SoundEffectManager &)=delete
 
 SoundEffectManager (SoundEffectManager &&)=default
 
SoundEffectManageroperator= (SoundEffectManager &&)=default
 
bool Initialize ()
 Initialize the audio system and load all sounds.
 
void PlayClickSound () override
 Play the button click sound effect.
 
void PlayMainMenuOpenSound () override
 Play the main menu open sound effect.
 
void PlayRoomMenuOpenSound () override
 Play the room menu open sound effect.
 
void SetVolume (float volume) override
 Set the master volume for all sound effects.
 
float GetVolume () const override
 Get the current master volume.
 
- Public Member Functions inherited from Audio::ISoundEffectService
virtual ~ISoundEffectService ()=default
 

Private Member Functions

void LoadSounds ()
 
void ApplyVolumeToAllSounds ()
 

Private Attributes

Graphics::IGraphics_graphics
 
float _volume {DEFAULT_SOUND_EFFECT_VOLUME}
 
bool _initialized {false}
 

Static Private Attributes

static constexpr const char * SOUND_CLICK = "menu_click"
 
static constexpr const char * SOUND_MAIN_MENU_OPEN = "main_menu_open"
 
static constexpr const char * SOUND_ROOM_MENU_OPEN = "room_menu_open"
 
static constexpr const char * PATH_CLICK = "assets/sounds/menu-click.mp3"
 
static constexpr const char * PATH_MAIN_MENU_OPEN = "assets/sounds/main-menu-open.mp3"
 
static constexpr const char * PATH_ROOM_MENU_OPEN = "assets/sounds/rooms-menu-open.mp3"
 

Detailed Description

Sound effect manager implementation using the graphics audio system.

This class manages loading and playing menu sound effects. It uses the IGraphics interface for audio operations, maintaining consistency with the rest of the codebase.

Sound file paths (relative to project root):

  • Button click: assets/sounds/menu-click.mp3
  • Main menu open: assets/sounds/main-menu-open.mp3
  • Room menu open: assets/sounds/rooms-menu-open.mp3

Definition at line 33 of file SoundEffectManager.hpp.

Constructor & Destructor Documentation

◆ SoundEffectManager() [1/3]

Audio::SoundEffectManager::SoundEffectManager ( Graphics::IGraphics graphics)
explicit

Construct the sound effect manager.

Parameters
graphicsGraphics interface with audio capabilities.

Definition at line 12 of file SoundEffectManager.cpp.

◆ ~SoundEffectManager()

Audio::SoundEffectManager::~SoundEffectManager ( )
override

Destructor - unloads all sounds.

Definition at line 14 of file SoundEffectManager.cpp.

References _graphics, _initialized, SOUND_CLICK, SOUND_MAIN_MENU_OPEN, SOUND_ROOM_MENU_OPEN, and Graphics::IGraphics::UnloadSound().

Here is the call graph for this function:

◆ SoundEffectManager() [2/3]

Audio::SoundEffectManager::SoundEffectManager ( const SoundEffectManager )
delete

◆ SoundEffectManager() [3/3]

Audio::SoundEffectManager::SoundEffectManager ( SoundEffectManager &&  )
default

Member Function Documentation

◆ ApplyVolumeToAllSounds()

void Audio::SoundEffectManager::ApplyVolumeToAllSounds ( )
private

Definition at line 56 of file SoundEffectManager.cpp.

References _graphics, _volume, Graphics::IGraphics::SetSoundVolume(), SOUND_CLICK, SOUND_MAIN_MENU_OPEN, and SOUND_ROOM_MENU_OPEN.

Referenced by Initialize(), and SetVolume().

Here is the call graph for this function:

◆ GetVolume()

float Audio::SoundEffectManager::GetVolume ( ) const
overridevirtual

Get the current master volume.

Returns
Current volume level (0.0 to 1.0)

Implements Audio::ISoundEffectService.

Definition at line 87 of file SoundEffectManager.cpp.

References _volume.

◆ Initialize()

bool Audio::SoundEffectManager::Initialize ( )

Initialize the audio system and load all sounds.

Returns
true if initialization was successful.

Definition at line 22 of file SoundEffectManager.cpp.

References _graphics, _initialized, _volume, ApplyVolumeToAllSounds(), Graphics::IGraphics::InitAudioDevice(), Graphics::IGraphics::IsAudioDeviceReady(), LoadSounds(), LOG_ERROR, and LOG_INFO.

Here is the call graph for this function:

◆ LoadSounds()

void Audio::SoundEffectManager::LoadSounds ( )
private

◆ operator=() [1/2]

SoundEffectManager & Audio::SoundEffectManager::operator= ( const SoundEffectManager )
delete

◆ operator=() [2/2]

SoundEffectManager & Audio::SoundEffectManager::operator= ( SoundEffectManager &&  )
default

◆ PlayClickSound()

void Audio::SoundEffectManager::PlayClickSound ( )
overridevirtual

Play the button click sound effect.

Implements Audio::ISoundEffectService.

Definition at line 62 of file SoundEffectManager.cpp.

References _graphics, _initialized, Graphics::IGraphics::PlaySound(), and SOUND_CLICK.

Here is the call graph for this function:

◆ PlayMainMenuOpenSound()

void Audio::SoundEffectManager::PlayMainMenuOpenSound ( )
overridevirtual

Play the main menu open sound effect.

Implements Audio::ISoundEffectService.

Definition at line 68 of file SoundEffectManager.cpp.

References _graphics, _initialized, Graphics::IGraphics::PlaySound(), and SOUND_MAIN_MENU_OPEN.

Here is the call graph for this function:

◆ PlayRoomMenuOpenSound()

void Audio::SoundEffectManager::PlayRoomMenuOpenSound ( )
overridevirtual

Play the room menu open sound effect.

Implements Audio::ISoundEffectService.

Definition at line 74 of file SoundEffectManager.cpp.

References _graphics, _initialized, Graphics::IGraphics::PlaySound(), and SOUND_ROOM_MENU_OPEN.

Here is the call graph for this function:

◆ SetVolume()

void Audio::SoundEffectManager::SetVolume ( float  volume)
overridevirtual

Set the master volume for all sound effects.

Parameters
volumeVolume level (0.0 to 1.0)

Implements Audio::ISoundEffectService.

Definition at line 80 of file SoundEffectManager.cpp.

References _initialized, _volume, and ApplyVolumeToAllSounds().

Here is the call graph for this function:

Member Data Documentation

◆ _graphics

◆ _initialized

bool Audio::SoundEffectManager::_initialized {false}
private

◆ _volume

float Audio::SoundEffectManager::_volume {DEFAULT_SOUND_EFFECT_VOLUME}
private

Definition at line 80 of file SoundEffectManager.hpp.

Referenced by ApplyVolumeToAllSounds(), GetVolume(), Initialize(), and SetVolume().

◆ PATH_CLICK

constexpr const char* Audio::SoundEffectManager::PATH_CLICK = "assets/sounds/menu-click.mp3"
staticconstexprprivate

Definition at line 89 of file SoundEffectManager.hpp.

Referenced by LoadSounds().

◆ PATH_MAIN_MENU_OPEN

constexpr const char* Audio::SoundEffectManager::PATH_MAIN_MENU_OPEN = "assets/sounds/main-menu-open.mp3"
staticconstexprprivate

Definition at line 90 of file SoundEffectManager.hpp.

Referenced by LoadSounds().

◆ PATH_ROOM_MENU_OPEN

constexpr const char* Audio::SoundEffectManager::PATH_ROOM_MENU_OPEN = "assets/sounds/rooms-menu-open.mp3"
staticconstexprprivate

Definition at line 91 of file SoundEffectManager.hpp.

Referenced by LoadSounds().

◆ SOUND_CLICK

constexpr const char* Audio::SoundEffectManager::SOUND_CLICK = "menu_click"
staticconstexprprivate

◆ SOUND_MAIN_MENU_OPEN

constexpr const char* Audio::SoundEffectManager::SOUND_MAIN_MENU_OPEN = "main_menu_open"
staticconstexprprivate

◆ SOUND_ROOM_MENU_OPEN

constexpr const char* Audio::SoundEffectManager::SOUND_ROOM_MENU_OPEN = "room_menu_open"
staticconstexprprivate

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