openMSX
ResampledSoundDevice.hh
Go to the documentation of this file.
1#ifndef RESAMPLEDSOUNDDEVICE_HH
2#define RESAMPLEDSOUNDDEVICE_HH
3
4#include "SoundDevice.hh"
5#include "DynamicClock.hh"
6#include "EnumSetting.hh"
7#include "Observer.hh"
8#include <memory>
9
10namespace openmsx {
11
12class MSXMotherBoard;
13class ResampleAlgo;
14class Setting;
15
16class ResampledSoundDevice : public SoundDevice, protected Observer<Setting>
17{
18public:
20
25 bool generateInput(float* buffer, size_t num);
26
27 [[nodiscard]] DynamicClock& getEmuClock() { return emuClock; }
28
29protected:
30 ResampledSoundDevice(MSXMotherBoard& motherBoard, std::string_view name,
31 static_string_view description, unsigned channels,
32 unsigned inputSampleRate, bool stereo);
34
35 // SoundDevice
36 void setOutputRate(unsigned hostSampleRate, double speed) override;
37 bool updateBuffer(size_t length, float* buffer,
38 EmuTime::param time) override;
39
40 // Observer<Setting>
41 void update(const Setting& setting) noexcept override;
42
43 void createResampler();
44
45private:
46 EnumSetting<ResampleType>& resampleSetting;
47 std::unique_ptr<ResampleAlgo> algo;
48 DynamicClock emuClock; // time of the last produced emu-sample,
49 // ticks once per emu-sample
50};
51
52} // namespace openmsx
53
54#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