Files
ggwave/src/resampler.h
Georgi Gerganov 19bf22df0d ggwave v0.2.0 (#20)
* ggwave : add support for fixed length transmissions

* spectrogram : add sample rate offset for debugging purposes

* gwave : fix decoding bug

* waver : wip

* wip

* remove post-marker frames

* add resampler

* ggwave : input/output resampling

* ggwave : fix python build

* ggwave : update spm

* ggwave : refactor duplicate encode/decode code

* ggwave : fix sound marker detection

* waver : fix typo

* ggwave : fix uninitialized members

* ggwave : more sensitive receive
2021-02-20 19:16:15 +02:00

33 lines
855 B
C++

#pragma once
class Resampler {
public:
int resample(
float factor,
int nSamples,
const float * samplesInp,
float * samplesOut);
private:
float gimme_data(long j) const;
void new_data(float data);
void make_sinc();
double sinc(double x) const;
/* this controls the number of neighboring samples
which are used to interpolate the new samples. The
processing time is linearly related to this width */
static const int kWidth = 64;
static const int kDelaySize = 140;
/* this defines how finely the sinc function
is sampled for storage in the table */
static const int kSamplesPerZeroCrossing = 32;
float m_sincTable[kWidth*kSamplesPerZeroCrossing] = { 0.0 };
float m_delayBuffer[3*kWidth] = { 0 };
float m_lastFactor = -1.0f;
};