feat(audio): add per-channel volume control and config reload

This commit is contained in:
2026-07-07 13:29:28 +08:00
parent a5bc4e238d
commit 5264755a7e
11 changed files with 102 additions and 19 deletions

View File

@@ -49,6 +49,7 @@ public:
ClientWorld& client_world();
ServerWorld& server_world();
const Argument& argument() const;
AudioEngine& audio();
private:
Camera m_camera;

View File

@@ -30,7 +30,10 @@ public:
bool check = false);
void update_listener(const glm::vec3& pos, const glm::vec3& forward,
const glm::vec3& up);
void update(float dt);
void update();
void reload_config();
float& bgm_target_volume();
private:
using FadeMap = std::unordered_map<std::string, AudioFade>;
@@ -42,5 +45,8 @@ private:
FadeMap m_fade_map;
SoundManager m_sounds;
std::shared_ptr<SourcePool> m_pool;
float m_music_volume = 1.0f;
float m_sfx_volume = 1.0f;
};
} // namespace Cubed

View File

@@ -12,7 +12,6 @@ private:
float m_in_duration = 0.0f;
float m_out_duration = 0.0f;
float m_start_gain = 0.0f;
float m_end_gain = 0.0f;
bool m_fade_in = true;
bool m_active = true;
};

View File

@@ -9,7 +9,7 @@ enum class AudioState { INITIAL, PLAYING, PAUSED, STOPPED };
class AudioSource {
public:
AudioSource();
AudioSource(float volume = 1.0f);
~AudioSource();
void set_buffer_2d(const AudioBuffer& buffer);
@@ -25,7 +25,9 @@ public:
void pause();
float duration() const;
float current_time() const;
float volume() const;
float target_volume() const;
float& target_volume();
void set_target_volume(float volume);
AudioState state() const;
void mark_in_use();
@@ -34,7 +36,7 @@ public:
private:
ALuint m_source = 0;
float m_volume = 1.0f;
float m_target_volume = 1.0f;
float m_duration = 0.0f;
bool m_using;
};

View File

@@ -20,6 +20,8 @@ class DevPanel {
bool is_enable_aniso = false;
bool is_support_aniso = true;
bool is_reload = true;
float volume_music = 1.0f;
float volume_sfx = 1.0f;
};
struct PlayerProfile {
int game_mode = 0;