diff --git a/audio/hermite.c b/audio/hermite.c index 8b46651b98..e0fb48941c 100644 --- a/audio/hermite.c +++ b/audio/hermite.c @@ -30,12 +30,12 @@ struct ssnes_resampler double r_frac; }; -void resampler_preinit(ssnes_resampler_t *re, double omega, unsigned *samples_offset) +void resampler_preinit(ssnes_resampler_t *re, double omega, double *samples_offset) { - *samples_offset = 4; - for (unsigned i = 0; i < 4; i++) + *samples_offset = 2.0; + for (int i = 0; i < 4; i++) { - re->chan_data[0][i] = cos(i * omega); + re->chan_data[0][i] = cos((i - 2) * omega); re->chan_data[1][i] = re->chan_data[0][i]; } diff --git a/audio/resampler.h b/audio/resampler.h index 8808d08785..8fc6452c23 100644 --- a/audio/resampler.h +++ b/audio/resampler.h @@ -45,7 +45,7 @@ void resampler_process(ssnes_resampler_t *re, struct resampler_data *data); void resampler_free(ssnes_resampler_t *re); // Generate a starting cosine pulse with given frequency for testing (SNR, etc) purposes. -void resampler_preinit(ssnes_resampler_t *re, double omega, unsigned *samples_offset); +void resampler_preinit(ssnes_resampler_t *re, double omega, double *samples_offset); #endif diff --git a/audio/sinc.c b/audio/sinc.c index 9b490a6fd2..8af6397ff9 100644 --- a/audio/sinc.c +++ b/audio/sinc.c @@ -65,7 +65,7 @@ struct ssnes_resampler uint32_t time; }; -void resampler_preinit(ssnes_resampler_t *re, double omega, unsigned *samples_offset) +void resampler_preinit(ssnes_resampler_t *re, double omega, double *samples_offset) { *samples_offset = SIDELOBES + 1; for (int i = 0; i < 2 * SIDELOBES; i++) diff --git a/audio/test/snr.c b/audio/test/snr.c index a947d24381..81fe421c8e 100644 --- a/audio/test/snr.c +++ b/audio/test/snr.c @@ -22,7 +22,7 @@ #include #include -static void gen_signal(float *out, double freq, double sample_rate, unsigned bias_samples, size_t samples) +static void gen_signal(float *out, double freq, double sample_rate, double bias_samples, size_t samples) { double omega = 2.0 * M_PI * freq / sample_rate; @@ -149,7 +149,7 @@ int main(int argc, char *argv[]) for (unsigned i = 0; i < sizeof(freq_list) / sizeof(freq_list[0]) && freq_list[i] < 0.5f * in_rate; i++) { double omega = 2.0 * M_PI * freq_list[i] / in_rate; - unsigned sample_offset; + double sample_offset; resampler_preinit(re, omega, &sample_offset); gen_signal(input, freq_list[i], in_rate, sample_offset, samples); @@ -171,6 +171,11 @@ int main(int argc, char *argv[]) printf("SNR @ %7.1f Hz: %6.2lf dB, Gain: %6.1f dB\n", freq_list[i], res.snr, res.gain); + + //printf("Generated:\n\t"); + //for (unsigned i = 0; i < 10; i++) + // printf("%.4f, ", output[i]); + //printf("\n"); } resampler_free(re);