openMSX
ResampleLQ.hh
Go to the documentation of this file.
1 #ifndef RESAMPLELQ_HH
2 #define RESAMPLELQ_HH
3 
4 #include "ResampleAlgo.hh"
5 #include "DynamicClock.hh"
6 #include "FixedPoint.hh"
7 #include <memory>
8 
9 namespace openmsx {
10 
11 class ResampledSoundDevice;
12 
13 template <unsigned CHANNELS>
14 class ResampleLQ : public ResampleAlgo
15 {
16 public:
17  static std::unique_ptr<ResampleLQ<CHANNELS>> create(
19  const DynamicClock& hostClock, unsigned emuSampleRate);
20 
21 protected:
23  const DynamicClock& hostClock, unsigned emuSampleRate);
24  bool fetchData(EmuTime::param time, unsigned& valid);
25 
27  using FP = FixedPoint<14>;
28  const FP step;
29  float lastInput[2 * CHANNELS];
30 };
31 
32 template <unsigned CHANNELS>
33 class ResampleLQDown final : public ResampleLQ<CHANNELS>
34 {
35 public:
37  const DynamicClock& hostClock, unsigned emuSampleRate);
38 private:
39  bool generateOutputImpl(float* dataOut, unsigned num,
40  EmuTime::param time) override;
41  using FP = typename ResampleLQ<CHANNELS>::FP;
42 };
43 
44 template <unsigned CHANNELS>
45 class ResampleLQUp final : public ResampleLQ<CHANNELS>
46 {
47 public:
49  const DynamicClock& hostClock, unsigned emuSampleRate);
50 private:
51  bool generateOutputImpl(float* dataOut, unsigned num,
52  EmuTime::param time) override;
53  using FP = typename ResampleLQ<CHANNELS>::FP;
54 };
55 
56 } // namespace openmsx
57 
58 #endif
CHANNELS
constexpr unsigned CHANNELS
Definition: YM2413Test.cc:20
openmsx::ResampleAlgo::input
ResampledSoundDevice & input
Definition: ResampleAlgo.hh:32
openmsx::ResampledSoundDevice
Definition: ResampledSoundDevice.hh:16
openmsx::ResampleLQ::lastInput
float lastInput[2 *CHANNELS]
Definition: ResampleLQ.hh:29
openmsx::ResampleLQDown::ResampleLQDown
ResampleLQDown(ResampledSoundDevice &input, const DynamicClock &hostClock, unsigned emuSampleRate)
Definition: ResampleLQ.cc:137
openmsx::ResampleLQUp
Definition: ResampleLQ.hh:45
openmsx::ResampleLQ::fetchData
bool fetchData(EmuTime::param time, unsigned &valid)
Definition: ResampleLQ.cc:54
openmsx::DynamicClock
Represents a clock with a variable frequency.
Definition: DynamicClock.hh:16
openmsx::ResampleLQ::step
const FP step
Definition: ResampleLQ.hh:28
ResampleAlgo.hh
openmsx::ResampleLQ::create
static std::unique_ptr< ResampleLQ< CHANNELS > > create(ResampledSoundDevice &input, const DynamicClock &hostClock, unsigned emuSampleRate)
Definition: ResampleLQ.cc:20
openmsx::ResampleLQ::ResampleLQ
ResampleLQ(ResampledSoundDevice &input, const DynamicClock &hostClock, unsigned emuSampleRate)
Definition: ResampleLQ.cc:37
FixedPoint.hh
openmsx::ResampleLQ
Definition: ResampleLQ.hh:14
openmsx::ResampleLQDown
Definition: ResampleLQ.hh:33
openmsx::ResampleLQ::hostClock
const DynamicClock & hostClock
Definition: ResampleLQ.hh:26
openmsx::ResampleLQUp::ResampleLQUp
ResampleLQUp(ResampledSoundDevice &input, const DynamicClock &hostClock, unsigned emuSampleRate)
Definition: ResampleLQ.cc:96
DynamicClock.hh
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
openmsx::ResampleAlgo
Definition: ResampleAlgo.hh:11
openmsx::FixedPoint
A fixed point number, implemented by a 32-bit signed integer.
Definition: FixedPoint.hh:15