Rewrote audio resampler using cubic filter interpolation

This allows using a much smaller (1.5 KB) lookup table, in exchange for a small amount of extra work per frame.

The extra work (a few extra loads/mul/adds) is negligible, and can execute in parallel.
The reduction in cache misses almost certainly outweighs any added cost.

The table is generated at runtime, and takes less than 0.02ms on my computer.
This commit is contained in:
Brick
2024-04-04 19:25:25 +01:00
committed by Sam Lantinga
parent 46cecc42a2
commit 8f6f9cadc4
5 changed files with 494 additions and 830 deletions

View File

@@ -844,7 +844,7 @@ static int audio_resampleLoss(void *arg)
double signal_to_noise;
double max_error;
} test_specs[] = {
{ 50, 440, 0, 44100, 48000, 80, 0.0009 },
{ 50, 440, 0, 44100, 48000, 80, 0.0010 },
{ 50, 5000, SDL_PI_D / 2, 20000, 10000, 999, 0.0001 },
{ 50, 440, 0, 22050, 96000, 79, 0.0120 },
{ 50, 440, 0, 96000, 22050, 80, 0.0002 },
@@ -888,7 +888,7 @@ static int audio_resampleLoss(void *arg)
tmpspec2.channels = num_channels;
tmpspec2.freq = spec->rate_out;
stream = SDL_CreateAudioStream(&tmpspec1, &tmpspec2);
SDLTest_AssertPass("Call to SDL_CreateAudioStream(SDL_AUDIO_F32, 1, %i, SDL_AUDIO_F32, 1, %i)", spec->rate_in, spec->rate_out);
SDLTest_AssertPass("Call to SDL_CreateAudioStream(SDL_AUDIO_F32, %i, %i, SDL_AUDIO_F32, %i, %i)", num_channels, spec->rate_in, num_channels, spec->rate_out);
SDLTest_AssertCheck(stream != NULL, "Expected SDL_CreateAudioStream to succeed.");
if (stream == NULL) {
return TEST_ABORTED;