Use lanzcos instead (better SNR).

This commit is contained in:
Themaister 2012-02-25 16:45:06 +01:00
parent dd57e0ae63
commit 3dc5b21b78

View File

@ -85,17 +85,9 @@ static inline double sinc(double val)
return sin(val) / val;
}
static inline double blackman(double index)
static inline double lanzcos(double index)
{
index *= 0.5;
index += 0.5;
double alpha = 0.16;
double a0 = (1.0 - alpha) / 2.0;
double a1 = 0.5;
double a2 = alpha / 2.0;
return a0 - a1 * cos(2.0 * M_PI * index) + a2 * cos(4.0 * M_PI * index);
return sinc(index);
}
static void init_sinc_table(ssnes_resampler_t *resamp)
@ -107,7 +99,8 @@ static void init_sinc_table(ssnes_resampler_t *resamp)
{
double p = (double)i / PHASES;
double sinc_phase = M_PI * (p + (SIDELOBES - 1 - j));
resamp->phase_table[i][PHASE_INDEX][j] = sinc(sinc_phase) * blackman(sinc_phase / SIDELOBES);
resamp->phase_table[i][PHASE_INDEX][j] = sinc(sinc_phase) *
lanzcos(sinc_phase / SIDELOBES);
}
}
@ -126,7 +119,7 @@ static void init_sinc_table(ssnes_resampler_t *resamp)
{
double p = 1.0;
double sinc_phase = M_PI * (p + (SIDELOBES - 1 - j));
double phase = sinc(sinc_phase) * blackman(sinc_phase / SIDELOBES);
double phase = sinc(sinc_phase) * lanzcos(sinc_phase / SIDELOBES);
float result = (phase - resamp->phase_table[PHASES - 1][PHASE_INDEX][j]) / SUBPHASES;
resamp->phase_table[PHASES - 1][DELTA_INDEX][j] = result;