28 return soundDriverMap;
33 , commandController(commandController_)
35 commandController,
"sound_driver",
36 "select the sound output driver",
37 Mixer::SND_SDL, getSoundDriverMap())
39 commandController,
"mute",
40 "(un)mute the emulation sound", false,
Setting::DONT_SAVE)
42 commandController,
"master_volume",
43 "master volume", 75, 0, 100)
45 commandController,
"frequency",
46 "mixer frequency", 44100, 11025, 48000)
48 commandController,
"samples",
52 muteSetting .
attach(*
this);
53 frequencySetting .
attach(*
this);
54 samplesSetting .
attach(*
this);
55 soundDriverSetting.
attach(*
this);
65 assert(msxMixers.empty());
68 soundDriverSetting.
detach(*
this);
69 samplesSetting .
detach(*
this);
70 frequencySetting .
detach(*
this);
71 muteSetting .
detach(*
this);
74 void Mixer::reloadDriver()
80 driver = std::make_unique<NullSoundDriver>();
83 switch (soundDriverSetting.
getEnum()) {
85 driver = std::make_unique<NullSoundDriver>();
88 driver = std::make_unique<SDLSoundDriver>(
96 }
catch (MSXException& e) {
105 assert(!
contains(msxMixers, &mixer));
106 msxMixers.push_back(&mixer);
119 if (muteCount++ == 0) {
127 if (--muteCount == 0) {
132 void Mixer::muteHelper()
134 bool isMuted = muteCount || msxMixers.empty();
135 unsigned samples = isMuted ? 0 : driver->getSamples();
136 unsigned frequency = driver->getFrequency();
137 for (
auto& m : msxMixers) {
138 m->setMixerParams(samples, frequency);
151 assert(!msxMixers.empty());
153 driver->uploadBuffer(buffer, len);
158 if (&
setting == &muteSetting) {
159 if (muteSetting.getBoolean()) {
164 }
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.
void uploadBuffer(MSXMixer &msxMixer, float *buffer, unsigned len)
Upload new sample data.
Mixer(Reactor &reactor, CommandController &commandController)
void unregisterMixer(MSXMixer &mixer)
Unregister per-machine mixer.
Contains the main loop of openMSX.
void detach(Observer< T > &observer)
void attach(Observer< T > &observer)
This file implemented 3 utility functions:
constexpr int defaultsamples
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.