diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/audio_core/algorithm/interpolate.cpp | 5 | ||||
| -rw-r--r-- | src/audio_core/audio_renderer.cpp | 7 |
2 files changed, 8 insertions, 4 deletions
diff --git a/src/audio_core/algorithm/interpolate.cpp b/src/audio_core/algorithm/interpolate.cpp index 3aea9b0f2..5005ba519 100644 --- a/src/audio_core/algorithm/interpolate.cpp +++ b/src/audio_core/algorithm/interpolate.cpp | |||
| @@ -54,8 +54,9 @@ std::vector<s16> Interpolate(InterpolationState& state, std::vector<s16> input, | |||
| 54 | double l = 0.0; | 54 | double l = 0.0; |
| 55 | double r = 0.0; | 55 | double r = 0.0; |
| 56 | for (std::size_t j = 0; j < h.size(); j++) { | 56 | for (std::size_t j = 0; j < h.size(); j++) { |
| 57 | l += Lanczos(taps, pos + j - taps + 1) * h[j][0]; | 57 | const double lanczos_calc = Lanczos(taps, pos + j - taps + 1); |
| 58 | r += Lanczos(taps, pos + j - taps + 1) * h[j][1]; | 58 | l += lanczos_calc * h[j][0]; |
| 59 | r += lanczos_calc * h[j][1]; | ||
| 59 | } | 60 | } |
| 60 | output.emplace_back(static_cast<s16>(std::clamp(l, -32768.0, 32767.0))); | 61 | output.emplace_back(static_cast<s16>(std::clamp(l, -32768.0, 32767.0))); |
| 61 | output.emplace_back(static_cast<s16>(std::clamp(r, -32768.0, 32767.0))); | 62 | output.emplace_back(static_cast<s16>(std::clamp(r, -32768.0, 32767.0))); |
diff --git a/src/audio_core/audio_renderer.cpp b/src/audio_core/audio_renderer.cpp index 2e59894ab..2683f3a5f 100644 --- a/src/audio_core/audio_renderer.cpp +++ b/src/audio_core/audio_renderer.cpp | |||
| @@ -285,8 +285,11 @@ void AudioRenderer::VoiceState::RefreshBuffer() { | |||
| 285 | break; | 285 | break; |
| 286 | } | 286 | } |
| 287 | 287 | ||
| 288 | samples = | 288 | // Only interpolate when necessary, expensive. |
| 289 | Interpolate(interp_state, std::move(samples), GetInfo().sample_rate, STREAM_SAMPLE_RATE); | 289 | if (GetInfo().sample_rate != STREAM_SAMPLE_RATE) { |
| 290 | samples = Interpolate(interp_state, std::move(samples), GetInfo().sample_rate, | ||
| 291 | STREAM_SAMPLE_RATE); | ||
| 292 | } | ||
| 290 | 293 | ||
| 291 | is_refresh_pending = false; | 294 | is_refresh_pending = false; |
| 292 | } | 295 | } |