mirror of
https://github.com/ggerganov/ggwave.git
synced 2026-02-06 16:47:59 +08:00
resampler : minor fixes
This commit is contained in:
@@ -9,16 +9,15 @@ double linear_interp(double first_number, double second_number, double fraction)
|
||||
}
|
||||
}
|
||||
|
||||
Resampler::Resampler() {
|
||||
make_sinc();
|
||||
}
|
||||
|
||||
int Resampler::resample(
|
||||
float factor,
|
||||
int nSamples,
|
||||
const float * samplesInp,
|
||||
float * samplesOut) {
|
||||
if (factor != m_lastFactor) {
|
||||
make_sinc();
|
||||
m_lastFactor = factor;
|
||||
}
|
||||
|
||||
int idxInp = 0;
|
||||
int idxOut = 0;
|
||||
int notDone = 1;
|
||||
@@ -31,8 +30,8 @@ int Resampler::resample(
|
||||
double one_over_factor = 1.0;
|
||||
while (notDone) {
|
||||
double temp1 = 0.0;
|
||||
long left_limit = time_now - kWidth + 1; /* leftmost neighboring sample used for interp.*/
|
||||
long right_limit = time_now + kWidth; /* rightmost leftmost neighboring sample used for interp.*/
|
||||
long left_limit = time_now - kWidth + 1; /* leftmost neighboring sample used for interp.*/
|
||||
long right_limit = time_now + kWidth; /* rightmost leftmost neighboring sample used for interp.*/
|
||||
if (left_limit<0) left_limit = 0;
|
||||
if (right_limit>num_samples) right_limit = num_samples;
|
||||
if (factor<1.0) {
|
||||
@@ -57,7 +56,7 @@ int Resampler::resample(
|
||||
time_now += factor;
|
||||
last_time = int_time;
|
||||
int_time = time_now;
|
||||
while(last_time<int_time) {
|
||||
while (last_time<int_time) {
|
||||
if (++idxInp == nSamples) {
|
||||
notDone = 0;
|
||||
} else {
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
class Resampler {
|
||||
public:
|
||||
Resampler();
|
||||
|
||||
int resample(
|
||||
float factor,
|
||||
int nSamples,
|
||||
@@ -28,6 +30,4 @@ private:
|
||||
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