diff options
| author | 2021-07-12 22:09:05 -0700 | |
|---|---|---|
| committer | 2021-07-12 22:09:05 -0700 | |
| commit | 7d464f73c9990329d14617de71653612de46085b (patch) | |
| tree | 0cdb2d11e9bf0a7084aa4a5f8421d907291e1053 /src | |
| parent | Merge pull request #6597 from FernandoS27/accelerate-dma (diff) | |
| parent | Replace NaN mix volume samples with silence. (diff) | |
| download | yuzu-7d464f73c9990329d14617de71653612de46085b.tar.gz yuzu-7d464f73c9990329d14617de71653612de46085b.tar.xz yuzu-7d464f73c9990329d14617de71653612de46085b.zip | |
Merge pull request #6571 from Kelebek1/Mix
audio_core: Replace NaN mix volume samples with silence
Diffstat (limited to '')
| -rw-r--r-- | src/audio_core/command_generator.cpp | 9 |
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 | |||
| 42 | 42 | ||
| 43 | s32 ApplyMixRamp(std::span<s32> output, std::span<const s32> input, float gain, float delta, | 43 | s32 ApplyMixRamp(std::span<s32> output, std::span<const s32> input, float gain, float delta, |
| 44 | s32 sample_count) { | 44 | s32 sample_count) { |
| 45 | // XC2 passes in NaN mix volumes, causing further issues as we handle everything as s32 rather | ||
| 46 | // than float, so the NaN propogation is lost. As the samples get further modified for | ||
| 47 | // volume etc, they can get out of NaN range, so a later heuristic for catching this is | ||
| 48 | // more difficult. Handle it here by setting these samples to silence. | ||
| 49 | if (std::isnan(gain)) { | ||
| 50 | gain = 0.0f; | ||
| 51 | delta = 0.0f; | ||
| 52 | } | ||
| 53 | |||
| 45 | s32 x = 0; | 54 | s32 x = 0; |
| 46 | for (s32 i = 0; i < sample_count; i++) { | 55 | for (s32 i = 0; i < sample_count; i++) { |
| 47 | x = static_cast<s32>(static_cast<float>(input[i]) * gain); | 56 | x = static_cast<s32>(static_cast<float>(input[i]) * gain); |