openMSX
Mixer.hh
Go to the documentation of this file.
1 #ifndef MIXER_HH
2 #define MIXER_HH
3 
4 #include "Observer.hh"
5 #include "BooleanSetting.hh"
6 #include "EnumSetting.hh"
7 #include "IntegerSetting.hh"
8 #include <vector>
9 #include <memory>
10 
11 namespace openmsx {
12 
13 class SoundDriver;
14 class Reactor;
15 class CommandController;
16 class MSXMixer;
17 
18 class Mixer final : private Observer<Setting>
19 {
20 public:
22 
23  Mixer(Reactor& reactor, CommandController& commandController);
24  ~Mixer();
25 
28  void registerMixer(MSXMixer& mixer);
29 
32  void unregisterMixer(MSXMixer& mixer);
33 
39  void mute();
40  void unmute();
41 
42  // Called by MSXMixer
43 
46  void uploadBuffer(MSXMixer& msxMixer, float* buffer, unsigned len);
47 
48  IntegerSetting& getMasterVolume() { return masterVolume; }
49 
50 private:
51  void reloadDriver();
52  void muteHelper();
53 
54  // Observer<Setting>
55  void update(const Setting& setting) override;
56 
57  std::vector<MSXMixer*> msxMixers; // unordered
58 
59  std::unique_ptr<SoundDriver> driver;
60  Reactor& reactor;
61  CommandController& commandController;
62 
63  EnumSetting<SoundDriverType> soundDriverSetting;
64  BooleanSetting muteSetting;
65  IntegerSetting masterVolume;
66  IntegerSetting frequencySetting;
67  IntegerSetting samplesSetting;
68 
69  int muteCount;
70 };
71 
72 } // namespace openmsx
73 
74 #endif
Contains the main loop of openMSX.
Definition: Reactor.hh:66
void uploadBuffer(MSXMixer &msxMixer, float *buffer, unsigned len)
Upload new sample data.
Definition: Mixer.cc:149
Mixer(Reactor &reactor, CommandController &commandController)
Definition: Mixer.cc:32
A Setting with an integer value.
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
void mute()
This methods (un)mute the sound.
Definition: Mixer.cc:118
void unregisterMixer(MSXMixer &mixer)
Unregister per-machine mixer.
Definition: Mixer.cc:111
IntegerSetting & getMasterVolume()
Definition: Mixer.hh:48
void registerMixer(MSXMixer &mixer)
Register per-machine mixer.
Definition: Mixer.cc:104
Generic Gang-of-Four Observer class, templatized edition.
Definition: Observer.hh:9
void unmute()
Definition: Mixer.cc:125