21static constexpr int defaultSamples = 2048;
23static constexpr int defaultSamples = 1024;
31 return soundDriverMap;
36 , commandController(commandController_)
38 commandController,
"sound_driver",
39 "select the sound output driver",
42 commandController,
"mute",
43 "(un)mute the emulation sound", false,
Setting::Save::NO)
45 commandController,
"master_volume",
46 "master volume", 75, 0, 100)
48 commandController,
"frequency",
49 "mixer frequency", 44100, 11025, 48000)
51 commandController,
"samples",
52 "mixer samples", defaultSamples, 64, 8192)
54 muteSetting .
attach(*
this);
55 frequencySetting .
attach(*
this);
56 samplesSetting .
attach(*
this);
57 soundDriverSetting.
attach(*
this);
67 assert(msxMixers.empty());
70 soundDriverSetting.
detach(*
this);
71 samplesSetting .
detach(*
this);
72 frequencySetting .
detach(*
this);
73 muteSetting .
detach(*
this);
76void Mixer::reloadDriver()
82 driver = std::make_unique<NullSoundDriver>();
85 switch (soundDriverSetting.
getEnum()) {
87 driver = std::make_unique<SDLSoundDriver>(
96 }
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 if (!driver) reloadDriver();
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);
156 assert(!msxMixers.empty());
158 driver->uploadBuffer(buffer);
163 if (&
setting == &muteSetting) {
164 if (muteSetting.getBoolean()) {
169 }
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.