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
openmsx::MSXMixer
Definition: MSXMixer.hh:30
openmsx::EnumSetting< SoundDriverType >
openmsx::Mixer::registerMixer
void registerMixer(MSXMixer &mixer)
Register per-machine mixer.
Definition: Mixer.cc:105
IntegerSetting.hh
openmsx::Mixer::SND_NULL
@ SND_NULL
Definition: Mixer.hh:21
openmsx::Mixer::uploadBuffer
void uploadBuffer(MSXMixer &msxMixer, float *buffer, unsigned len)
Upload new sample data.
Definition: Mixer.cc:150
openmsx::CommandController
Definition: CommandController.hh:18
openmsx::Mixer::~Mixer
~Mixer()
Definition: Mixer.cc:65
openmsx::Setting
Definition: Setting.hh:120
BooleanSetting.hh
openmsx::Reactor
Contains the main loop of openMSX.
Definition: Reactor.hh:67
openmsx::Mixer::unmute
void unmute()
Definition: Mixer.cc:126
openmsx::Mixer::SND_SDL
@ SND_SDL
Definition: Mixer.hh:21
Observer.hh
openmsx::Mixer::mute
void mute()
This methods (un)mute the sound.
Definition: Mixer.cc:119
openmsx::Mixer::unregisterMixer
void unregisterMixer(MSXMixer &mixer)
Unregister per-machine mixer.
Definition: Mixer.cc:112
openmsx::Mixer
Definition: Mixer.hh:19
EnumSetting.hh
openmsx::Mixer::getMasterVolume
IntegerSetting & getMasterVolume()
Definition: Mixer.hh:48
openmsx::BooleanSetting
Definition: BooleanSetting.hh:9
openmsx::IntegerSetting
A Setting with an integer value.
Definition: IntegerSetting.hh:11
openmsx::Mixer::SoundDriverType
SoundDriverType
Definition: Mixer.hh:21
openmsx
This file implemented 3 utility functions:
Definition: Autofire.cc:5
openmsx::Mixer::Mixer
Mixer(Reactor &reactor, CommandController &commandController)
Definition: Mixer.cc:33
openmsx::Observer
Generic Gang-of-Four Observer class, templatized edition.
Definition: Observer.hh:10