FA-81576 / MIDI event timing / Open access
MIDI clock transport and song position: song position LSB and MSB swapped · case 01
A pointer of 4 sixteenths (lsb 4, msb 0) locates to sixteenth 512 instead of 4.
ROOT CAUSE
The 14-bit pointer is assembled with the LSB in the high position.
VERIFIED REPAIR
Restore the pointer byte order step so that it reads `(msg[2] << 7) | msg[1]`.
Unsuccessful approach: Shifting the MSB by eight bits treats the data bytes as full bytes, so msb 1 means 256 instead of 128.
Case contract
Input a list of messages: ["start"], ["continue"], ["stop"], ["clock"] or ["spp", lsb, msb]. start resets the position to 0 and runs; continue runs from the current position; stop halts; clock advances the position by one clock only while running; a song position pointer (in sixteenth notes, 6 clocks each, 14-bit lsb/msb) is honoured only while stopped. Return [position in clocks, running, quarter notes = position // 24]; unknown messages return None.
Why this case matters
MIDI sequencers, file readers and synth drivers depend on exact event ordering and tick/time arithmetic.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
if not isinstance(x, list):
return None
pos = 0
running = False
for msg in x:
kind = msg[0]
if kind == 'start':
pos = 0
running = True
elif kind == 'continue':
running = True
elif kind == 'stop':
running = False
elif kind == 'clock':
if running:
pos += 1
elif kind == 'spp':
if not running:
pos = 6 * ((msg[1] << 7) | msg[2])
else:
return None
return [pos, running, pos // 24]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([['start'], ['clock'], ['clock']], [2, True, 0]), ([['clock'], ['clock']], [0, False, 0]), ([['start'], ['clock'], ['stop'], ['clock'], ['continue'], ['clock']], [2, True, 0]), ([['spp', 4, 0], ['continue'], ['clock']], [25, True, 1]), ([['spp', 0, 1], ['continue']], [768, True, 32]), ([['start'], ['spp', 8, 0], ['clock']], [1, True, 0]), ([['start'], ['clock'], ['stop'], ['start'], ['clock']], [1, True, 0]), ([['stop'], ['spp', 3, 0], ['continue'], ['clock'], ['clock']], [20, True, 0])], [([['spp', 0, 1], ['continue']], [768, True, 32]), ([['spp', 1, 1]], [774, False, 32]), ([['start'], ['spp', 8, 0], ['clock']], [1, True, 0]), ([['start'], ['clock'], ['stop'], ['start'], ['clock']], [1, True, 0]), ([['spp', 16, 0], ['start']], [0, True, 0]), ([['reset']], None), ([], [0, False, 0]), ([['spp', 4, 0], ['continue'], ['stop'], ['continue'], ['clock']], [25, True, 1])], [([['stop'], ['spp', 3, 0], ['continue'], ['clock'], ['clock']], [20, True, 0]), ([['reset']], None), ([], [0, False, 0]), ([['start'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock']], [25, True, 1]), ([['spp', 127, 127]], [98298, False, 4095]), ([['start'], ['clock'], ['clock'], ['stop'], ['spp', 2, 0], ['continue'], ['clock']], [13, True, 0]), ([['continue'], ['clock']], [1, True, 0]), ([['start'], ['stop'], ['continue'], ['clock']], [1, True, 0])], [([['spp', 4, 0], ['continue'], ['clock']], [25, True, 1]), ([['spp', 0, 1], ['continue']], [768, True, 32]), ([['spp', 1, 1]], [774, False, 32]), ([['stop'], ['spp', 3, 0], ['continue'], ['clock'], ['clock']], [20, True, 0]), ([['spp', 127, 127]], [98298, False, 4095]), ([['spp', 4, 0], ['continue'], ['stop'], ['continue'], ['clock']], [25, True, 1]), ([['continue'], ['clock']], [1, True, 0]), ([['start'], ['stop'], ['continue'], ['clock']], [1, True, 0])], [([['start'], ['clock'], ['clock']], [2, True, 0]), ([['clock'], ['clock']], [0, False, 0]), ([['spp', 0, 1], ['continue']], [768, True, 32]), ([['spp', 1, 1]], [774, False, 32]), ([['stop'], ['spp', 3, 0], ['continue'], ['clock'], ['clock']], [20, True, 0]), ([['spp', 127, 127]], [98298, False, 4095]), ([['spp', 4, 0], ['continue'], ['stop'], ['continue'], ['clock']], [25, True, 1]), ([['start'], ['clock'], ['clock'], ['stop'], ['spp', 2, 0], ['continue'], ['clock']], [13, True, 0])]]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("oracle %d" % i, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| oracle 0 | [2, True, 0] | [2, True, 0] | Passed |
| oracle 1 | [0, False, 0] | [0, False, 0] | Passed |
| oracle 2 | [2, True, 0] | [2, True, 0] | Passed |
| oracle 3 | [3073, True, 128] | [25, True, 1] | Failed |
| oracle 4 | [6, True, 0] | [768, True, 32] | Failed |
| oracle 5 | [1, True, 0] | [1, True, 0] | Passed |
| oracle 6 | [1, True, 0] | [1, True, 0] | Passed |
| oracle 7 | [2306, True, 96] | [20, True, 0] | Failed |
SHA-256 / e9c390c10fdae83db2c9416aa1fc4d8a2b398c30ea129bf9d0b03b9513a37bfa
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
if not isinstance(x, list):
return None
pos = 0
running = False
for msg in x:
kind = msg[0]
if kind == 'start':
pos = 0
running = True
elif kind == 'continue':
running = True
elif kind == 'stop':
running = False
elif kind == 'clock':
if running:
pos += 1
elif kind == 'spp':
if not running:
pos = 6 * ((msg[2] << 8) | msg[1])
else:
return None
return [pos, running, pos // 24]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([['start'], ['clock'], ['clock']], [2, True, 0]), ([['clock'], ['clock']], [0, False, 0]), ([['start'], ['clock'], ['stop'], ['clock'], ['continue'], ['clock']], [2, True, 0]), ([['spp', 4, 0], ['continue'], ['clock']], [25, True, 1]), ([['spp', 0, 1], ['continue']], [768, True, 32]), ([['start'], ['spp', 8, 0], ['clock']], [1, True, 0]), ([['start'], ['clock'], ['stop'], ['start'], ['clock']], [1, True, 0]), ([['stop'], ['spp', 3, 0], ['continue'], ['clock'], ['clock']], [20, True, 0])], [([['spp', 0, 1], ['continue']], [768, True, 32]), ([['spp', 1, 1]], [774, False, 32]), ([['start'], ['spp', 8, 0], ['clock']], [1, True, 0]), ([['start'], ['clock'], ['stop'], ['start'], ['clock']], [1, True, 0]), ([['spp', 16, 0], ['start']], [0, True, 0]), ([['reset']], None), ([], [0, False, 0]), ([['spp', 4, 0], ['continue'], ['stop'], ['continue'], ['clock']], [25, True, 1])], [([['stop'], ['spp', 3, 0], ['continue'], ['clock'], ['clock']], [20, True, 0]), ([['reset']], None), ([], [0, False, 0]), ([['start'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock']], [25, True, 1]), ([['spp', 127, 127]], [98298, False, 4095]), ([['start'], ['clock'], ['clock'], ['stop'], ['spp', 2, 0], ['continue'], ['clock']], [13, True, 0]), ([['continue'], ['clock']], [1, True, 0]), ([['start'], ['stop'], ['continue'], ['clock']], [1, True, 0])], [([['spp', 4, 0], ['continue'], ['clock']], [25, True, 1]), ([['spp', 0, 1], ['continue']], [768, True, 32]), ([['spp', 1, 1]], [774, False, 32]), ([['stop'], ['spp', 3, 0], ['continue'], ['clock'], ['clock']], [20, True, 0]), ([['spp', 127, 127]], [98298, False, 4095]), ([['spp', 4, 0], ['continue'], ['stop'], ['continue'], ['clock']], [25, True, 1]), ([['continue'], ['clock']], [1, True, 0]), ([['start'], ['stop'], ['continue'], ['clock']], [1, True, 0])], [([['start'], ['clock'], ['clock']], [2, True, 0]), ([['clock'], ['clock']], [0, False, 0]), ([['spp', 0, 1], ['continue']], [768, True, 32]), ([['spp', 1, 1]], [774, False, 32]), ([['stop'], ['spp', 3, 0], ['continue'], ['clock'], ['clock']], [20, True, 0]), ([['spp', 127, 127]], [98298, False, 4095]), ([['spp', 4, 0], ['continue'], ['stop'], ['continue'], ['clock']], [25, True, 1]), ([['start'], ['clock'], ['clock'], ['stop'], ['spp', 2, 0], ['continue'], ['clock']], [13, True, 0])]]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("oracle %d" % i, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| oracle 0 | [2, True, 0] | [2, True, 0] | Passed |
| oracle 1 | [0, False, 0] | [0, False, 0] | Passed |
| oracle 2 | [2, True, 0] | [2, True, 0] | Passed |
| oracle 3 | [25, True, 1] | [25, True, 1] | Passed |
| oracle 4 | [1536, True, 64] | [768, True, 32] | Failed |
| oracle 5 | [1, True, 0] | [1, True, 0] | Passed |
| oracle 6 | [1, True, 0] | [1, True, 0] | Passed |
| oracle 7 | [20, True, 0] | [20, True, 0] | Passed |
SHA-256 / 4ee56232162edd17ca7237b77757ccaf6b4097edbbdc4704697e925c9989318c
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
if not isinstance(x, list):
return None
pos = 0
running = False
for msg in x:
kind = msg[0]
if kind == 'start':
pos = 0
running = True
elif kind == 'continue':
running = True
elif kind == 'stop':
running = False
elif kind == 'clock':
if running:
pos += 1
elif kind == 'spp':
if not running:
pos = 6 * ((msg[2] << 7) | msg[1])
else:
return None
return [pos, running, pos // 24]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([['start'], ['clock'], ['clock']], [2, True, 0]), ([['clock'], ['clock']], [0, False, 0]), ([['start'], ['clock'], ['stop'], ['clock'], ['continue'], ['clock']], [2, True, 0]), ([['spp', 4, 0], ['continue'], ['clock']], [25, True, 1]), ([['spp', 0, 1], ['continue']], [768, True, 32]), ([['start'], ['spp', 8, 0], ['clock']], [1, True, 0]), ([['start'], ['clock'], ['stop'], ['start'], ['clock']], [1, True, 0]), ([['stop'], ['spp', 3, 0], ['continue'], ['clock'], ['clock']], [20, True, 0])], [([['spp', 0, 1], ['continue']], [768, True, 32]), ([['spp', 1, 1]], [774, False, 32]), ([['start'], ['spp', 8, 0], ['clock']], [1, True, 0]), ([['start'], ['clock'], ['stop'], ['start'], ['clock']], [1, True, 0]), ([['spp', 16, 0], ['start']], [0, True, 0]), ([['reset']], None), ([], [0, False, 0]), ([['spp', 4, 0], ['continue'], ['stop'], ['continue'], ['clock']], [25, True, 1])], [([['stop'], ['spp', 3, 0], ['continue'], ['clock'], ['clock']], [20, True, 0]), ([['reset']], None), ([], [0, False, 0]), ([['start'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock'], ['clock']], [25, True, 1]), ([['spp', 127, 127]], [98298, False, 4095]), ([['start'], ['clock'], ['clock'], ['stop'], ['spp', 2, 0], ['continue'], ['clock']], [13, True, 0]), ([['continue'], ['clock']], [1, True, 0]), ([['start'], ['stop'], ['continue'], ['clock']], [1, True, 0])], [([['spp', 4, 0], ['continue'], ['clock']], [25, True, 1]), ([['spp', 0, 1], ['continue']], [768, True, 32]), ([['spp', 1, 1]], [774, False, 32]), ([['stop'], ['spp', 3, 0], ['continue'], ['clock'], ['clock']], [20, True, 0]), ([['spp', 127, 127]], [98298, False, 4095]), ([['spp', 4, 0], ['continue'], ['stop'], ['continue'], ['clock']], [25, True, 1]), ([['continue'], ['clock']], [1, True, 0]), ([['start'], ['stop'], ['continue'], ['clock']], [1, True, 0])], [([['start'], ['clock'], ['clock']], [2, True, 0]), ([['clock'], ['clock']], [0, False, 0]), ([['spp', 0, 1], ['continue']], [768, True, 32]), ([['spp', 1, 1]], [774, False, 32]), ([['stop'], ['spp', 3, 0], ['continue'], ['clock'], ['clock']], [20, True, 0]), ([['spp', 127, 127]], [98298, False, 4095]), ([['spp', 4, 0], ['continue'], ['stop'], ['continue'], ['clock']], [25, True, 1]), ([['start'], ['clock'], ['clock'], ['stop'], ['spp', 2, 0], ['continue'], ['clock']], [13, True, 0])]]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("oracle %d" % i, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| oracle 0 | [2, True, 0] | [2, True, 0] | Passed |
| oracle 1 | [0, False, 0] | [0, False, 0] | Passed |
| oracle 2 | [2, True, 0] | [2, True, 0] | Passed |
| oracle 3 | [25, True, 1] | [25, True, 1] | Passed |
| oracle 4 | [768, True, 32] | [768, True, 32] | Passed |
| oracle 5 | [1, True, 0] | [1, True, 0] | Passed |
| oracle 6 | [1, True, 0] | [1, True, 0] | Passed |
| oracle 7 | [20, True, 0] | [20, True, 0] | Passed |
SHA-256 / c276e113a1536e10b53abd5072de26d28cc48c9f368cf749571eb24efbc57fe1
Verification & scope
A deterministic bounded teaching model with a stipulated toy contract; it is not a complete Standard MIDI File or MIDI 1.0/2.0 implementation. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:50:04.397694+00:00.
Case digest / 3e1ca5464cc8c03e4287632173c6bebc83a31ccf52ed4346dc93b51ad536d93a