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
11namespace openmsx {
12
13class SoundDriver;
14class Reactor;
15class CommandController;
16class MSXMixer;
17
19 float left = 0.0f;
20 float right = 0.0f;
21};
22
23class Mixer final : private Observer<Setting>
24{
25public:
27
28 Mixer(Reactor& reactor, CommandController& commandController);
29 ~Mixer();
30
33 void registerMixer(MSXMixer& mixer);
34
37 void unregisterMixer(MSXMixer& mixer);
38
44 void mute();
45 void unmute();
46
47 // Called by MSXMixer
48
51 void uploadBuffer(MSXMixer& msxMixer, std::span<const StereoFloat> buffer);
52
53 [[nodiscard]] IntegerSetting& getMasterVolume() { return masterVolume; }
54
55private:
56 void reloadDriver();
57 void muteHelper();
58
59 // Observer<Setting>
60 void update(const Setting& setting) noexcept override;
61
62private:
63 std::vector<MSXMixer*> msxMixers; // unordered
64
65 std::unique_ptr<SoundDriver> driver;
66 Reactor& reactor;
67 CommandController& commandController;
68
69 EnumSetting<SoundDriverType> soundDriverSetting;
70 BooleanSetting muteSetting;
71 IntegerSetting masterVolume;
72 IntegerSetting frequencySetting;
73 IntegerSetting samplesSetting;
74
75 int muteCount = 0;
76};
77
78} // namespace openmsx
79
80#endif
BaseSetting * setting
Definition: Interpreter.cc:28
A Setting with an integer value.
IntegerSetting & getMasterVolume()
Definition: Mixer.hh:53
void registerMixer(MSXMixer &mixer)
Register per-machine mixer.
Definition: Mixer.cc:102
void mute()
This methods (un)mute the sound.
Definition: Mixer.cc:116
void unmute()
Definition: Mixer.cc:123
Mixer(Reactor &reactor, CommandController &commandController)
Definition: Mixer.cc:31
void unregisterMixer(MSXMixer &mixer)
Unregister per-machine mixer.
Definition: Mixer.cc:109
void uploadBuffer(MSXMixer &msxMixer, std::span< const StereoFloat > buffer)
Upload new sample data.
Definition: Mixer.cc:147
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