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
32 // setBalance() might switch between mono/stereo
37
38protected:
39 ResampledSoundDevice(MSXMotherBoard& motherBoard, std::string_view name,
40 static_string_view description, unsigned channels,
41 unsigned inputSampleRate, bool stereo);
43
44 // SoundDevice
45 void setOutputRate(unsigned hostSampleRate, double speed) override;
46 bool updateBuffer(size_t length, float* buffer,
47 EmuTime::param time) override;
48
49 // Observer<Setting>
50 void update(const Setting& setting) noexcept override;
51
52 void createResampler();
53
54private:
55 EnumSetting<ResampleType>& resampleSetting;
56 std::unique_ptr<ResampleAlgo> algo;
57 DynamicClock emuClock{EmuTime::zero()}; // time of the last produced emu-sample,
58 // ticks once per emu-sample
59};
60
61} // namespace openmsx
62
63#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.
virtual void postSetBalance()
static_string_view
This file implemented 3 utility functions:
Definition Autofire.cc:11