22 static const int defaultsamples = 2048;
23 #elif PLATFORM_ANDROID
24 static const int defaultsamples = 2560;
26 static const int defaultsamples = 1024;
31 , commandController(commandController_)
33 commandController,
"mute",
34 "(un)mute the emulation sound", false,
Setting::DONT_SAVE))
36 commandController,
"master_volume",
37 "master volume", 75, 0, 100))
39 commandController,
"frequency",
40 "mixer frequency", 44100, 11025, 48000))
42 commandController,
"samples",
43 "mixer samples", defaultsamples, 64, 8192))
47 soundDriverMap[
"null"] = SND_NULL;
48 soundDriverMap[
"sdl"] = SND_SDL;
49 SoundDriverType defaultSoundDriver = SND_SDL;
52 soundDriverMap[
"directx"] = SND_DIRECTX;
53 defaultSoundDriver = SND_DIRECTX;
56 soundDriverMap[
"libao"] = SND_LIBAO;
59 soundDriverSetting = make_unique<EnumSetting<SoundDriverType>>(
60 commandController,
"sound_driver",
61 "select the sound output driver",
62 defaultSoundDriver, soundDriverMap);
64 muteSetting->attach(*
this);
65 frequencySetting->attach(*
this);
66 samplesSetting->attach(*
this);
67 soundDriverSetting->attach(*
this);
70 if (muteSetting->getValue()) ++muteCount;
77 assert(msxMixers.empty());
80 soundDriverSetting->detach(*
this);
81 samplesSetting->detach(*
this);
82 frequencySetting->detach(*
this);
83 muteSetting->detach(*
this);
86 void Mixer::reloadDriver()
88 driver = make_unique<NullSoundDriver>();
91 switch (soundDriverSetting->getValue()) {
93 driver = make_unique<NullSoundDriver>();
96 driver = make_unique<SDLSoundDriver>(
98 frequencySetting->getValue(),
99 samplesSetting->getValue());
103 driver = make_unique<DirectXSoundDriver>(
104 frequencySetting->getValue(),
105 samplesSetting->getValue());
110 driver = make_unique<LibAOSoundDriver>(
111 frequencySetting->getValue(),
112 samplesSetting->getValue());
118 }
catch (MSXException& e) {
127 assert(count(msxMixers.begin(), msxMixers.end(), &mixer) == 0);
128 msxMixers.push_back(&mixer);
135 assert(count(msxMixers.begin(), msxMixers.end(), &mixer) == 1);
136 msxMixers.erase(find(msxMixers.begin(), msxMixers.end(), &mixer));
144 if (muteCount++ == 0) {
152 if (--muteCount == 0) {
157 void Mixer::muteHelper()
159 bool mute = muteCount || msxMixers.empty();
160 unsigned samples = mute ? 0 : driver->getSamples();
161 unsigned frequency = driver->getFrequency();
162 for (
auto& m : msxMixers) {
163 m->setMixerParams(samples, frequency);
175 return *masterVolume;
181 assert(!msxMixers.empty());
183 driver->uploadBuffer(buffer, len);
186 void Mixer::update(
const Setting& setting)
188 if (&setting == muteSetting.get()) {
189 if (muteSetting->getValue()) {
194 }
else if ((&setting == samplesSetting.get()) ||
195 (&setting == soundDriverSetting.get()) ||
196 (&setting == frequencySetting.get())) {