37 lines
1.4 KiB
C++
37 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <unordered_map>
|
|
|
|
#include "core/audio/jail_audio.hpp" // Per a Ja::EchoParams / Ja::ReverbParams
|
|
|
|
// Catàleg de presets d'efectes carregat des de data/config/sounds.yaml. La capa
|
|
// Audio (playSoundWithEcho/playSoundWithReverb) hi accedeix per nom: si el
|
|
// preset no existeix, el so es reprodueix sec amb un avís a stderr.
|
|
//
|
|
// Patró Meyers idèntic a UiConfig/Locale: un sol load() a l'arrencada, sense
|
|
// hot-reload. Si el fitxer no existeix, el catàleg queda buit (cap preset
|
|
// disponible) i tots els playSoundWith* es comporten com playSound dry.
|
|
class SoundEffectsConfig {
|
|
public:
|
|
static auto get() -> SoundEffectsConfig&;
|
|
|
|
SoundEffectsConfig(const SoundEffectsConfig&) = delete;
|
|
SoundEffectsConfig(SoundEffectsConfig&&) = delete;
|
|
auto operator=(const SoundEffectsConfig&) -> SoundEffectsConfig& = delete;
|
|
auto operator=(SoundEffectsConfig&&) -> SoundEffectsConfig& = delete;
|
|
|
|
void load(const std::string& file_path);
|
|
|
|
// Retorna nullptr si el preset no existeix.
|
|
[[nodiscard]] auto findEcho(const std::string& name) const -> const Ja::EchoParams*;
|
|
[[nodiscard]] auto findReverb(const std::string& name) const -> const Ja::ReverbParams*;
|
|
|
|
private:
|
|
SoundEffectsConfig() = default;
|
|
~SoundEffectsConfig() = default;
|
|
|
|
std::unordered_map<std::string, Ja::EchoParams> echoes_;
|
|
std::unordered_map<std::string, Ja::ReverbParams> reverbs_;
|
|
};
|