FA-81596 / MIDI event timing / Open access
MIDI clock transport and song position: start resumes from the old position · case 01
Start after playback resumes counting from the previous position instead of from 0.
ROOT CAUSE
The start handler sets the running flag but does not rewind.
VERIFIED REPAIR
Restore the start resets position step so that it reads `if kind == 'start': pos = 0 running = True`.
Unsuccessful approach: Rewinding without setting the running flag leaves the transport stopped after start.
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':
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]), ([['spp', 4, 0], ['continue'], ['clock']], [25, True, 1]), ([['spp', 0, 1], ['continue']], [768, True, 32]), ([['spp', 1, 1]], [774, False, 32]), ([['start'], ['clock'], ['stop'], ['start'], ['clock']], [1, True, 0]), ([['stop'], ['spp', 3, 0], ['continue'], ['clock'], ['clock']], [20, True, 0]), ([['reset']], None)], [([['start'], ['clock'], ['stop'], ['clock'], ['continue'], ['clock']], [2, True, 0]), ([['spp', 1, 1]], [774, False, 32]), ([['spp', 16, 0], ['start']], [0, True, 0]), ([['stop'], ['spp', 3, 0], ['continue'], ['clock'], ['clock']], [20, True, 0]), ([['reset']], None), ([], [0, False, 0]), ([['spp', 127, 127]], [98298, False, 4095]), ([['spp', 4, 0], ['continue'], ['stop'], ['continue'], ['clock']], [25, True, 1])], [([['start'], ['spp', 8, 0], ['clock']], [1, True, 0]), ([['start'], ['clock'], ['stop'], ['start'], ['clock']], [1, True, 0]), ([], [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]), ([['spp', 4, 0], ['continue'], ['stop'], ['continue'], ['clock']], [25, True, 1]), ([['start'], ['clock'], ['clock'], ['stop'], ['spp', 2, 0], ['continue'], ['clock']], [13, True, 0]), ([['continue'], ['clock']], [1, True, 0])], [([['start'], ['clock'], ['clock']], [2, True, 0]), ([['start'], ['clock'], ['stop'], ['clock'], ['continue'], ['clock']], [2, True, 0]), ([['start'], ['spp', 8, 0], ['clock']], [1, True, 0]), ([['start'], ['clock'], ['stop'], ['start'], ['clock']], [1, True, 0]), ([['spp', 16, 0], ['start']], [0, True, 0]), ([['start'], ['clock'], ['clock'], ['stop'], ['spp', 2, 0], ['continue'], ['clock']], [13, True, 0]), ([['continue'], ['clock']], [1, True, 0]), ([['start'], ['stop'], ['continue'], ['clock']], [1, True, 0])], [([['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]), ([['start'], ['spp', 8, 0], ['clock']], [1, True, 0]), ([['start'], ['clock'], ['stop'], ['start'], ['clock']], [1, True, 0]), ([['spp', 16, 0], ['start']], [0, True, 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])]]
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 | [25, True, 1] | [25, True, 1] | Passed |
| oracle 3 | [768, True, 32] | [768, True, 32] | Passed |
| oracle 4 | [774, False, 32] | [774, False, 32] | Passed |
| oracle 5 | [2, True, 0] | [1, True, 0] | Failed |
| oracle 6 | [20, True, 0] | [20, True, 0] | Passed |
| oracle 7 | None | None | Passed |
SHA-256 / 894b54c70d3d40f126a1a80431dda1e73f867bd589685048b922b2e037877a85
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
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]), ([['spp', 4, 0], ['continue'], ['clock']], [25, True, 1]), ([['spp', 0, 1], ['continue']], [768, True, 32]), ([['spp', 1, 1]], [774, False, 32]), ([['start'], ['clock'], ['stop'], ['start'], ['clock']], [1, True, 0]), ([['stop'], ['spp', 3, 0], ['continue'], ['clock'], ['clock']], [20, True, 0]), ([['reset']], None)], [([['start'], ['clock'], ['stop'], ['clock'], ['continue'], ['clock']], [2, True, 0]), ([['spp', 1, 1]], [774, False, 32]), ([['spp', 16, 0], ['start']], [0, True, 0]), ([['stop'], ['spp', 3, 0], ['continue'], ['clock'], ['clock']], [20, True, 0]), ([['reset']], None), ([], [0, False, 0]), ([['spp', 127, 127]], [98298, False, 4095]), ([['spp', 4, 0], ['continue'], ['stop'], ['continue'], ['clock']], [25, True, 1])], [([['start'], ['spp', 8, 0], ['clock']], [1, True, 0]), ([['start'], ['clock'], ['stop'], ['start'], ['clock']], [1, True, 0]), ([], [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]), ([['spp', 4, 0], ['continue'], ['stop'], ['continue'], ['clock']], [25, True, 1]), ([['start'], ['clock'], ['clock'], ['stop'], ['spp', 2, 0], ['continue'], ['clock']], [13, True, 0]), ([['continue'], ['clock']], [1, True, 0])], [([['start'], ['clock'], ['clock']], [2, True, 0]), ([['start'], ['clock'], ['stop'], ['clock'], ['continue'], ['clock']], [2, True, 0]), ([['start'], ['spp', 8, 0], ['clock']], [1, True, 0]), ([['start'], ['clock'], ['stop'], ['start'], ['clock']], [1, True, 0]), ([['spp', 16, 0], ['start']], [0, True, 0]), ([['start'], ['clock'], ['clock'], ['stop'], ['spp', 2, 0], ['continue'], ['clock']], [13, True, 0]), ([['continue'], ['clock']], [1, True, 0]), ([['start'], ['stop'], ['continue'], ['clock']], [1, True, 0])], [([['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]), ([['start'], ['spp', 8, 0], ['clock']], [1, True, 0]), ([['start'], ['clock'], ['stop'], ['start'], ['clock']], [1, True, 0]), ([['spp', 16, 0], ['start']], [0, True, 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])]]
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 | [0, False, 0] | [2, True, 0] | Failed |
| oracle 1 | [0, False, 0] | [0, False, 0] | Passed |
| oracle 2 | [25, True, 1] | [25, True, 1] | Passed |
| oracle 3 | [768, True, 32] | [768, True, 32] | Passed |
| oracle 4 | [774, False, 32] | [774, False, 32] | Passed |
| oracle 5 | [0, False, 0] | [1, True, 0] | Failed |
| oracle 6 | [20, True, 0] | [20, True, 0] | Passed |
| oracle 7 | None | None | Passed |
SHA-256 / f145b2e2414b4ec6e4a748903c86e63262a8dd9c19c3ad5ef09d07bdab226de3
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]), ([['spp', 4, 0], ['continue'], ['clock']], [25, True, 1]), ([['spp', 0, 1], ['continue']], [768, True, 32]), ([['spp', 1, 1]], [774, False, 32]), ([['start'], ['clock'], ['stop'], ['start'], ['clock']], [1, True, 0]), ([['stop'], ['spp', 3, 0], ['continue'], ['clock'], ['clock']], [20, True, 0]), ([['reset']], None)], [([['start'], ['clock'], ['stop'], ['clock'], ['continue'], ['clock']], [2, True, 0]), ([['spp', 1, 1]], [774, False, 32]), ([['spp', 16, 0], ['start']], [0, True, 0]), ([['stop'], ['spp', 3, 0], ['continue'], ['clock'], ['clock']], [20, True, 0]), ([['reset']], None), ([], [0, False, 0]), ([['spp', 127, 127]], [98298, False, 4095]), ([['spp', 4, 0], ['continue'], ['stop'], ['continue'], ['clock']], [25, True, 1])], [([['start'], ['spp', 8, 0], ['clock']], [1, True, 0]), ([['start'], ['clock'], ['stop'], ['start'], ['clock']], [1, True, 0]), ([], [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]), ([['spp', 4, 0], ['continue'], ['stop'], ['continue'], ['clock']], [25, True, 1]), ([['start'], ['clock'], ['clock'], ['stop'], ['spp', 2, 0], ['continue'], ['clock']], [13, True, 0]), ([['continue'], ['clock']], [1, True, 0])], [([['start'], ['clock'], ['clock']], [2, True, 0]), ([['start'], ['clock'], ['stop'], ['clock'], ['continue'], ['clock']], [2, True, 0]), ([['start'], ['spp', 8, 0], ['clock']], [1, True, 0]), ([['start'], ['clock'], ['stop'], ['start'], ['clock']], [1, True, 0]), ([['spp', 16, 0], ['start']], [0, True, 0]), ([['start'], ['clock'], ['clock'], ['stop'], ['spp', 2, 0], ['continue'], ['clock']], [13, True, 0]), ([['continue'], ['clock']], [1, True, 0]), ([['start'], ['stop'], ['continue'], ['clock']], [1, True, 0])], [([['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]), ([['start'], ['spp', 8, 0], ['clock']], [1, True, 0]), ([['start'], ['clock'], ['stop'], ['start'], ['clock']], [1, True, 0]), ([['spp', 16, 0], ['start']], [0, True, 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])]]
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 | [25, True, 1] | [25, True, 1] | Passed |
| oracle 3 | [768, True, 32] | [768, True, 32] | Passed |
| oracle 4 | [774, False, 32] | [774, False, 32] | Passed |
| oracle 5 | [1, True, 0] | [1, True, 0] | Passed |
| oracle 6 | [20, True, 0] | [20, True, 0] | Passed |
| oracle 7 | None | None | Passed |
SHA-256 / 6063e841c7c27816661af5adebd840d3640a0ab300213f95f6dee7388051d336
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.438126+00:00.
Case digest / 543425bbfb176d47414b53196fa6e4a94e982b507f25a9d642e76f4b032705a4