summaryrefslogtreecommitdiffstats
path: root/src/audio_core
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2021-07-13 07:09:05 +0200
committerGitHub <noreply@github.com>2021-07-13 07:09:05 +0200
commit7d464f73c9990329d14617de71653612de46085b (patch)
tree0cdb2d11e9bf0a7084aa4a5f8421d907291e1053 /src/audio_core
parentMerge pull request #6597 from FernandoS27/accelerate-dma (diff)
parentReplace NaN mix volume samples with silence. (diff)
downloadyuzu-7d464f73c9990329d14617de71653612de46085b.tar
yuzu-7d464f73c9990329d14617de71653612de46085b.tar.gz
yuzu-7d464f73c9990329d14617de71653612de46085b.tar.bz2
yuzu-7d464f73c9990329d14617de71653612de46085b.tar.lz
yuzu-7d464f73c9990329d14617de71653612de46085b.tar.xz
yuzu-7d464f73c9990329d14617de71653612de46085b.tar.zst
yuzu-7d464f73c9990329d14617de71653612de46085b.zip
Diffstat (limited to 'src/audio_core')
-rw-r--r--src/audio_core/command_generator.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/audio_core/command_generator.cpp b/src/audio_core/command_generator.cpp
index b99d0fc91..45b2eef52 100644
--- a/src/audio_core/command_generator.cpp
+++ b/src/audio_core/command_generator.cpp
@@ -42,6 +42,15 @@ void ApplyMix(std::span<s32> output, std::span<const s32> input, s32 gain, s32 s
s32 ApplyMixRamp(std::span<s32> output, std::span<const s32> input, float gain, float delta,
s32 sample_count) {
+ // XC2 passes in NaN mix volumes, causing further issues as we handle everything as s32 rather
+ // than float, so the NaN propogation is lost. As the samples get further modified for
+ // volume etc, they can get out of NaN range, so a later heuristic for catching this is
+ // more difficult. Handle it here by setting these samples to silence.
+ if (std::isnan(gain)) {
+ gain = 0.0f;
+ delta = 0.0f;
+ }
+
s32 x = 0;
for (s32 i = 0; i < sample_count; i++) {
x = static_cast<s32>(static_cast<float>(input[i]) * gain);