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
@@ -368,6 +368,10 @@ default-ON (`'0'` disables).
|
||||
| `BT_GAUGE_ATTR_LOG` | `[attr] <binding> OK/NULL` per config binding |
|
||||
| `BT_GAUGE_SKIP_LOG` | `[gskip] <primitive>` per unregistered gauge widget the parse skips |
|
||||
| `BT_VALVE_LOG` | condenser valve flow distribution |
|
||||
| `BT_LOOP_AUDIT` | `[loop-audit]` per-sound `sample-flag × source-render-type -> AL_LOOPING` (Gitea #51; rig `scratchpad/loopaudit.py`) |
|
||||
| `BT_LOOP_LEGACY=1` | restore the OLD always-loop rule (`AL_LOOPING = sample != ForceStatic`) for a field A/B — see the loop-flag note in [[wintesla-port]] |
|
||||
| `BT_AUDIO_DUMP` | once-a-second `[playing]` dump of every playing AL source + gain/pitch/**loop** — catches a stuck looping source red-handed |
|
||||
| `BT_AUD_TAIL` | `[aud-tail]` timestamped PLAY/STOP/fade tracing per source |
|
||||
| `BT_SECTOR_LOG` | SectorDisplay Make/Execute |
|
||||
| `BT_NET_TRACE` | `[net-tx]/[net-rx]/[net-upd]` MP tracing |
|
||||
| `BT_DEV_GAUGES` | render the 6 pod MFD surfaces in a separate dev window |
|
||||
|
||||
@@ -81,6 +81,29 @@ on top of it. Full detail: `docs/PROGRESS_LOG.md §5b, §8`.
|
||||
`MAX_PRESET_SAMPLES=25` (AllExplosion). Authored loop REGIONS apply via `AL_SOFT_loop_points`;
|
||||
authored `releaseVolEnv` (1.1–3.9 s on ~20 looping presets) fades on Stop
|
||||
(`PRESET_serviceReleaseFades`, serviced from `AudioHead::Execute`).
|
||||
- **⚠ THE LOOP FLAG IS NOT THE LOOP DECISION (Gitea #51, 2026-07-25).** `SetupPatch`
|
||||
(`L4AUDLVL.cpp`) used to map `AL_LOOPING = (sample != ForceStatic)`, which armed **224 of the
|
||||
603 authored samples** as OpenAL sources that never end — any whose note-off never arrives plays
|
||||
**forever** (SAURON: "coolant flush sound glitched and perma"). Three facts say the sample flag
|
||||
only expresses PERMISSION, and the SOURCE decides [T1]:
|
||||
(1) 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` =
|
||||
always; (2) `LoopAtWill` is enum value **0**, i.e. the DEFAULT an unauthored sample receives
|
||||
(`WTPresets.cpp:37`) — it cannot mean "loop forever"; (3) `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`). New rule: `LoopAlways`→1,
|
||||
`ForceStatic`→0, `LoopAtWill`→ the source's render type. **Measured** (`BT_LOOP_AUDIT=1`,
|
||||
`scratchpad/loopaudit.py`): `LoopAtWill×Transient` 1946 events flip 1→0, `LoopAtWill×Sustained`
|
||||
65 events stay 1, `ForceStatic×Transient` 292 unchanged — the engine loops
|
||||
(EngineAccel07_z0-z2/EngineMotor01/EnginePower01) are all Sustained and **preserved**; all 24
|
||||
reclassified samples are genuine one-shots (laser charge/fire/explosion, missile loading,
|
||||
coolant pressure inc/dec). **A/B proof** (`scratchpad/loopab.py`): under the old rule
|
||||
`CoolantPresInc03_z2` + `CoolantPresDcr03_z2` are still playing with `loop=1` after every
|
||||
release; under the new rule zero coolant sources survive, engine loop intact. `BT_LOOP_LEGACY=1`
|
||||
restores the old rule for a field A/B — listen to the beam-sustain layers (`LaserA/CSustain*` are
|
||||
`LoopAtWill` on a Transient source, so they now end with the sample). A stuck looping source also
|
||||
holds a pool slot for the rest of the match, so this plausibly contributed to **#32**'s dropouts.
|
||||
- **Distance/volume/doppler**: OpenAL distance model is `AL_NONE` — the AUTHORED
|
||||
`GetDistanceVolumeScale()` curve multiplies in `CalculateSourceVolumeScale` (Dynamic3D +
|
||||
Static3D); per-source `AL_GAIN = volume_scale²` (GM CC7 squared law); `alDopplerFactor(0)` —
|
||||
|
||||
@@ -553,6 +553,70 @@ nothing lost in THIS stream (listens on 1) but Slide/Rest scrape audio elsewhere
|
||||
|
||||
---
|
||||
|
||||
<a name="f38"></a>
|
||||
### F38 — `LoopAtWill` was mapped to "loop forever" (Gitea #51) — FIXED 2026-07-25
|
||||
|
||||
**Symptom (playtest night 3, SAURON):** "coolant flush sound glitched and perma" — a coolant sound
|
||||
started and never stopped; a client restart cleared it.
|
||||
|
||||
**Defect.** `PatchLevelOfDetail::SetupPatch` (`L4AUDLVL.cpp`) decided looping from the SAMPLE flag
|
||||
alone: `AL_LOOPING = (info.loop != ForceStatic)`. That armed **224 of the 603 authored samples** as
|
||||
OpenAL sources that never end on their own — including unmistakable one-shots (laser fire, explosions,
|
||||
button clicks). Any such sound whose note-off never arrives plays forever. Measured **1946**
|
||||
`LoopAtWill × Transient` arming events in a single short session.
|
||||
|
||||
**Why the sample flag is not the decision** [T1]:
|
||||
|
||||
| evidence | source |
|
||||
|---|---|
|
||||
| `LoopAtWill` = "will play once **or loop as desired**"; `ForceStatic` = "plays only once **even if looped**" (a veto); `LoopAlways` = "ramp up and then down" | `L4AUDLVL.h:14-19`, the engine's own comments |
|
||||
| `LoopAtWill` is enum value **0** — the DEFAULT an unauthored sample receives | `WTPresets.cpp:37` (`none.loop = LoopAtWill`) |
|
||||
| `LoopAlways`, the real always-loop, is used by **zero** shipped samples | `audiopresets.cpp` (0 occurrences) |
|
||||
|
||||
So "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`).
|
||||
|
||||
**Fix.** `SetupPatch` takes the source's render type; the rule becomes `LoopAlways`→1,
|
||||
`ForceStatic`→0, `LoopAtWill`→`sustained`. Threaded from all three `L4AudioSource` call sites
|
||||
(Direct/Dynamic3D/Static3D, `L4AUDIO.cpp:966/1314/1875`).
|
||||
|
||||
**Measured, not assumed** (`BT_LOOP_AUDIT=1`, `scratchpad/loopaudit.py`):
|
||||
|
||||
| sample flag | source type | loop | events |
|
||||
|---|---|---|---|
|
||||
| LoopAtWill | Transient | 0 (**was 1**) | 1946 |
|
||||
| LoopAtWill | Sustained | 1 (unchanged) | 65 |
|
||||
| ForceStatic | Transient | 0 (unchanged) | 292 |
|
||||
|
||||
The engine loops (`EngineAccel07_z0..z2`, `EngineMotor01`, `EnginePower01`) are all
|
||||
`LoopAtWill / Sustained` and **preserved**. 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):
|
||||
|
||||
```
|
||||
[legacy] still playing loop=1 after all releases: EnginePower01, CoolantPresInc03_z2, CoolantPresDcr03_z2
|
||||
[fixed] still playing loop=1 after all releases: EnginePower01
|
||||
```
|
||||
|
||||
The two stuck coolant sources ARE the reported symptom. Note 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 that source. The fix removes the mechanism.
|
||||
|
||||
**Residual risk / how to A/B in the field.** `BT_LOOP_LEGACY=1` restores the old rule without a
|
||||
rebuild. The layers to listen to are the beam sustains: `LaserASustain*` / `LaserCSustain*` are
|
||||
authored `LoopAtWill` on a **Transient** source, so they now end with the sample rather than looping
|
||||
until note-off. If a beam sounds short, that is the knob. [The render type is T1 authored data; the
|
||||
*interpretation* that `LoopAtWill` defers to it is a strong reading of the enum + defaults, not a
|
||||
disassembled statement — flagged accordingly.]
|
||||
|
||||
**Likely bearing on #32** (audio cutting in and out late in a match): a stuck looping source holds
|
||||
its pool slot for the rest of the round, so eliminating 1946 potential leaks per session should
|
||||
reduce source-pool starvation.
|
||||
|
||||
---
|
||||
|
||||
<a name="validations"></a>
|
||||
## 4. Validations and KB corrections (no fidelity gap)
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
"""Reproduce Gitea #51 -- the coolant flush sound loops forever (SAURON, night 3).
|
||||
|
||||
Uses the built-in scripted flush (BT_FLUSH_TEST=<frame>): holds the flush for ~60
|
||||
sim frames, then releases. Instruments all four layers of the chain so the stuck
|
||||
stage is identifiable rather than guessed:
|
||||
|
||||
[flush-tx] the input dispatch edge (mech4.cpp:5566 -- PRESS / RELEASE pair)
|
||||
[flush] the reservoir drain (heatfamily_reslice.cpp:772, while alarm==1)
|
||||
[aud-tail] OpenAL PLAY / STOP per source, with the LoopAtWill flag + release time
|
||||
[audio] PlayNote / StopNote calls
|
||||
|
||||
PASS = one PRESS + one RELEASE, the [flush] drain STOPS after the release, and every
|
||||
CoolantDump source that got a PLAY also gets a STOP. A stuck sound shows up as
|
||||
either repeated PLAY lines with no STOP (per-frame re-trigger -- PlayNote restarts
|
||||
any source not currently AL_PLAYING) or a PLAY with no matching STOP at all.
|
||||
|
||||
Runs well past the release so a late re-trigger is visible. Kills only its own PID.
|
||||
"""
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
||||
REPO = r"C:\git\bt411"
|
||||
LOG = os.path.join(REPO, "scratchpad_flushsnd.log")
|
||||
if os.path.exists(LOG):
|
||||
os.remove(LOG)
|
||||
|
||||
env = dict(os.environ)
|
||||
env.update({
|
||||
"BT_START_INSIDE": "1",
|
||||
"BT_DEV_GAUGES": "1",
|
||||
"BT_FLUSH_TEST": "300", # press at sim frame 300, release 60 frames later
|
||||
"BT_FLUSH_LOG": "1",
|
||||
"BT_AUD_TAIL": "1",
|
||||
"BT_AUDIO_LOG": "1",
|
||||
"BT_LOG": LOG,
|
||||
})
|
||||
proc = subprocess.Popen(
|
||||
[os.path.join(REPO, "build", "Release", "btl4.exe"), "-egg", "LAST.EGG"],
|
||||
cwd=os.path.join(REPO, "content"), env=env,
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
print("pid", proc.pid)
|
||||
|
||||
try:
|
||||
deadline = time.time() + 260
|
||||
released = False
|
||||
while time.time() < deadline:
|
||||
if os.path.exists(LOG):
|
||||
t = open(LOG, errors="replace").read()
|
||||
if "[flush-tx] InjectCoolant RELEASE" in t:
|
||||
released = True
|
||||
break
|
||||
time.sleep(2)
|
||||
# keep running well past the release -- a late re-trigger is the whole point
|
||||
time.sleep(20)
|
||||
finally:
|
||||
proc.terminate()
|
||||
time.sleep(1)
|
||||
|
||||
t = open(LOG, errors="replace").read() if os.path.exists(LOG) else ""
|
||||
tx = re.findall(r"^\[flush-tx\].*$", t, re.M)
|
||||
drain = re.findall(r"^\[flush\].*$", t, re.M)
|
||||
tail = re.findall(r"^\[aud-tail\].*$", t, re.M)
|
||||
|
||||
# pair PLAY/STOP per source, and flag which sources carry the LoopAtWill flag
|
||||
plays, stops, loopy = {}, {}, set()
|
||||
for l in tail:
|
||||
m = re.search(r"(PLAY|STOP) src=(\d+).*?file=(\S+)", l)
|
||||
if not m:
|
||||
continue
|
||||
kind, src, f = m.group(1), m.group(2), m.group(3)
|
||||
(plays if kind == "PLAY" else stops).setdefault((src, f), 0)
|
||||
(plays if kind == "PLAY" else stops)[(src, f)] += 1
|
||||
if kind == "PLAY" and "loop=1" in l:
|
||||
loopy.add((src, f))
|
||||
|
||||
print("\n=============== RESULT ===============")
|
||||
print("reached the release edge:", released)
|
||||
print("\n[flush-tx] dispatch edges:", len(tx))
|
||||
for l in tx:
|
||||
print(" ", l[:120])
|
||||
|
||||
print("\n[flush] drain samples:", len(drain), "(should stop at the release)")
|
||||
for l in drain[:4]:
|
||||
print(" ", l[:120])
|
||||
if len(drain) > 4:
|
||||
print(" ... last:", drain[-1][:120])
|
||||
|
||||
print("\nOpenAL source pairing (coolant layers only):")
|
||||
allk = sorted(set(plays) | set(stops))
|
||||
unbalanced = []
|
||||
for k in allk:
|
||||
if "Coolant" not in k[1] and "coolant" not in k[1]:
|
||||
continue
|
||||
p, s = plays.get(k, 0), stops.get(k, 0)
|
||||
flag = " LoopAtWill" if k in loopy else ""
|
||||
print(" src=%-5s %-28s PLAY=%d STOP=%d%s" % (k[0], k[1], p, s, flag))
|
||||
if p > s:
|
||||
unbalanced.append((k, p, s))
|
||||
|
||||
print("\nTotal [aud-tail] lines:", len(tail))
|
||||
if unbalanced:
|
||||
print("\n*** UNBALANCED (sound left running / re-triggered):")
|
||||
for k, p, s in unbalanced:
|
||||
print(" %s %s PLAY=%d STOP=%d" % (k[0], k[1], p, s))
|
||||
|
||||
verdict = ("REPRODUCED -- a coolant source plays more than it stops" if unbalanced
|
||||
else ("clean pairing this run -- flush start/stop balanced" if tail
|
||||
else "NO [aud-tail] output -- audio path never fired (check the rig)"))
|
||||
print("\nVERDICT:", verdict)
|
||||
sys.exit(0)
|
||||
@@ -0,0 +1,117 @@
|
||||
"""Gitea #51 part 2 -- catch the STUCK looping coolant source red-handed.
|
||||
|
||||
Part 1 (flushsnd.py) showed the flush picks one of five CoolantDump variants and
|
||||
that the note-off does arrive. But three of the five variants contain a zone
|
||||
authored **LoopAtWill**, and SetupPatch (L4AUDLVL.cpp:290-296) maps anything that
|
||||
is not ForceStatic to **AL_LOOPING = 1** -- an OpenAL source that never ends on
|
||||
its own. The enum's own comment says LoopAtWill means "will play once OR loop as
|
||||
desired" (L4AUDLVL.h:16), i.e. permission to loop, not a command.
|
||||
|
||||
So: drive several flushes (variant selection differs per trigger), then sit idle
|
||||
and use the engine's own BT_AUDIO_DUMP once-a-second playing-source dump to see
|
||||
whether anything is STILL playing with loop=1 long after the last release.
|
||||
|
||||
PASS (bug absent) = no [playing] lines with loop=1 after the idle period.
|
||||
FAIL (bug present) = a coolant source still playing with loop=1 forever.
|
||||
|
||||
Kills only the PID it spawns.
|
||||
"""
|
||||
import ctypes
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
||||
KEYUP = 0x0002
|
||||
VK_H = 0x48
|
||||
user32 = ctypes.windll.user32
|
||||
|
||||
REPO = r"C:\git\bt411"
|
||||
LOG = os.path.join(REPO, "scratchpad_flushsnd2.log")
|
||||
if os.path.exists(LOG):
|
||||
os.remove(LOG)
|
||||
|
||||
env = dict(os.environ)
|
||||
env.update({
|
||||
"BT_START_INSIDE": "1",
|
||||
"BT_KEY_NOFOCUS": "1",
|
||||
"BT_DEV_GAUGES": "1",
|
||||
"BT_FLUSH_LOG": "1",
|
||||
"BT_AUD_TAIL": "1",
|
||||
"BT_AUDIO_DUMP": "1", # once-a-second dump of every PLAYING source + its loop flag
|
||||
"BT_LOG": LOG,
|
||||
})
|
||||
proc = subprocess.Popen(
|
||||
[os.path.join(REPO, "build", "Release", "btl4.exe"), "-egg", "LAST.EGG"],
|
||||
cwd=os.path.join(REPO, "content"), env=env,
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
print("pid", proc.pid)
|
||||
|
||||
|
||||
def tap(hold=0.35):
|
||||
user32.keybd_event(VK_H, 0, 0, 0)
|
||||
time.sleep(hold)
|
||||
user32.keybd_event(VK_H, 0, KEYUP, 0)
|
||||
|
||||
|
||||
try:
|
||||
deadline = time.time() + 240
|
||||
while time.time() < deadline:
|
||||
if os.path.exists(LOG) and "first frame" in open(LOG, errors="replace").read():
|
||||
break
|
||||
time.sleep(2)
|
||||
else:
|
||||
print("FAIL: never reached the mission")
|
||||
proc.terminate()
|
||||
sys.exit(2)
|
||||
time.sleep(6)
|
||||
|
||||
# six flushes, spaced -- the variant selection differs per trigger
|
||||
for i in range(6):
|
||||
tap()
|
||||
print(" flush %d dispatched" % (i + 1))
|
||||
time.sleep(3.0)
|
||||
|
||||
print(" idling 25s -- anything still playing now is STUCK")
|
||||
idle_mark = len(open(LOG, errors="replace").read())
|
||||
time.sleep(25)
|
||||
finally:
|
||||
proc.terminate()
|
||||
time.sleep(1)
|
||||
|
||||
t = open(LOG, errors="replace").read() if os.path.exists(LOG) else ""
|
||||
tail_t = t[idle_mark:] if "idle_mark" in dir() else t
|
||||
|
||||
tx = re.findall(r"^\[flush-tx\].*$", t, re.M)
|
||||
variants = sorted(set(re.findall(r"file=(CoolantDump\d+_z\d+\.wav)", t)))
|
||||
# playing-source dumps recorded DURING the idle window (post-release)
|
||||
idle_play = re.findall(r"^\[playing\].*$", tail_t, re.M)
|
||||
stuck = [l for l in idle_play if "loop=1" in l]
|
||||
stuck_coolant = [l for l in stuck if "oolant" in l]
|
||||
|
||||
print("\n=============== RESULT ===============")
|
||||
print("[flush-tx] edges:", len(tx), "(expect 12 = 6 press + 6 release)")
|
||||
print("coolant zones that actually played:", len(variants))
|
||||
for v in variants:
|
||||
print(" ", v)
|
||||
|
||||
print("\n[playing] lines during the 25s IDLE window:", len(idle_play))
|
||||
seen = {}
|
||||
for l in idle_play:
|
||||
m = re.search(r"src=(\d+) (\S+).*loop=(\d+)", l)
|
||||
if m:
|
||||
seen[(m.group(1), m.group(2), m.group(3))] = seen.get((m.group(1), m.group(2), m.group(3)), 0) + 1
|
||||
for (src, nm, lp), n in sorted(seen.items(), key=lambda kv: -kv[1]):
|
||||
print(" src=%-4s %-28s loop=%s seen %dx" % (src, nm, lp, n))
|
||||
|
||||
print("\nSTILL PLAYING with loop=1 after all releases:", len(stuck))
|
||||
print(" ...of which coolant:", len(stuck_coolant))
|
||||
for l in stuck_coolant[:5]:
|
||||
print(" ", l[:120])
|
||||
|
||||
print("\nVERDICT:", "REPRODUCED -- a looping coolant source outlives its release (#51)"
|
||||
if stuck_coolant else
|
||||
("looping sources stuck, but not coolant -- same class, different sample"
|
||||
if stuck else "no stuck looping source in this run"))
|
||||
sys.exit(0)
|
||||
@@ -0,0 +1,112 @@
|
||||
"""Gitea #51 A/B -- prove the stuck coolant sound before the fix, and gone after.
|
||||
|
||||
Same session both ways; the only difference is BT_LOOP_LEGACY, which selects the
|
||||
OLD loop rule (`AL_LOOPING = sample != ForceStatic`) vs the new one (a LoopAtWill
|
||||
sample defers to the source's authored AudioRenderType).
|
||||
|
||||
The measurement is the engine's own once-a-second playing-source dump
|
||||
(BT_AUDIO_DUMP): after all the flush releases, sit idle, then ask what is STILL
|
||||
playing with loop=1. A coolant source in that list is #51 reproduced.
|
||||
|
||||
Kills only the PIDs it spawns.
|
||||
"""
|
||||
import ctypes
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
||||
KEYUP = 0x0002
|
||||
VK_H = 0x48
|
||||
VK_C = 0x43
|
||||
user32 = ctypes.windll.user32
|
||||
REPO = r"C:\git\bt411"
|
||||
|
||||
|
||||
def run(legacy):
|
||||
tag = "legacy" if legacy else "fixed"
|
||||
log = os.path.join(REPO, "scratchpad_loopab_%s.log" % tag)
|
||||
if os.path.exists(log):
|
||||
os.remove(log)
|
||||
env = dict(os.environ)
|
||||
env.update({
|
||||
"BT_START_INSIDE": "1",
|
||||
"BT_KEY_NOFOCUS": "1",
|
||||
"BT_DEV_GAUGES": "1",
|
||||
"BT_AUDIO_DUMP": "1",
|
||||
"BT_FLUSH_LOG": "1",
|
||||
"BT_LOG": log,
|
||||
})
|
||||
if legacy:
|
||||
env["BT_LOOP_LEGACY"] = "1"
|
||||
else:
|
||||
env.pop("BT_LOOP_LEGACY", None)
|
||||
|
||||
p = subprocess.Popen(
|
||||
[os.path.join(REPO, "build", "Release", "btl4.exe"), "-egg", "LAST.EGG"],
|
||||
cwd=os.path.join(REPO, "content"), env=env,
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
print("[%s] pid %d" % (tag, p.pid))
|
||||
try:
|
||||
deadline = time.time() + 240
|
||||
while time.time() < deadline:
|
||||
if os.path.exists(log) and "first frame" in open(log, errors="replace").read():
|
||||
break
|
||||
time.sleep(2)
|
||||
else:
|
||||
p.terminate()
|
||||
return tag, None
|
||||
time.sleep(6)
|
||||
# exercise the coolant plumbing: flush, valve, flush -- the pressure
|
||||
# inc/dec layers (LoopAtWill/Transient) are the suspect samples
|
||||
for _ in range(4):
|
||||
user32.keybd_event(VK_H, 0, 0, 0); time.sleep(0.5)
|
||||
user32.keybd_event(VK_H, 0, KEYUP, 0); time.sleep(0.6)
|
||||
user32.keybd_event(VK_C, 0, 0, 0); time.sleep(0.2)
|
||||
user32.keybd_event(VK_C, 0, KEYUP, 0); time.sleep(1.2)
|
||||
mark = len(open(log, errors="replace").read())
|
||||
print("[%s] idling 25s" % tag)
|
||||
time.sleep(25)
|
||||
finally:
|
||||
p.terminate()
|
||||
time.sleep(1)
|
||||
|
||||
t = open(log, errors="replace").read()
|
||||
idle = t[mark:]
|
||||
playing = re.findall(r"^\[playing\].*$", idle, re.M)
|
||||
stuck = {}
|
||||
for l in playing:
|
||||
m = re.search(r"src=(\d+) (\S+).*loop=(\d+)", l)
|
||||
if m and m.group(3) == "1":
|
||||
stuck[m.group(2)] = stuck.get(m.group(2), 0) + 1
|
||||
return tag, stuck
|
||||
|
||||
|
||||
results = {}
|
||||
for legacy in (True, False):
|
||||
tag, stuck = run(legacy)
|
||||
results[tag] = stuck
|
||||
|
||||
print("\n=============== A/B RESULT ===============")
|
||||
for tag in ("legacy", "fixed"):
|
||||
s = results.get(tag)
|
||||
if s is None:
|
||||
print("\n[%s] never reached the mission" % tag)
|
||||
continue
|
||||
coolant = {k: v for k, v in s.items() if "oolant" in k}
|
||||
print("\n[%s] still playing with loop=1 after all releases: %d distinct samples"
|
||||
% (tag, len(s)))
|
||||
for k, v in sorted(s.items(), key=lambda kv: -kv[1]):
|
||||
mark = " <-- COOLANT" if "oolant" in k else ""
|
||||
print(" %-30s seen %dx%s" % (k, v, mark))
|
||||
print(" coolant sources stuck: %d" % len(coolant))
|
||||
|
||||
L = results.get("legacy") or {}
|
||||
F = results.get("fixed") or {}
|
||||
lc = len([k for k in L if "oolant" in k])
|
||||
fc = len([k for k in F if "oolant" in k])
|
||||
print("\nVERDICT: legacy coolant-stuck=%d fixed coolant-stuck=%d -> %s"
|
||||
% (lc, fc, "FIX CONFIRMED" if lc > fc else
|
||||
("no coolant stick reproduced in either arm" if lc == 0 else "NOT fixed")))
|
||||
sys.exit(0)
|
||||
@@ -0,0 +1,114 @@
|
||||
"""Gitea #51 -- audit which sounds the LoopAtWill reclassification actually changes.
|
||||
|
||||
The old rule was `AL_LOOPING = (sample != ForceStatic)`, which made every one of the
|
||||
224 non-ForceStatic samples an OpenAL source that never ends. The new rule defers a
|
||||
LoopAtWill sample to the SOURCE's authored AudioRenderType (streamed from
|
||||
AUDIO*.RES), which is what the enum comment says it means.
|
||||
|
||||
This run drives a normal solo session -- engine, walking, weapons, coolant flush --
|
||||
with BT_LOOP_AUDIT=1 and tabulates every sound by (sample flag, source type) so the
|
||||
reclassification is measured, not assumed. The load-bearing question:
|
||||
|
||||
* do the sustained loops (engine, wind) stay loop=1? <- must be YES
|
||||
* which sounds flip [WAS 1, NOW 0]? <- must all be one-shots
|
||||
|
||||
Kills only the PID it spawns.
|
||||
"""
|
||||
import ctypes
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
from collections import Counter
|
||||
|
||||
KEYUP = 0x0002
|
||||
VK = {"W": 0x57, "H": 0x48, "C": 0x43, "SPACE": 0x20}
|
||||
user32 = ctypes.windll.user32
|
||||
|
||||
REPO = r"C:\git\bt411"
|
||||
LOG = os.path.join(REPO, "scratchpad_loopaudit.log")
|
||||
if os.path.exists(LOG):
|
||||
os.remove(LOG)
|
||||
|
||||
env = dict(os.environ)
|
||||
env.update({
|
||||
"BT_START_INSIDE": "1",
|
||||
"BT_KEY_NOFOCUS": "1",
|
||||
"BT_DEV_GAUGES": "1",
|
||||
"BT_LOOP_AUDIT": "1",
|
||||
"BT_AUTOFIRE": "1", # exercise weapon one-shots
|
||||
"BT_LOG": LOG,
|
||||
})
|
||||
proc = subprocess.Popen(
|
||||
[os.path.join(REPO, "build", "Release", "btl4.exe"), "-egg", "LAST.EGG"],
|
||||
cwd=os.path.join(REPO, "content"), env=env,
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
print("pid", proc.pid)
|
||||
|
||||
|
||||
def hold(name, secs):
|
||||
vk = VK[name]
|
||||
user32.keybd_event(vk, 0, 0, 0)
|
||||
time.sleep(secs)
|
||||
user32.keybd_event(vk, 0, KEYUP, 0)
|
||||
time.sleep(0.3)
|
||||
|
||||
|
||||
try:
|
||||
deadline = time.time() + 240
|
||||
while time.time() < deadline:
|
||||
if os.path.exists(LOG) and "first frame" in open(LOG, errors="replace").read():
|
||||
break
|
||||
time.sleep(2)
|
||||
else:
|
||||
print("FAIL: never reached the mission")
|
||||
proc.terminate()
|
||||
sys.exit(2)
|
||||
time.sleep(6)
|
||||
|
||||
hold("W", 4.0) # throttle up -> engine + footfalls
|
||||
hold("H", 0.6) # coolant flush
|
||||
hold("C", 0.2) # valve
|
||||
hold("H", 0.6) # flush again
|
||||
time.sleep(8)
|
||||
finally:
|
||||
proc.terminate()
|
||||
time.sleep(1)
|
||||
|
||||
t = open(LOG, errors="replace").read() if os.path.exists(LOG) else ""
|
||||
lines = re.findall(r"^\[loop-audit\].*$", t, re.M)
|
||||
|
||||
combos = Counter()
|
||||
flipped = {}
|
||||
kept = {}
|
||||
for l in lines:
|
||||
m = re.search(r"file=(\S+) sample=(\S+) source=(\S+) -> loop=(\d)", l)
|
||||
if not m:
|
||||
continue
|
||||
f, samp, src, lp = m.groups()
|
||||
combos[(samp, src, lp)] += 1
|
||||
if "[WAS 1, NOW 0]" in l:
|
||||
flipped[f] = (samp, src)
|
||||
elif lp == "1":
|
||||
kept[f] = (samp, src)
|
||||
|
||||
print("\n=============== RESULT ===============")
|
||||
print("[loop-audit] events:", len(lines))
|
||||
print("\nclassification matrix (sample flag x source type -> loop):")
|
||||
for (samp, src, lp), n in sorted(combos.items(), key=lambda kv: -kv[1]):
|
||||
print(" %-12s x %-9s -> loop=%s (%d events)" % (samp, src, lp, n))
|
||||
|
||||
print("\nSTILL LOOPING (loop=1) -- these must be genuine sustained loops:", len(kept))
|
||||
for f, (samp, src) in sorted(kept.items()):
|
||||
print(" %-30s %s / %s" % (f, samp, src))
|
||||
|
||||
print("\nRECLASSIFIED to one-shot [WAS 1, NOW 0]:", len(flipped))
|
||||
for f, (samp, src) in sorted(flipped.items()):
|
||||
print(" %-30s %s / %s" % (f, samp, src))
|
||||
|
||||
engine_kept = [f for f in kept if "Engine" in f or "Wind" in f]
|
||||
print("\nsustained engine/wind loops preserved:", engine_kept if engine_kept else "NONE -- INVESTIGATE")
|
||||
print("\nVERDICT:", "measured -- review the two lists above" if lines
|
||||
else "no [loop-audit] output (gate not firing?)")
|
||||
sys.exit(0)
|
||||
Reference in New Issue
Block a user