libresidfp  1.2.3
SincResampler.h
1 /*
2  * This file is part of libsidplayfp, a SID player engine.
3  *
4  * Copyright 2011-2024 Leandro Nini <drfiemost@users.sourceforge.net>
5  * Copyright 2007-2010 Antti Lankila
6  * Copyright 2004 Dag Lem <resid@nimrod.no>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  */
22 
23 #ifndef SINCRESAMPLER_H
24 #define SINCRESAMPLER_H
25 
26 #include "Resampler.h"
27 
28 #include "../array.h"
29 
30 namespace reSIDfp
31 {
32 
48 class SincResampler final : public Resampler
49 {
50  friend class State;
51 
52 private:
54  static constexpr int RINGSIZE = 2048;
55 
56 #ifdef RUNTIME_DISPATCH
57 private:
58  using convolve_func_t = auto (*)(const int32_t*, const int16_t*, int) -> int32_t;
59 
60  convolve_func_t simd_convolve;
61 #endif
62 
63 private:
65  matrix_t* firTable;
66 
67  int sampleIndex = 0;
68 
70  int firRES;
71 
73  int firN;
74 
75  const int cyclesPerSample;
76 
77  int sampleOffset = 0;
78 
79  int32_t outputValue = 0;
80 
81  int32_t sample[RINGSIZE * 2] = {0};
82 
83 private:
84  int32_t fir(int subcycle);
85 
86 private:
87  SincResampler(const SincResampler&) = delete;
88  SincResampler& operator=(const SincResampler&) = delete;
89 
90 public:
108  double clockFrequency,
109  double samplingFrequency,
110  double highestAccurateFrequency);
111  ~SincResampler() override;
112 
113  bool input(int32_t input) override;
114 
115  int32_t output() const override { return outputValue; }
116 
117  void reset() override;
118 };
119 
120 } // namespace reSIDfp
121 
122 #endif
Definition: SincResampler.h:48
Definition: array.h:30
Definition: Dac.cpp:27
bool input(int32_t input) override
Definition: SincResampler.cpp:305
Definition: Resampler.h:36
Definition: State.h:45