R-Type
Distributed multiplayer game engine in C++
Loading...
Searching...
No Matches
SoundEffectManager.cpp
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2025
3** r-type
4** File description:
5** SoundEffectManager - Manages menu sound effects
6*/
7
9#include "../common/Logger/Logger.hpp"
10
11namespace Audio {
13
21
23 if (_initialized) {
24 return true;
25 }
26
28
30 LOG_ERROR("[SoundEffectManager] Failed to initialize audio device");
31 return false;
32 }
33
34 LoadSounds();
36
37 _initialized = true;
38 LOG_INFO("[SoundEffectManager] Initialized with volume: ", static_cast<int>(_volume * 100), "%");
39 return true;
40 }
41
44 LOG_WARNING("[SoundEffectManager] Failed to load click sound: ", PATH_CLICK);
45 }
46
48 LOG_WARNING("[SoundEffectManager] Failed to load main menu open sound: ", PATH_MAIN_MENU_OPEN);
49 }
50
52 LOG_WARNING("[SoundEffectManager] Failed to load room menu open sound: ", PATH_ROOM_MENU_OPEN);
53 }
54 }
55
61
67
73
79
80 void SoundEffectManager::SetVolume(float volume) {
81 _volume = (volume < 0.0F) ? 0.0F : (volume > 1.0F) ? 1.0F : volume;
82 if (_initialized) {
84 }
85 }
86
88 return _volume;
89 }
90} // namespace Audio
#define LOG_INFO(...)
Definition Logger.hpp:181
#define LOG_ERROR(...)
Definition Logger.hpp:183
#define LOG_WARNING(...)
Definition Logger.hpp:182
Graphics::IGraphics & _graphics
~SoundEffectManager() override
Destructor - unloads all sounds.
SoundEffectManager(Graphics::IGraphics &graphics)
Construct the sound effect manager.
void PlayRoomMenuOpenSound() override
Play the room menu open sound effect.
static constexpr const char * SOUND_ROOM_MENU_OPEN
void PlayClickSound() override
Play the button click sound effect.
static constexpr const char * SOUND_MAIN_MENU_OPEN
static constexpr const char * SOUND_CLICK
float GetVolume() const override
Get the current master volume.
void SetVolume(float volume) override
Set the master volume for all sound effects.
bool Initialize()
Initialize the audio system and load all sounds.
static constexpr const char * PATH_ROOM_MENU_OPEN
static constexpr const char * PATH_MAIN_MENU_OPEN
void PlayMainMenuOpenSound() override
Play the main menu open sound effect.
static constexpr const char * PATH_CLICK
Abstract interface for graphics rendering operations.
Definition IGraphics.hpp:32
virtual bool LoadSound(const char *soundName, const char *filepath)=0
Load a sound from file.
virtual void PlaySound(const char *soundName)=0
Play a loaded sound.
virtual void UnloadSound(const char *soundName)=0
Unload a previously loaded sound.
virtual bool IsAudioDeviceReady() const =0
Check if audio device is ready.
virtual void SetSoundVolume(const char *soundName, float volume)=0
Set volume for a specific sound.
virtual void InitAudioDevice()=0
Initialize the audio device.