ref: a15a906131e89bc8b7fb43dc0c54f704f743d7df
parent: 3e3c7e15806ba01fc6a680def36ee0df4a3bc6da
author: Chris Moeller <[email protected]>
date: Sun Mar 23 16:58:27 EDT 2014
Changed sinc window to Nuttal 3 term, and added pre-fill of silence to account for half the window size minus one
--- a/dumb/src/helpers/resampler.c
+++ b/dumb/src/helpers/resampler.c
@@ -76,9 +76,12 @@
for (i = 0; i < SINC_SAMPLES + 1; ++i, x += dx)
{
float y = x / SINC_WIDTH;
-#if 1
+#if 0
// Blackman
float window = 0.42659 - 0.49656 * cos(M_PI + M_PI * y) + 0.076849 * cos(2.0 * M_PI * y);
+#elif 1
+ // Nuttal 3 term
+ float window = 0.40897 + 0.5 * cos(M_PI * y) + 0.09103 * cos(2.0 * M_PI * y);
#elif 0
// C.R.Helmrich's 2 term window
float window = 0.79445 * cos(0.5 * M_PI * y) + 0.20555 * cos(1.5 * M_PI * y);
@@ -118,8 +121,8 @@
resampler * r = ( resampler * ) malloc( sizeof(resampler) );
if ( !r ) return 0;
- r->write_pos = 0;
- r->write_filled = 0;
+ r->write_pos = SINC_WIDTH - 1;
+ r->write_filled = SINC_WIDTH - 1;
r->read_pos = 0;
r->read_filled = 0;
r->phase = 0;
@@ -215,11 +218,13 @@
void resampler_clear(void *_r)
{
resampler * r = ( resampler * ) _r;
- r->write_pos = 0;
- r->write_filled = 0;
+ r->write_pos = SINC_WIDTH - 1;
+ r->write_filled = SINC_WIDTH - 1;
r->read_pos = 0;
r->read_filled = 0;
r->phase = 0;
+ memset(r->buffer_in, 0, (SINC_WIDTH - 1) * sizeof(r->buffer_in[0]));
+ memset(r->buffer_in + resampler_buffer_size, 0, (SINC_WIDTH - 1) * sizeof(r->buffer_in[0]));
}
void resampler_set_rate(void *_r, double new_factor)