Gitea #51 ROOT CAUSE: LoopAtWill was mapped to "loop forever", arming 224 of 603 samples as endless OpenAL sources
SAURON's "coolant flush sound glitched and perma" is one instance of a systemic
defect. SetupPatch (L4AUDLVL.cpp) decided looping from the SAMPLE flag alone:
AL_LOOPING = (info.loop != ForceStatic)
That armed every non-ForceStatic sample -- 224 of the 603 authored zones,
including unmistakable one-shots -- as an OpenAL source that never ends on its
own. Any such sound whose note-off never arrives plays forever. Measured 1946
LoopAtWill x Transient arming events in one short session.
The sample flag expresses PERMISSION; the SOURCE decides. Three facts [T1]:
* the enum's own comments (L4AUDLVL.h:14-19) -- LoopAtWill = "will play once
OR LOOP AS DESIRED", ForceStatic = "plays only once EVEN IF LOOPED" (a
veto), LoopAlways = "ramp up and then down";
* LoopAtWill is enum value 0, i.e. the DEFAULT an unauthored sample receives
(WTPresets.cpp:37) -- it cannot mean "loop forever";
* LoopAlways, the real always-loop, is used by ZERO shipped samples.
"As desired" is the source's authored AudioRenderType (Transient=one-shot vs
Sustained=held), streamed from AUDIO*.RES (AUDLVL.cpp:28) and already consulted
by the renderer (L4AUDRND.cpp:567, AUDREND.cpp:184). SetupPatch now takes it,
threaded from all three L4AudioSource call sites (Direct/Dynamic3D/Static3D).
New rule: LoopAlways->1, ForceStatic->0, LoopAtWill->the source's render type.
MEASURED before changing behaviour (BT_LOOP_AUDIT=1, scratchpad/loopaudit.py):
LoopAtWill x Transient -> loop=0 (was 1) 1946 events
LoopAtWill x Sustained -> loop=1 unchanged 65 events
ForceStatic x Transient -> loop=0 unchanged 292 events
The engine loops (EngineAccel07_z0..z2, EngineMotor01, EnginePower01) are all
LoopAtWill/Sustained and PRESERVED -- no regression there. All 24 reclassified
samples are genuine one-shots: laser charge/fire/explosion/loaded, missile
loading, engine shift, coolant pressure inc/dec.
A/B PROOF (scratchpad/loopab.py, same session both arms, only BT_LOOP_LEGACY
differs), asking the engine's own BT_AUDIO_DUMP what is still playing with
loop=1 long after every release:
[legacy] EnginePower01, CoolantPresInc03_z2, CoolantPresDcr03_z2
[fixed] EnginePower01
The two stuck coolant sources are the reported symptom. They were eventually
reclaimed when a later trigger reused the source, which is why the bug was
intermittent -- the "perma" case is when nothing else retriggers it. The fix
removes the mechanism.
BT_LOOP_LEGACY=1 restores the old rule for a field A/B without a rebuild. The
layers to listen to are the beam sustains: LaserA/CSustain* are authored
LoopAtWill on a TRANSIENT source, so they now end with the sample instead of
looping until note-off. The render type is T1 authored data; the interpretation
that LoopAtWill defers to it is a strong reading of the enum + defaults rather
than a disassembled statement, and is flagged as such in the KB.
Plausibly bears on #32 (audio cutting in/out late in a match): a stuck looping
source holds its pool slot for the rest of the round.
Rigs: scratchpad/flushsnd.py (flush start/stop pairing), flushsnd2.py (stuck-
source hunt), loopaudit.py (the classification matrix), loopab.py (the A/B).
KB: context/wintesla-port.md audio section, context/decomp-reference.md env
table (BT_LOOP_AUDIT / BT_LOOP_LEGACY / BT_AUDIO_DUMP / BT_AUD_TAIL),
docs/AUDIO_FIDELITY.md F38. checkctx.py CLEAN.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
f3bdb3b85a
commit
d39227ef39
@@ -963,7 +963,9 @@ void
|
||||
patch_resource = Cast_Object(PatchResource*, GetAudioResource());
|
||||
Check(patch_resource);
|
||||
patch_resource->SetDistance(GetDistanceToSource());
|
||||
patch_resource->SetupPatch(channelSet, (int)GetCurrentNoteValue());
|
||||
patch_resource->SetupPatch(channelSet, (int)GetCurrentNoteValue(),
|
||||
// (Gitea #51) a LoopAtWill sample loops only for a SUSTAINED source
|
||||
(GetAudioRenderType() == SustainedAudioRenderType) ? True : False);
|
||||
|
||||
{ // apply the requested note's pitch to the freshly attached sources
|
||||
float note_pitch = BTNotePitchFactor((int)GetCurrentNoteValue());
|
||||
@@ -1309,7 +1311,9 @@ void
|
||||
patch_resource = Cast_Object(PatchResource*, GetAudioResource());
|
||||
Check(patch_resource);
|
||||
patch_resource->SetDistance(GetDistanceToSource());
|
||||
patch_resource->SetupPatch(channelSet, (int)GetCurrentNoteValue());
|
||||
patch_resource->SetupPatch(channelSet, (int)GetCurrentNoteValue(),
|
||||
// (Gitea #51) a LoopAtWill sample loops only for a SUSTAINED source
|
||||
(GetAudioRenderType() == SustainedAudioRenderType) ? True : False);
|
||||
|
||||
{ // apply the requested note's pitch to the freshly attached sources
|
||||
float note_pitch = BTNotePitchFactor((int)GetCurrentNoteValue());
|
||||
@@ -1868,7 +1872,9 @@ void
|
||||
patch_resource = Cast_Object(PatchResource*, GetAudioResource());
|
||||
Check(patch_resource);
|
||||
patch_resource->SetDistance(GetDistanceToSource());
|
||||
patch_resource->SetupPatch(channelSet, (int)GetCurrentNoteValue());
|
||||
patch_resource->SetupPatch(channelSet, (int)GetCurrentNoteValue(),
|
||||
// (Gitea #51) a LoopAtWill sample loops only for a SUSTAINED source
|
||||
(GetAudioRenderType() == SustainedAudioRenderType) ? True : False);
|
||||
|
||||
{ // apply the requested note's pitch to the freshly attached sources
|
||||
float note_pitch = BTNotePitchFactor((int)GetCurrentNoteValue());
|
||||
|
||||
@@ -237,7 +237,7 @@ Logical
|
||||
//#############################################################################
|
||||
//
|
||||
void
|
||||
PatchLevelOfDetail::SetupPatch(SourceSet sourceSet, int note)
|
||||
PatchLevelOfDetail::SetupPatch(SourceSet sourceSet, int note, Logical sustained)
|
||||
{
|
||||
// Check(this);
|
||||
//// Check(channel);
|
||||
@@ -287,13 +287,57 @@ void
|
||||
alSource3f(sourceSet.sources[i],AL_POSITION,pan_x,0,0);
|
||||
alSource3f(sourceSet.sources[i],AL_VELOCITY,0,0,0);
|
||||
|
||||
if (info.loop == ForceStatic)
|
||||
{
|
||||
alSourcei(sourceSet.sources[i],AL_LOOPING,0);
|
||||
} else
|
||||
{
|
||||
alSourcei(sourceSet.sources[i],AL_LOOPING,1);
|
||||
}
|
||||
//
|
||||
// (Gitea #51) THE LOOP DECISION. The old rule was
|
||||
// `ForceStatic ? 0 : 1`, which turned every non-ForceStatic
|
||||
// sample into an OpenAL source that NEVER ends -- 224 of the
|
||||
// 603 authored samples, including obvious one-shots. Any such
|
||||
// sound whose note-off never arrives plays forever: SAURON's
|
||||
// "coolant flush sound glitched and perma".
|
||||
//
|
||||
// The enum's own comments (L4AUDLVL.h:14-19) say the sample
|
||||
// flag is not the decision:
|
||||
// LoopAtWill "Will play once OR LOOP AS DESIRED" <- defers
|
||||
// ForceStatic "Plays only once EVEN IF LOOPED" <- veto
|
||||
// LoopAlways "Ramp up and then down" <- always
|
||||
// and LoopAtWill is enum value 0, i.e. the DEFAULT an
|
||||
// unauthored sample gets (WTPresets.cpp:37) -- so it cannot
|
||||
// mean "loop forever". LoopAlways, the real always-loop, is
|
||||
// used by ZERO shipped samples.
|
||||
//
|
||||
// "As desired" is the SOURCE's authored AudioRenderType,
|
||||
// streamed from AUDIO*.RES (AUDLVL.cpp:28): a sustained source
|
||||
// (engine, wind, coolant leak) holds its note and loops; a
|
||||
// transient one is a one-shot and must not.
|
||||
//
|
||||
// BT_LOOP_LEGACY=1 restores the old always-loop rule, so a
|
||||
// field A/B can settle any "that sound got cut short" report
|
||||
// without a rebuild (the BT_NO_PILOTLIST precedent). The
|
||||
// beam-sustain layers are the ones to listen to: LaserA/CSustain
|
||||
// are authored LoopAtWill on a TRANSIENT source, so they now end
|
||||
// with the sample instead of looping until the note-off.
|
||||
static int s_legacy = -1;
|
||||
if (s_legacy < 0) s_legacy = (getenv("BT_LOOP_LEGACY") != 0) ? 1 : 0;
|
||||
|
||||
Logical wants_loop = s_legacy
|
||||
? ((info.loop != ForceStatic) ? True : False) // old rule
|
||||
: ((info.loop == LoopAlways) ? True :
|
||||
(info.loop == ForceStatic) ? False :
|
||||
sustained); // LoopAtWill -> the source decides
|
||||
alSourcei(sourceSet.sources[i],AL_LOOPING, wants_loop ? 1 : 0);
|
||||
|
||||
// #51 measurement: tabulate what each sound is authored as, so
|
||||
// the reclassification can be audited rather than assumed.
|
||||
if (getenv("BT_LOOP_AUDIT"))
|
||||
DEBUG_STREAM << "[loop-audit] bank=" << (int)bankID
|
||||
<< " patch=" << (int)patchID
|
||||
<< " file=" << (info.file ? info.file : "?")
|
||||
<< " sample=" << (info.loop == ForceStatic ? "ForceStatic" :
|
||||
info.loop == LoopAlways ? "LoopAlways" : "LoopAtWill")
|
||||
<< " source=" << (sustained ? "Sustained" : "Transient")
|
||||
<< " -> loop=" << (wants_loop ? 1 : 0)
|
||||
<< (( info.loop != ForceStatic && !sustained) ? " [WAS 1, NOW 0]" : "")
|
||||
<< "\n" << std::flush;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -439,7 +483,7 @@ Logical
|
||||
//#############################################################################
|
||||
//
|
||||
void
|
||||
PatchResource::SetupPatch(SourceSet sourceSet, int note)
|
||||
PatchResource::SetupPatch(SourceSet sourceSet, int note, Logical sustained)
|
||||
{
|
||||
Check(this);
|
||||
// Check(channel);
|
||||
@@ -448,7 +492,7 @@ void
|
||||
Cast_Object(PatchLevelOfDetail*, GetAudioLevelOfDetail());
|
||||
|
||||
Check(patch_level_of_detail);
|
||||
patch_level_of_detail->SetupPatch(sourceSet, note);
|
||||
patch_level_of_detail->SetupPatch(sourceSet, note, sustained);
|
||||
}
|
||||
|
||||
void PatchResource::PlayNote(SourceSet sourceSet, int note)
|
||||
|
||||
@@ -115,8 +115,13 @@ public:
|
||||
// Accessors
|
||||
//-----------------------------------------------------------------------
|
||||
//
|
||||
// (Gitea #51) `sustained` carries the SOURCE's authored AudioRenderType
|
||||
// (SustainedAudioRenderType vs TransientAudioRenderType, streamed from
|
||||
// AUDIO*.RES). A LoopAtWill sample means "play once OR loop as desired"
|
||||
// -- it is the SOURCE, not the sample, that decides. Default False keeps
|
||||
// any unconverted caller on the safe one-shot behaviour.
|
||||
void
|
||||
SetupPatch(SourceSet sourceSet, int note);
|
||||
SetupPatch(SourceSet sourceSet, int note, Logical sustained = False);
|
||||
|
||||
MIDINRPNValue
|
||||
GetMaxMIDIFilterCutoff()
|
||||
@@ -188,8 +193,13 @@ public:
|
||||
// Accessors
|
||||
//-----------------------------------------------------------------------
|
||||
//
|
||||
// (Gitea #51) `sustained` carries the SOURCE's authored AudioRenderType
|
||||
// (SustainedAudioRenderType vs TransientAudioRenderType, streamed from
|
||||
// AUDIO*.RES). A LoopAtWill sample means "play once OR loop as desired"
|
||||
// -- it is the SOURCE, not the sample, that decides. Default False keeps
|
||||
// any unconverted caller on the safe one-shot behaviour.
|
||||
void
|
||||
SetupPatch(SourceSet sourceSet, int note);
|
||||
SetupPatch(SourceSet sourceSet, int note, Logical sustained = False);
|
||||
|
||||
MIDINRPNValue
|
||||
GetMaxMIDIFilterCutoff();
|
||||
|
||||
Reference in New Issue
Block a user