mirror of
https://github.com/ggerganov/ggwave.git
synced 2026-03-25 21:41:13 +08:00
Add arduino-rx + update ggwave-mod
This commit is contained in:
49
examples/ggwave-mod/src/resampler.h
Normal file
49
examples/ggwave-mod/src/resampler.h
Normal file
@@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
|
||||
class Resampler {
|
||||
public:
|
||||
// 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;
|
||||
|
||||
Resampler();
|
||||
|
||||
void reset();
|
||||
|
||||
int nSamplesTotal() const { return m_state.nSamplesTotal; }
|
||||
|
||||
int resample(
|
||||
float factor,
|
||||
int nSamples,
|
||||
const float * samplesInp,
|
||||
float * samplesOut);
|
||||
|
||||
private:
|
||||
float gimme_data(int j) const;
|
||||
void new_data(float data);
|
||||
void make_sinc();
|
||||
double sinc(double x) const;
|
||||
|
||||
static const int kDelaySize = 140;
|
||||
|
||||
// this defines how finely the sinc function is sampled for storage in the table
|
||||
static const int kSamplesPerZeroCrossing = 32;
|
||||
|
||||
std::vector<float> m_sincTable;
|
||||
std::vector<float> m_delayBuffer;
|
||||
std::vector<float> m_edgeSamples;
|
||||
std::vector<float> m_samplesInp;
|
||||
|
||||
struct State {
|
||||
int nSamplesTotal = 0;
|
||||
int timeInt = 0;
|
||||
int timeLast = 0;
|
||||
double timeNow = 0.0;
|
||||
};
|
||||
|
||||
State m_state;
|
||||
};
|
||||
Reference in New Issue
Block a user