openMSX
ResampledSoundDevice.hh
Go to the documentation of this file.
1#ifndef RESAMPLEDSOUNDDEVICE_HH
2#define RESAMPLEDSOUNDDEVICE_HH
3
4#include "SoundDevice.hh"
5
6#include "DynamicClock.hh"
7#include "EnumSetting.hh"
8
9#include "Observer.hh"
10
11#include <memory>
12
13namespace openmsx {
14
15class MSXMotherBoard;
16class ResampleAlgo;
17class Setting;
18
19class ResampledSoundDevice : public SoundDevice, protected Observer<Setting>
20{
21public:
22 enum class ResampleType { HQ, BLIP };
23
28 bool generateInput(float* buffer, size_t num);
29
30 [[nodiscard]] DynamicClock& getEmuClock() { return emuClock; }
31
32protected:
33 ResampledSoundDevice(MSXMotherBoard& motherBoard, std::string_view name,
34 static_string_view description, unsigned channels,
35 unsigned inputSampleRate, bool stereo);
37
38 // SoundDevice
39 void setOutputRate(unsigned hostSampleRate, double speed) override;
40 bool updateBuffer(size_t length, float* buffer,
41 EmuTime::param time) override;
42
43 // Observer<Setting>
44 void update(const Setting& setting) noexcept override;
45
46 void createResampler();
47
48private:
49 EnumSetting<ResampleType>& resampleSetting;
50 std::unique_ptr<ResampleAlgo> algo;
51 DynamicClock emuClock{EmuTime::zero()}; // time of the last produced emu-sample,
52 // ticks once per emu-sample
53};
54
55} // namespace openmsx
56
57#endif
BaseSetting * setting
Represents a clock with a variable frequency.
Generic Gang-of-Four Observer class, templatized edition.
Definition Observer.hh:10
bool generateInput(float *buffer, size_t num)
Note: To enable various optimizations (like SSE), this method is allowed to generate up to 3 extra sa...
void update(const Setting &setting) noexcept override
void setOutputRate(unsigned hostSampleRate, double speed) override
When a SoundDevice registers itself with the Mixer, the Mixer sets the required sampleRate through th...
bool updateBuffer(size_t length, float *buffer, EmuTime::param time) override
Generate sample data.
static_string_view
This file implemented 3 utility functions:
Definition Autofire.cc:11