17static constexpr int defaultSamples = 2048;
19static constexpr int defaultSamples = 1024;
27 return soundDriverMap;
32 , commandController(commandController_)
34 commandController,
"sound_driver",
35 "select the sound output driver",
36 Mixer::SND_SDL, getSoundDriverMap())
38 commandController,
"mute",
39 "(un)mute the emulation sound", false,
Setting::DONT_SAVE)
41 commandController,
"master_volume",
42 "master volume", 75, 0, 100)
44 commandController,
"frequency",
45 "mixer frequency", 44100, 11025, 48000)
47 commandController,
"samples",
48 "mixer samples", defaultSamples, 64, 8192)
50 muteSetting .
attach(*
this);
51 frequencySetting .
attach(*
this);
52 samplesSetting .
attach(*
this);
53 soundDriverSetting.
attach(*
this);
63 assert(msxMixers.empty());
66 soundDriverSetting.
detach(*
this);
67 samplesSetting .
detach(*
this);
68 frequencySetting .
detach(*
this);
69 muteSetting .
detach(*
this);
72void Mixer::reloadDriver()
78 driver = std::make_unique<NullSoundDriver>();
81 switch (soundDriverSetting.
getEnum()) {
83 driver = std::make_unique<NullSoundDriver>();
86 driver = std::make_unique<SDLSoundDriver>(
94 }
catch (MSXException& e) {
103 assert(!
contains(msxMixers, &mixer));
104 msxMixers.push_back(&mixer);
117 if (muteCount++ == 0) {
125 if (--muteCount == 0) {
130void Mixer::muteHelper()
132 bool isMuted = muteCount || msxMixers.empty();
133 unsigned samples = isMuted ? 0 : driver->getSamples();
134 unsigned frequency = driver->getFrequency();
135 for (
auto& m : msxMixers) {
136 m->setMixerParams(samples, frequency);
149 assert(!msxMixers.empty());
151 driver->uploadBuffer(buffer);
156 if (&
setting == &muteSetting) {
157 if (muteSetting.getBoolean()) {
162 }
else if (&
setting ==
one_of(&samplesSetting, &soundDriverSetting, &frequencySetting)) {
bool getBoolean() const noexcept
void printWarning(std::string_view message)
virtual CliComm & getCliComm()=0
T getEnum() const noexcept
int getInt() const noexcept
void registerMixer(MSXMixer &mixer)
Register per-machine mixer.
void mute()
This methods (un)mute the sound.
Mixer(Reactor &reactor, CommandController &commandController)
void unregisterMixer(MSXMixer &mixer)
Unregister per-machine mixer.
void uploadBuffer(MSXMixer &msxMixer, std::span< const StereoFloat > buffer)
Upload new sample data.
Contains the main loop of openMSX.
void detach(Observer< T > &observer)
void attach(Observer< T > &observer)
This file implemented 3 utility functions:
void move_pop_back(VECTOR &v, typename VECTOR::iterator it)
Erase the pointed to element from the given vector.
auto rfind_unguarded(RANGE &range, const VAL &val, Proj proj={})
Similar to the find(_if)_unguarded functions above, but searches from the back to front.
constexpr bool contains(ITER first, ITER last, const VAL &val)
Check if a range contains a given value, using linear search.