| 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 <cstdint> |
| 11 |
#include <memory> |
| 12 |
#include <vector> |
| 13 |
|
| 14 |
namespace openmsx { |
| 15 |
|
| 16 |
class SoundDriver; |
| 17 |
class Reactor; |
| 18 |
class CommandController; |
| 19 |
class MSXMixer; |
| 20 |
|
| 21 |
struct StereoFloat { |
| 22 |
|
| 23 |
|
| 24 |
float left; |
| 25 |
float right; |
| 26 |
}; |
| 27 |
|
| 28 |
class Mixer final : private Observer<Setting> |
| 29 |
{ |
| 30 |
public: |
| 31 |
enum class SoundDriverType : uint8_t { NONE, SDL }; |
| 32 |
|
| 33 |
Mixer(Reactor& reactor, CommandController& commandController); |
| 34 |
~Mixer(); |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
void registerMixer(MSXMixer& mixer); |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
void unregisterMixer(MSXMixer& mixer); |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
void mute(); |
| 50 |
void unmute(); |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
void uploadBuffer(MSXMixer& msxMixer, std::span<const StereoFloat> buffer); |
| 57 |
|
| 58 |
[[nodiscard]] IntegerSetting& getMasterVolume() { return masterVolume; } |
| 59 |
[[nodiscard]] BooleanSetting& getMuteSetting() { return muteSetting; } |
| 60 |
|
| 61 |
private: |
| 62 |
void reloadDriver(); |
| 63 |
void muteHelper(); |
| 64 |
|
| 65 |
|
| 66 |
void update(const Setting& setting) noexcept override; |
| 67 |
|
| 68 |
private: |
| 69 |
std::vector<MSXMixer*> msxMixers; |
| 70 |
|
| 71 |
std::unique_ptr<SoundDriver> driver; |
| 72 |
Reactor& reactor; |
| 73 |
CommandController& commandController; |
| 74 |
|
| 75 |
EnumSetting<SoundDriverType> soundDriverSetting; |
| 76 |
BooleanSetting muteSetting; |
| 77 |
IntegerSetting masterVolume; |
| 78 |
IntegerSetting frequencySetting; |
| 79 |
IntegerSetting samplesSetting; |
| 80 |
|
| 81 |
int muteCount = 0; |
| 82 |
}; |
| 83 |
|
| 84 |
} |
| 85 |
|
| 86 |
#endif |