19 void begin(
float in_rate,
float out_rate,
float cutoff = 0.45f) {
23 float low_rate = in_rate < out_rate ? in_rate : out_rate;
30 for (
int j = 0; j <=
TABLE; j++) {
33 float x = 2.0f *
cutoff * u;
34 float sinc = j == 0 ? 1.0f : sinf((
float)M_PI * x) / ((float)M_PI * x);
35 float window = 0.5f + 0.5f * cosf((
float)M_PI * u /
HALF_WIDTH);
68 for (
int n = first; n <= last; n++) {
92 float sum_re = 0, sum_im = 0;
93 for (
int n = first; n <= last; n++) {
121 if (idx >=
TABLE)
return 0;
122 float frac = pos - idx;
138 for (
int j = 0; j <
len / 2; j++) {
148 for (
int i = 1, j = 0; i <
len; i++) {
150 for (; j & bit; bit >>= 1) j ^= bit;
164 for (
int start = 0; start <
len; start +=
size) {
165 for (
int k = 0; k < half; k++) {
167 int a = start + k, b = a + half;
168 float tr = re[b] * c - im[b] * s;
169 float ti = re[b] * s + im[b] * c;
Converts the sample rate of a signal with a windowed sinc low pass filter (by default the cut off is ...
Definition DSPUtils.h:15
double base_ratio
Definition DSPUtils.h:109
float kernel_scale
Definition DSPUtils.h:113
float cutoff
Definition DSPUtils.h:110
double next
Definition DSPUtils.h:115
float table[TABLE+2]
Definition DSPUtils.h:107
void begin(float in_rate, float out_rate, float cutoff=0.45f)
Definition DSPUtils.h:19
void reset()
Definition DSPUtils.h:41
audio_tools::Vector< float > history
Definition DSPUtils.h:108
void setRateFactor(double factor)
Definition DSPUtils.h:49
int64_t count
Definition DSPUtils.h:114
double ratio
Definition DSPUtils.h:109
static constexpr int TABLE
Definition DSPUtils.h:106
float half_width
Definition DSPUtils.h:112
audio_tools::Vector< float > history_q
Definition DSPUtils.h:108
float kernel(float u)
kernel at the distance u (in samples of the lower rate)
Definition DSPUtils.h:118
void write(float x, F out)
Adds an input sample and calls out(float) for each output sample.
Definition DSPUtils.h:55
void writeComplex(float re, float im, F out)
Definition DSPUtils.h:80
bool bypass
Definition DSPUtils.h:111
static constexpr int HALF_WIDTH
Definition DSPUtils.h:105
Radix 2 complex FFT with a precomputed twiddle table.
Definition DSPUtils.h:131
void process(float *re, float *im)
In place forward transform.
Definition DSPUtils.h:146
int size() const
Definition DSPUtils.h:179
bool begin(int size)
Definition DSPUtils.h:133
audio_tools::Vector< float > sin_table
Definition DSPUtils.h:183
int len
Definition DSPUtils.h:182
audio_tools::Vector< float > cos_table
Definition DSPUtils.h:183
TinyModem: software audio modems and packets with error correction.
Definition AX25.h:11