From 0d4581575910b60de614d5fc05995a5875835695 Mon Sep 17 00:00:00 2001 From: stechyo Date: Sat, 21 Sep 2024 09:51:21 +0100 Subject: [PATCH] Fix: hearing damage when all direct effects are disabled. (closes #70) It seems that iplAudioBufferMix doesn't clear the buffers, and doing it by hand seems to avoid weird audio. --- src/stream.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/stream.cpp b/src/stream.cpp index 6560674..88d5fe2 100644 --- a/src/stream.cpp +++ b/src/stream.cpp @@ -92,6 +92,12 @@ int32_t SteamAudioStreamPlayback::_mix(AudioFrame *buffer, double rate_scale, in ls->fx.direct, &ls->direct_outputs, &ls->bufs.in, &ls->bufs.direct); } else { + for (int i = 0; i < ls->bufs.direct.numChannels; i++) { + for (int j = 0; j < ls->bufs.direct.numSamples; j++) { + ls->bufs.direct.data[i][j] = 0.0f; + } + } + iplAudioBufferMix(gs->ctx, &ls->bufs.in, &ls->bufs.direct); }