Scale enemy bgm to the current distance when it starts - #7115
Conversation
…s#5706) Enemy bgm starts at the wrong volume because sAudioEnemyVol still holds whatever the previous encounter ended on. Every frame an enemy is in range, the player calls Audio_SetBgmEnemyVolume() and then Audio_SetSequenceMode(). The first records the distance unconditionally but only rescales while enemy bgm is already playing, so on the frame enemy mode begins it stores the new distance and returns without touching the volume. Audio_SetSequenceMode() then crossfades using the old one. Both directions are audible. Entering far from an enemy after an encounter that ended close, the area music is ducked to zero and the enemy bgm fades in loud and then straight back down to nothing - the area goes quiet with nothing replacing it. Entering next to an enemy after one that ended far, the enemy bgm starts inaudible. It corrects itself once the distance changes, and never corrects at all while both stand still, since the rescale is guarded on the distance having moved. This is original game behaviour rather than a port regression, so the rescale sits behind FixEnemyBgmVolume, off by default. The curve moves to a helper so both callers share it.
ece6c22 to
5ce2295
Compare
|
Closing this: tested by ear and the effect is not audible, so the checkbox would promise something it does not deliver. What was tested. Kid, Hyrule Field at night, Stalchild encounters, toggling Why. The stale The description here claimed more than that. I confirmed the mechanism with logging but never checked how long the wrong value survives, which is the part that decides whether it matters. There is one case with a real audible symptom: Not worth the cost, so dropping it rather than leaving it open. |
Fixes #5706.
Enemy bgm starts at the volume of the previous encounter.
Every frame an enemy is within range,
z_player.ccallsAudio_SetBgmEnemyVolume()and thenAudio_SetSequenceMode(). The first records the distance unconditionally but only rescales while enemy bgm is already playing:On the frame enemy mode begins,
sPrevSeqModeis still the old mode, so it stores the new distance and returns without touchingsAudioEnemyVol.Audio_SetSequenceMode()then runs its crossfade against a value that belongs to the last encounter. It also never corrects itself if nothing moves afterwards, because the rescale is guarded on the distance having changed.Both directions are audible. Entering far from an enemy after an encounter that ended close, the area music is ducked to zero while the enemy bgm fades in loud and then straight back down to nothing - the area goes quiet with nothing replacing it, which is what #5706 describes. Entering next to an enemy after one that ended far, the enemy bgm starts inaudible.
Reproduction. Instrumented build logging the distance, the volume in use, and the volume that distance actually calls for:
The first is an enemy spawned on top of the player right after an encounter that ended 494 units away: adjacent enemy, enemy bgm at 2/127. The second is the reported case - an enemy picked up at 495 units, where the previous encounter had ended at full volume; before the change that entry used 127, silencing the area music.
Behind a switch. This is original game behaviour, not a port regression, so the rescale sits behind
FixEnemyBgmVolumeunder Enhancements -> Fixes, off by default. Lifting the curve into a helper is unconditional, since it changes nothing on its own.It is easiest to notice with a custom music pack, because each track is a single streamed channel, so a player scaled to zero goes silent rather than merely thinning out. Nothing about the bug is specific to custom sequences.
Thanks @lankv2 for the log that pinned this down.
Build Artifacts