The warning's trill, and why it only sometimes came out

An LFO belongs to the DEVICE and not to a channel. There are two of them
against four voices, and a patch carries LFO settings the way it carries
everything else - so whichever patch was loaded last owns both of them,
for every voice at once.

The warning's trill is a saw LFO on the pitch. The patches on channel
three, the bang and the latch, carry an LFO that is switched off, and
they load at the moment they are used. So the first landing, docking or
crash of a run took the trill away and left a plain tone, and it was
right again next time the machine started. Correct until something
unrelated plays is the worst shape a fault can have.

The same thing had already happened silently at startup: the instruments
were set up in order, so the warning's LFO settings, written last, sat on
top of the rumble's and the rumble never had its own at all.

So nothing is set up once any more. Each sound loads its patch
immediately before its note - forty-odd writes at a moment already making
a sound - and is then whatever its patch says, whatever played before it.
Measured after a landing: 1056, 660, 516 hertz, then up to 1698 and down
again. Two sweeps of the saw, which is the trill.

What it does not fix, because it cannot: two sounds overlapping still
share the LFOs, so a warning going off mid-burn re-tunes the rumble for
as long as it lasts. With two between four that is the device.

Three checks at the device level, where the trap can be stated exactly: a
routed LFO bends a pitch (184 Hz against the 262 the note asked for),
another channel's patch takes it away (272, the note itself), and saying
it again gets it back (184). Written up in the Programming Manual beside
the LFO mode, since the next program to want two sounds will meet it too.
This commit is contained in:
Anachronaut
2026-09-04 19:44:02 -04:00
parent 5e85356245
commit 3ca5f193e6
14 changed files with 139 additions and 33 deletions
+81
View File
@@ -496,6 +496,87 @@ PY
&& result ok "and two hits are the same hit" "sample for sample, noise and all" \
|| result no "and two hits are the same hit" "$SAME"
# ---- An LFO belongs to the device, and a patch carries LFO settings ----
#
# Which is a trap with teeth, and it bit a game before it was written down here. Four voices
# share two LFOs, so a patch loaded onto channel ONE re-tunes what channel NOUGHT hears - and
# a program that sets its instruments up once at startup gets whichever of them was written
# last, for all of them.
#
# The symptom is the worst kind: a sound that is right until some unrelated thing plays, and
# right again next time the machine starts. In the game it was a warning whose trill vanished
# after the first landing of a run, because the landing's patch carries an LFO switched off.
#
# Three notes on channel nought, all identical in what THEY were told. Between the first and
# second, a patch is dropped on channel one that switches the LFO off; between the second and
# third, channel nought's own settings are written again.
{ printf '#Program\nstart:\n'; port 0x41 0x00; loud
param 0x00 1 # triangle, so the LFO's work on the pitch is plain
param 0x51 1 # triggered, so each note ends itself
param 0x20 0x00; param 0x21 40; param 0x22 0x00
param 0x08 3 # pitch follows LFO 0
param 0x09 200 # and a long way
param 0x60 0x01; param 0x61 2; param 0x62 40; param 0x63 0x01
port 0x44 60; pause one 250
port 0x41 0x01 # somebody else's instrument, which says the LFO is off
param 0x60 0x00
port 0x41 0x00
port 0x44 60; pause two 250
port 0x41 0x00 # and its own settings said again, which is the fix
param 0x60 0x01; param 0x61 2; param 0x62 40; param 0x63 0x01
port 0x44 60; spinForever
printf '#Vectors\n Boot start\n'; } | run lfoshared 8000000 || exit 1
read -r FIRST SECOND THIRD <<EOT
$(python3 - "$BUILD/lfoshared.raw" <<'PY'
import struct, sys
data = open(sys.argv[1], "rb").read()
v = struct.unpack("<%dh" % (len(data) // 2), data)
# Three notes, found as sound after silence.
at, sounding, quiet = [], False, 0
for i, x in enumerate(v):
if abs(x) > 300:
if not sounding:
at.append(i); sounding = True
quiet = 0
elif sounding:
quiet += 1
if quiet > 3000: sounding = False
if len(at) < 3:
print("0 0 0"); raise SystemExit
# ---- The PITCH of each, not how far it travels inside one ----
#
# The LFO here is slower than the note is long, so within one note it barely moves - what it
# does is hold the pitch somewhere other than where the note asked for. Which is the honest
# thing to measure anyway: a retriggered LFO starts at the same phase every time, so two notes
# that agree had the same LFO and one that disagrees did not.
def hz(start):
w = v[start:start + 3000]
peak = max((abs(x) for x in w), default=0)
if not peak: return 0
gate, cross, side = peak // 10, 0, 0
for x in w:
if side <= 0 and x > gate: side, cross = 1, cross + 1
elif side >= 0 and x < -gate: side, cross = -1, cross + 1
return cross * 48000 // (2 * len(w))
print(hz(at[0]), hz(at[1]), hz(at[2]))
PY
)
EOT
# The note asks for middle C, about 262. With the LFO on it is bent well away from that.
[ "$FIRST" -gt 0 ] && [ "$SECOND" -gt 0 ] && [ "$THIRD" -gt 0 ] \
&& result ok "an LFO bends the pitch it is routed to" "$FIRST hertz against the 262 asked for" \
|| result no "an LFO bends the pitch it is routed to" "$FIRST $SECOND $THIRD"
# Switched off by a patch meant for ANOTHER CHANNEL, and the note comes back unbent.
[ "$(( SECOND - FIRST ))" -gt 40 ] \
&& result ok "and another channel's patch takes it away" "$FIRST became $SECOND, which is the note itself" \
|| result no "and another channel's patch takes it away" "$FIRST then $SECOND, so it was not shared"
# And said again, it is bent exactly as before, because a retriggered LFO starts where it did.
[ "$FIRST" = "$THIRD" ] \
&& result ok "and saying it again gets it back" "$SECOND became $THIRD again" \
|| result no "and saying it again gets it back" "$SECOND then $THIRD"
echo
if [ "$FAIL" -eq 0 ]; then
echo "All $PASS sound checks passed."