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(int* buffer, unsigned num);
25 
26 protected:
28  string_view description, unsigned channels,
29  bool stereo = false);
31 
32  // SoundDevice
33  void setOutputRate(unsigned sampleRate) override;
34  bool updateBuffer(unsigned length, int* 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
T length(const vecN< N, T > &x)
Definition: gl_vec.hh:343
bool updateBuffer(unsigned length, int *buffer, EmuTime::param time) override
Generate sample data.
ResampledSoundDevice(MSXMotherBoard &motherBoard, string_view name, string_view description, unsigned channels, bool stereo=false)
bool generateInput(int *buffer, unsigned num)
Note: To enable various optimizations (like SSE), this method is allowed to generate up to 3 extra sa...
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...
This class implements a (close approximation) of the std::string_view class.
Definition: string_view.hh:16
void update(const Setting &setting) override
Generic Gang-of-Four Observer class, templatized edition.
Definition: Observer.hh:9