diff --git a/miniaudio.h b/miniaudio.h index e9e9f1e2..69419dd3 100644 --- a/miniaudio.h +++ b/miniaudio.h @@ -59189,8 +59189,7 @@ static void ma_linear_resampler_interpolate_frame_s16(ma_linear_resampler* pResa } } - -static void ma_linear_resampler_interpolate_frame_f32(ma_linear_resampler* pResampler, float* MA_RESTRICT pFrameOut) +static void ma_linear_resampler_interpolate_frame_f32(ma_linear_resampler* pResampler, float invSampleRateOut, float* MA_RESTRICT pFrameOut) { ma_uint32 c; float a; @@ -59199,7 +59198,7 @@ static void ma_linear_resampler_interpolate_frame_f32(ma_linear_resampler* pResa MA_ASSERT(pResampler != NULL); MA_ASSERT(pFrameOut != NULL); - a = (float)pResampler->inTimeFrac / pResampler->config.sampleRateOut; + a = (float)pResampler->inTimeFrac * invSampleRateOut; MA_ASSUME(channels > 0); for (c = 0; c < channels; c += 1) { @@ -59380,6 +59379,7 @@ static ma_result ma_linear_resampler_process_pcm_frames_f32_downsample(ma_linear ma_uint64 frameCountOut; ma_uint64 framesProcessedIn; ma_uint64 framesProcessedOut; + float invSampleRateOut; MA_ASSERT(pResampler != NULL); MA_ASSERT(pFrameCountIn != NULL); @@ -59391,6 +59391,7 @@ static ma_result ma_linear_resampler_process_pcm_frames_f32_downsample(ma_linear frameCountOut = *pFrameCountOut; framesProcessedIn = 0; framesProcessedOut = 0; + invSampleRateOut = 1.0f / pResampler->sampleRateOut; while (framesProcessedOut < frameCountOut) { /* Before interpolating we need to load the buffers. When doing this we need to ensure we run every input sample through the filter. */ @@ -59426,7 +59427,7 @@ static ma_result ma_linear_resampler_process_pcm_frames_f32_downsample(ma_linear /* Getting here means the frames have been loaded and filtered and we can generate the next output frame. */ if (pFramesOutF32 != NULL) { MA_ASSERT(pResampler->inTimeInt == 0); - ma_linear_resampler_interpolate_frame_f32(pResampler, pFramesOutF32); + ma_linear_resampler_interpolate_frame_f32(pResampler, invSampleRateOut, pFramesOutF32); pFramesOutF32 += pResampler->channels; } @@ -59456,6 +59457,7 @@ static ma_result ma_linear_resampler_process_pcm_frames_f32_upsample(ma_linear_r ma_uint64 frameCountOut; ma_uint64 framesProcessedIn; ma_uint64 framesProcessedOut; + float invSampleRateOut; MA_ASSERT(pResampler != NULL); MA_ASSERT(pFrameCountIn != NULL); @@ -59467,6 +59469,7 @@ static ma_result ma_linear_resampler_process_pcm_frames_f32_upsample(ma_linear_r frameCountOut = *pFrameCountOut; framesProcessedIn = 0; framesProcessedOut = 0; + invSampleRateOut = 1.0f / pResampler->sampleRateOut; while (framesProcessedOut < frameCountOut) { /* Before interpolating we need to load the buffers. */ @@ -59497,7 +59500,7 @@ static ma_result ma_linear_resampler_process_pcm_frames_f32_upsample(ma_linear_r /* Getting here means the frames have been loaded and we can generate the next output frame. */ if (pFramesOutF32 != NULL) { MA_ASSERT(pResampler->inTimeInt == 0); - ma_linear_resampler_interpolate_frame_f32(pResampler, pFramesOutF32); + ma_linear_resampler_interpolate_frame_f32(pResampler, invSampleRateOut, pFramesOutF32); /* Filter. Do not apply filtering if sample rates are the same or else you'll get dangerous glitching. */ if (pResampler->inAdvanceInt == 1 && pResampler->inAdvanceFrac == 0) {