openMSX
Mixer.hh
Go to the documentation of this file.
1#ifndef MIXER_HH
2#define MIXER_HH
3
4#include "BooleanSetting.hh"
5#include "EnumSetting.hh"
6#include "IntegerSetting.hh"
7
8#include "Observer.hh"
9
10#include <vector>
11#include <memory>
12
13namespace openmsx {
14
15class SoundDriver;
16class Reactor;
17class CommandController;
18class MSXMixer;
19
21 // Note: important to keep this uninitialized, we have large arrays of
22 // these objects and needlessly initializing those is expensive
23 float left;
24 float right;
25};
26
27class Mixer final : private Observer<Setting>
28{
29public:
30 enum class SoundDriverType { NONE, SDL };
31
32 Mixer(Reactor& reactor, CommandController& commandController);
33 ~Mixer();
34
37 void registerMixer(MSXMixer& mixer);
38
41 void unregisterMixer(MSXMixer& mixer);
42
48 void mute();
49 void unmute();
50
51 // Called by MSXMixer
52
55 void uploadBuffer(MSXMixer& msxMixer, std::span<const StereoFloat> buffer);
56
57 [[nodiscard]] IntegerSetting& getMasterVolume() { return masterVolume; }
58 [[nodiscard]] BooleanSetting& getMuteSetting() { return muteSetting; }
59
60private:
61 void reloadDriver();
62 void muteHelper();
63
64 // Observer<Setting>
65 void update(const Setting& setting) noexcept override;
66
67private:
68 std::vector<MSXMixer*> msxMixers; // unordered
69
70 std::unique_ptr<SoundDriver> driver;
71 Reactor& reactor;
72 CommandController& commandController;
73
74 EnumSetting<SoundDriverType> soundDriverSetting;
75 BooleanSetting muteSetting;
76 IntegerSetting masterVolume;
77 IntegerSetting frequencySetting;
78 IntegerSetting samplesSetting;
79
80 int muteCount = 0;
81};
82
83} // namespace openmsx
84
85#endif
BaseSetting * setting
A Setting with an integer value.
BooleanSetting & getMuteSetting()
Definition Mixer.hh:58
IntegerSetting & getMasterVolume()
Definition Mixer.hh:57
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:148
Generic Gang-of-Four Observer class, templatized edition.
Definition Observer.hh:10
Contains the main loop of openMSX.
Definition Reactor.hh:75
This file implemented 3 utility functions:
Definition Autofire.cc:11