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