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
openmsx::EnumSetting< ResampleType >
openmsx::ResampledSoundDevice::RESAMPLE_HQ
Definition: ResampledSoundDevice.hh:18
openmsx::ResampledSoundDevice::ResampleType
ResampleType
Definition: ResampledSoundDevice.hh:18
openmsx::ResampledSoundDevice
Definition: ResampledSoundDevice.hh:15
openmsx::ResampledSoundDevice::setOutputRate
void setOutputRate(unsigned sampleRate) override
When a SoundDevice registers itself with the Mixer, the Mixer sets the required sampleRate through th...
Definition: ResampledSoundDevice.cc:33
openmsx::ResampledSoundDevice::RESAMPLE_LQ
Definition: ResampledSoundDevice.hh:18
openmsx::ResampledSoundDevice::~ResampledSoundDevice
~ResampledSoundDevice()
Definition: ResampledSoundDevice.cc:27
openmsx::ResampledSoundDevice::generateInput
bool generateInput(float *buffer, unsigned num)
Note: To enable various optimizations (like SSE), this method is allowed to generate up to 3 extra sa...
Definition: ResampledSoundDevice.cc:44
gl::length
T length(const vecN< N, T > &x)
Definition: gl_vec.hh:348
openmsx::ResampledSoundDevice::updateBuffer
bool updateBuffer(unsigned length, float *buffer, EmuTime::param time) override
Generate sample data.
Definition: ResampledSoundDevice.cc:38
openmsx::Setting
Definition: Setting.hh:119
openmsx::ResampledSoundDevice::ResampledSoundDevice
ResampledSoundDevice(MSXMotherBoard &motherBoard, std::string_view name, std::string_view description, unsigned channels, unsigned inputSampleRate, bool stereo)
Definition: ResampledSoundDevice.cc:16
Observer.hh
openmsx::SoundDevice
Definition: SoundDevice.hh:16
openmsx::MSXMotherBoard
Definition: MSXMotherBoard.hh:59
SoundDevice.hh
openmsx::ResampledSoundDevice::RESAMPLE_BLIP
Definition: ResampledSoundDevice.hh:18
openmsx::ResampledSoundDevice::update
void update(const Setting &setting) override
Definition: ResampledSoundDevice.cc:50
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
openmsx::Observer
Generic Gang-of-Four Observer class, templatized edition.
Definition: Observer.hh:9
openmsx::ResampledSoundDevice::createResampler
void createResampler()
Definition: ResampledSoundDevice.cc:57