mirror of
https://github.com/ggerganov/ggwave.git
synced 2026-03-17 07:56:00 +08:00
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
This commit is contained in:
32
src/resampler.h
Normal file
32
src/resampler.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#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;
|
||||
};
|
||||
Reference in New Issue
Block a user