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  [[nodiscard]] IntegerSetting& getMasterVolume() { return masterVolume; }
49 
50 private:
51  void reloadDriver();
52  void muteHelper();
53 
54  // Observer<Setting>
55  void update(const Setting& setting) noexcept override;
56 
57 private:
58  std::vector<MSXMixer*> msxMixers; // unordered
59 
60  std::unique_ptr<SoundDriver> driver;
61  Reactor& reactor;
62  CommandController& commandController;
63 
64  EnumSetting<SoundDriverType> soundDriverSetting;
65  BooleanSetting muteSetting;
66  IntegerSetting masterVolume;
67  IntegerSetting frequencySetting;
68  IntegerSetting samplesSetting;
69 
70  int muteCount;
71 };
72 
73 } // namespace openmsx
74 
75 #endif
BaseSetting * setting
Definition: Interpreter.cc:27
A Setting with an integer value.
IntegerSetting & getMasterVolume()
Definition: Mixer.hh:48
void registerMixer(MSXMixer &mixer)
Register per-machine mixer.
Definition: Mixer.cc:103
void mute()
This methods (un)mute the sound.
Definition: Mixer.cc:117
void uploadBuffer(MSXMixer &msxMixer, float *buffer, unsigned len)
Upload new sample data.
Definition: Mixer.cc:148
void unmute()
Definition: Mixer.cc:124
Mixer(Reactor &reactor, CommandController &commandController)
Definition: Mixer.cc:31
void unregisterMixer(MSXMixer &mixer)
Unregister per-machine mixer.
Definition: Mixer.cc:110
Generic Gang-of-Four Observer class, templatized edition.
Definition: Observer.hh:10
Contains the main loop of openMSX.
Definition: Reactor.hh:68
This file implemented 3 utility functions:
Definition: Autofire.cc:9