19 unsigned inputSampleRate_,
bool stereo_)
20 :
SoundDevice(motherBoard.getMSXMixer(), name_, description_,
21 channels, inputSampleRate_, stereo_)
22 , resampleSetting(motherBoard.getReactor().getGlobalSettings().getResampleSetting())
23 , emuClock(EmuTime::zero())
25 resampleSetting.
attach(*
this);
30 resampleSetting.
detach(*
this);
42 return algo->generateOutput(buffer,
length, time);
54 assert(&
setting == &resampleSetting);
66 if (outputPeriod == inputPeriod) {
67 algo = std::make_unique<ResampleTrivial>(*
this);
69 switch (resampleSetting.
getEnum()) {
72 algo = std::make_unique<ResampleHQ<1>>(*
this, hostClock);
74 algo = std::make_unique<ResampleHQ<2>>(*
this, hostClock);
86 algo = std::make_unique<ResampleBlip<1>>(*
this, hostClock);
88 algo = std::make_unique<ResampleBlip<2>>(*
this, hostClock);
Represents a clock with a variable frequency.
EmuDuration getPeriod() const
Returns the length of one clock-cycle.
void setPeriod(EmuDuration period)
Set the duration of a clock tick.
void reset(EmuTime::param e)
Reset the clock to start ticking at the given time.
EmuTime::param getTime() const
Gets the time at which the last clock tick occurred.
T getEnum() const noexcept
static std::unique_ptr< ResampleLQ< CHANNELS > > create(ResampledSoundDevice &input, const DynamicClock &hostClock)
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...
ResampledSoundDevice(MSXMotherBoard &motherBoard, std::string_view name, static_string_view description, unsigned channels, unsigned inputSampleRate, bool stereo)
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.
double getEffectiveSpeed() const
unsigned getInputRate() const
const DynamicClock & getHostSampleClock() const
See MSXMixer::getHostSampleClock().
bool mixChannels(float *dataOut, size_t samples)
Calls generateChannels() and combines the output to a single channel.
bool isStereo() const
Is this a stereo device? This is set in the constructor and cannot be changed anymore.
void detach(Observer< T > &observer)
void attach(Observer< T > &observer)
T length(const vecN< N, T > &x)
This file implemented 3 utility functions: