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 "Observer.hh"
6 #include <memory>
7 
8 namespace openmsx {
9 
10 class MSXMotherBoard;
11 class ResampleAlgo;
12 class Setting;
13 template<typename T> class EnumSetting;
14 
15 class ResampledSoundDevice : public SoundDevice, protected Observer<Setting>
16 {
17 public:
19 
24  bool generateInput(float* buffer, unsigned num);
25 
26 protected:
27  ResampledSoundDevice(MSXMotherBoard& motherBoard, std::string_view name,
28  std::string_view description, unsigned channels,
29  unsigned inputSampleRate, bool stereo);
31 
32  // SoundDevice
33  void setOutputRate(unsigned sampleRate) override;
34  bool updateBuffer(unsigned length, float* buffer,
35  EmuTime::param time) override;
36 
37  // Observer<Setting>
38  void update(const Setting& setting) override;
39 
40  void createResampler();
41 
42 private:
43  EnumSetting<ResampleType>& resampleSetting;
44  std::unique_ptr<ResampleAlgo> algo;
45 };
46 
47 } // namespace openmsx
48 
49 #endif
bool updateBuffer(unsigned length, float *buffer, EmuTime::param time) override
Generate sample data.
T length(const vecN< N, T > &x)
Definition: gl_vec.hh:343
ResampledSoundDevice(MSXMotherBoard &motherBoard, std::string_view name, std::string_view description, unsigned channels, unsigned inputSampleRate, bool stereo)
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
void setOutputRate(unsigned sampleRate) override
When a SoundDevice registers itself with the Mixer, the Mixer sets the required sampleRate through th...
void update(const Setting &setting) override
Generic Gang-of-Four Observer class, templatized edition.
Definition: Observer.hh:9
bool generateInput(float *buffer, unsigned num)
Note: To enable various optimizations (like SSE), this method is allowed to generate up to 3 extra sa...