mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-11-27 13:04:21 +01:00
Replace NaN mix volume samples with silence.
Fixes Xenoblade Chronicles 2 blowing out the audio.
This commit is contained in:
parent
91a4a924b1
commit
7905eb0254
@ -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 ApplyMixRamp(std::span<s32> output, std::span<const s32> input, float gain, float delta,
|
||||||
s32 sample_count) {
|
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;
|
s32 x = 0;
|
||||||
for (s32 i = 0; i < sample_count; i++) {
|
for (s32 i = 0; i < sample_count; i++) {
|
||||||
x = static_cast<s32>(static_cast<float>(input[i]) * gain);
|
x = static_cast<s32>(static_cast<float>(input[i]) * gain);
|
||||||
|
Loading…
Reference in New Issue
Block a user