FA-81816 / MIDI event timing / Open access
MIDI Time Code quarter-frame assembly: two-frame assembly latency not compensated · case 01
Every decoded position is two frames behind the time at which the last quarter frame arrived.
ROOT CAUSE
The two-frame delay inherent in assembling eight quarter frames is not added.
VERIFIED REPAIR
Restore the transmission latency step so that it reads `frames += 2`.
Unsuccessful approach: Adding a single frame compensates only half of the assembly latency.
Case contract
Input the data bytes of received quarter-frame messages. The last eight must carry piece numbers 0..7 (high nibble) in order; low nibbles give frames (pieces 0,1 as low/high nibble), seconds (2,3), minutes (4,5) and hours (6 low nibble, piece 7 bit 0 as hours bit 4); piece 7 bits 1-2 give the rate code (0: 24, 1: 25, 2: 30 drop, 3: 30 fps). The reported time is the decoded time plus 2 frames, carried into seconds, minutes and hours (mod 24). Return [h, m, s, f, rate_code] or 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) or len(x) < 8:
return None
last8 = x[-8:]
if [b >> 4 for b in last8] != list(range(8)):
return None
nib = [b & 0x0F for b in last8]
frames = nib[0] | (nib[1] << 4)
secs = nib[2] | (nib[3] << 4)
mins = nib[4] | (nib[5] << 4)
hours = nib[6] | ((nib[7] & 0x1) << 4)
rate = (nib[7] >> 1) & 0x3
fps = [24, 25, 30, 30][rate]
secs += frames // fps
frames %= fps
mins += secs // 60
secs %= 60
hours = (hours + mins // 60) % 24
mins %= 60
return [hours, mins, secs, frames, rate]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([0, 16, 32, 48, 64, 80, 96, 112], [0, 0, 0, 2, 0]), ([5, 17, 32, 48, 64, 80, 96, 114], [0, 0, 0, 23, 1]), ([4, 16, 35, 48, 66, 80, 97, 114], [1, 2, 3, 6, 1]), ([10, 16, 47, 48, 78, 81, 97, 117], [17, 30, 15, 12, 2]), ([0, 16, 32, 48, 64, 80, 100, 119], [20, 0, 0, 2, 3]), ([7, 17, 43, 51, 75, 83, 103, 113], [0, 0, 0, 1, 0]), ([0, 16, 32, 48, 64, 80, 96], None), ([16, 32, 48, 64, 80, 96, 112, 0], None)], [([5, 17, 32, 48, 64, 80, 96, 114], [0, 0, 0, 23, 1]), ([4, 16, 35, 48, 66, 80, 97, 114], [1, 2, 3, 6, 1]), ([10, 16, 47, 48, 78, 81, 97, 117], [17, 30, 15, 12, 2]), ([0, 16, 32, 48, 64, 80, 100, 119], [20, 0, 0, 2, 3]), ([7, 17, 43, 51, 75, 83, 103, 113], [0, 0, 0, 1, 0]), ([12, 17, 43, 51, 75, 83, 103, 119], [0, 0, 0, 0, 3]), ([8, 17, 43, 51, 75, 83, 97, 114], [2, 0, 0, 1, 1]), ([7, 16, 38, 48, 69, 80, 96, 115], [16, 5, 6, 9, 1])], [([4, 16, 35, 48, 66, 80, 97, 114], [1, 2, 3, 6, 1]), ([0, 16, 32, 48, 64, 80, 100, 119], [20, 0, 0, 2, 3]), ([7, 17, 43, 51, 75, 83, 103, 113], [0, 0, 0, 1, 0]), ([12, 17, 43, 51, 75, 83, 103, 119], [0, 0, 0, 0, 3]), ([8, 17, 43, 51, 75, 83, 97, 114], [2, 0, 0, 1, 1]), ([7, 16, 38, 48, 69, 80, 96, 115], [16, 5, 6, 9, 1]), ([13, 17, 43, 51, 64, 80, 99, 117], [19, 1, 0, 1, 2]), ([6, 17, 43, 51, 75, 83, 102, 113], [23, 0, 0, 0, 0])], [([10, 16, 47, 48, 78, 81, 97, 117], [17, 30, 15, 12, 2]), ([7, 17, 43, 51, 75, 83, 103, 113], [0, 0, 0, 1, 0]), ([12, 17, 43, 51, 75, 83, 103, 119], [0, 0, 0, 0, 3]), ([8, 17, 43, 51, 75, 83, 97, 114], [2, 0, 0, 1, 1]), ([7, 16, 38, 48, 69, 80, 96, 115], [16, 5, 6, 9, 1]), ([13, 17, 43, 51, 64, 80, 99, 117], [19, 1, 0, 1, 2]), ([6, 17, 43, 51, 75, 83, 102, 113], [23, 0, 0, 0, 0]), ([4, 17, 40, 51, 66, 82, 108, 118], [12, 34, 56, 22, 3])], [([0, 16, 32, 48, 64, 80, 100, 119], [20, 0, 0, 2, 3]), ([12, 17, 43, 51, 75, 83, 103, 119], [0, 0, 0, 0, 3]), ([8, 17, 43, 51, 75, 83, 97, 114], [2, 0, 0, 1, 1]), ([6, 17, 43, 51, 75, 83, 102, 113], [23, 0, 0, 0, 0]), ([4, 17, 40, 51, 66, 82, 108, 118], [12, 34, 56, 22, 3]), ([3, 0, 16, 32, 48, 64, 80, 98, 112], [2, 0, 0, 2, 0]), ([8, 17, 43, 51, 75, 83, 103, 115], [0, 0, 0, 1, 1]), ([9, 16, 41, 48, 73, 80, 105, 112], [9, 9, 9, 11, 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 | [0, 0, 0, 0, 0] | [0, 0, 0, 2, 0] | Failed |
| oracle 1 | [0, 0, 0, 21, 1] | [0, 0, 0, 23, 1] | Failed |
| oracle 2 | [1, 2, 3, 4, 1] | [1, 2, 3, 6, 1] | Failed |
| oracle 3 | [17, 30, 15, 10, 2] | [17, 30, 15, 12, 2] | Failed |
| oracle 4 | [20, 0, 0, 0, 3] | [20, 0, 0, 2, 3] | Failed |
| oracle 5 | [23, 59, 59, 23, 0] | [0, 0, 0, 1, 0] | Failed |
| oracle 6 | None | None | Passed |
| oracle 7 | None | None | Passed |
SHA-256 / 167bcec7084ac89da250c0ea41b011370246d263fea3e0882d2c970653d1bf5b
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) or len(x) < 8:
return None
last8 = x[-8:]
if [b >> 4 for b in last8] != list(range(8)):
return None
nib = [b & 0x0F for b in last8]
frames = nib[0] | (nib[1] << 4)
secs = nib[2] | (nib[3] << 4)
mins = nib[4] | (nib[5] << 4)
hours = nib[6] | ((nib[7] & 0x1) << 4)
rate = (nib[7] >> 1) & 0x3
fps = [24, 25, 30, 30][rate]
frames += 1
secs += frames // fps
frames %= fps
mins += secs // 60
secs %= 60
hours = (hours + mins // 60) % 24
mins %= 60
return [hours, mins, secs, frames, rate]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([0, 16, 32, 48, 64, 80, 96, 112], [0, 0, 0, 2, 0]), ([5, 17, 32, 48, 64, 80, 96, 114], [0, 0, 0, 23, 1]), ([4, 16, 35, 48, 66, 80, 97, 114], [1, 2, 3, 6, 1]), ([10, 16, 47, 48, 78, 81, 97, 117], [17, 30, 15, 12, 2]), ([0, 16, 32, 48, 64, 80, 100, 119], [20, 0, 0, 2, 3]), ([7, 17, 43, 51, 75, 83, 103, 113], [0, 0, 0, 1, 0]), ([0, 16, 32, 48, 64, 80, 96], None), ([16, 32, 48, 64, 80, 96, 112, 0], None)], [([5, 17, 32, 48, 64, 80, 96, 114], [0, 0, 0, 23, 1]), ([4, 16, 35, 48, 66, 80, 97, 114], [1, 2, 3, 6, 1]), ([10, 16, 47, 48, 78, 81, 97, 117], [17, 30, 15, 12, 2]), ([0, 16, 32, 48, 64, 80, 100, 119], [20, 0, 0, 2, 3]), ([7, 17, 43, 51, 75, 83, 103, 113], [0, 0, 0, 1, 0]), ([12, 17, 43, 51, 75, 83, 103, 119], [0, 0, 0, 0, 3]), ([8, 17, 43, 51, 75, 83, 97, 114], [2, 0, 0, 1, 1]), ([7, 16, 38, 48, 69, 80, 96, 115], [16, 5, 6, 9, 1])], [([4, 16, 35, 48, 66, 80, 97, 114], [1, 2, 3, 6, 1]), ([0, 16, 32, 48, 64, 80, 100, 119], [20, 0, 0, 2, 3]), ([7, 17, 43, 51, 75, 83, 103, 113], [0, 0, 0, 1, 0]), ([12, 17, 43, 51, 75, 83, 103, 119], [0, 0, 0, 0, 3]), ([8, 17, 43, 51, 75, 83, 97, 114], [2, 0, 0, 1, 1]), ([7, 16, 38, 48, 69, 80, 96, 115], [16, 5, 6, 9, 1]), ([13, 17, 43, 51, 64, 80, 99, 117], [19, 1, 0, 1, 2]), ([6, 17, 43, 51, 75, 83, 102, 113], [23, 0, 0, 0, 0])], [([10, 16, 47, 48, 78, 81, 97, 117], [17, 30, 15, 12, 2]), ([7, 17, 43, 51, 75, 83, 103, 113], [0, 0, 0, 1, 0]), ([12, 17, 43, 51, 75, 83, 103, 119], [0, 0, 0, 0, 3]), ([8, 17, 43, 51, 75, 83, 97, 114], [2, 0, 0, 1, 1]), ([7, 16, 38, 48, 69, 80, 96, 115], [16, 5, 6, 9, 1]), ([13, 17, 43, 51, 64, 80, 99, 117], [19, 1, 0, 1, 2]), ([6, 17, 43, 51, 75, 83, 102, 113], [23, 0, 0, 0, 0]), ([4, 17, 40, 51, 66, 82, 108, 118], [12, 34, 56, 22, 3])], [([0, 16, 32, 48, 64, 80, 100, 119], [20, 0, 0, 2, 3]), ([12, 17, 43, 51, 75, 83, 103, 119], [0, 0, 0, 0, 3]), ([8, 17, 43, 51, 75, 83, 97, 114], [2, 0, 0, 1, 1]), ([6, 17, 43, 51, 75, 83, 102, 113], [23, 0, 0, 0, 0]), ([4, 17, 40, 51, 66, 82, 108, 118], [12, 34, 56, 22, 3]), ([3, 0, 16, 32, 48, 64, 80, 98, 112], [2, 0, 0, 2, 0]), ([8, 17, 43, 51, 75, 83, 103, 115], [0, 0, 0, 1, 1]), ([9, 16, 41, 48, 73, 80, 105, 112], [9, 9, 9, 11, 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 | [0, 0, 0, 1, 0] | [0, 0, 0, 2, 0] | Failed |
| oracle 1 | [0, 0, 0, 22, 1] | [0, 0, 0, 23, 1] | Failed |
| oracle 2 | [1, 2, 3, 5, 1] | [1, 2, 3, 6, 1] | Failed |
| oracle 3 | [17, 30, 15, 11, 2] | [17, 30, 15, 12, 2] | Failed |
| oracle 4 | [20, 0, 0, 1, 3] | [20, 0, 0, 2, 3] | Failed |
| oracle 5 | [0, 0, 0, 0, 0] | [0, 0, 0, 1, 0] | Failed |
| oracle 6 | None | None | Passed |
| oracle 7 | None | None | Passed |
SHA-256 / 417e85751c106e4fff1854c0d6beba91e9b80546740b74ec4d49e89532624494
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) or len(x) < 8:
return None
last8 = x[-8:]
if [b >> 4 for b in last8] != list(range(8)):
return None
nib = [b & 0x0F for b in last8]
frames = nib[0] | (nib[1] << 4)
secs = nib[2] | (nib[3] << 4)
mins = nib[4] | (nib[5] << 4)
hours = nib[6] | ((nib[7] & 0x1) << 4)
rate = (nib[7] >> 1) & 0x3
fps = [24, 25, 30, 30][rate]
frames += 2
secs += frames // fps
frames %= fps
mins += secs // 60
secs %= 60
hours = (hours + mins // 60) % 24
mins %= 60
return [hours, mins, secs, frames, rate]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([0, 16, 32, 48, 64, 80, 96, 112], [0, 0, 0, 2, 0]), ([5, 17, 32, 48, 64, 80, 96, 114], [0, 0, 0, 23, 1]), ([4, 16, 35, 48, 66, 80, 97, 114], [1, 2, 3, 6, 1]), ([10, 16, 47, 48, 78, 81, 97, 117], [17, 30, 15, 12, 2]), ([0, 16, 32, 48, 64, 80, 100, 119], [20, 0, 0, 2, 3]), ([7, 17, 43, 51, 75, 83, 103, 113], [0, 0, 0, 1, 0]), ([0, 16, 32, 48, 64, 80, 96], None), ([16, 32, 48, 64, 80, 96, 112, 0], None)], [([5, 17, 32, 48, 64, 80, 96, 114], [0, 0, 0, 23, 1]), ([4, 16, 35, 48, 66, 80, 97, 114], [1, 2, 3, 6, 1]), ([10, 16, 47, 48, 78, 81, 97, 117], [17, 30, 15, 12, 2]), ([0, 16, 32, 48, 64, 80, 100, 119], [20, 0, 0, 2, 3]), ([7, 17, 43, 51, 75, 83, 103, 113], [0, 0, 0, 1, 0]), ([12, 17, 43, 51, 75, 83, 103, 119], [0, 0, 0, 0, 3]), ([8, 17, 43, 51, 75, 83, 97, 114], [2, 0, 0, 1, 1]), ([7, 16, 38, 48, 69, 80, 96, 115], [16, 5, 6, 9, 1])], [([4, 16, 35, 48, 66, 80, 97, 114], [1, 2, 3, 6, 1]), ([0, 16, 32, 48, 64, 80, 100, 119], [20, 0, 0, 2, 3]), ([7, 17, 43, 51, 75, 83, 103, 113], [0, 0, 0, 1, 0]), ([12, 17, 43, 51, 75, 83, 103, 119], [0, 0, 0, 0, 3]), ([8, 17, 43, 51, 75, 83, 97, 114], [2, 0, 0, 1, 1]), ([7, 16, 38, 48, 69, 80, 96, 115], [16, 5, 6, 9, 1]), ([13, 17, 43, 51, 64, 80, 99, 117], [19, 1, 0, 1, 2]), ([6, 17, 43, 51, 75, 83, 102, 113], [23, 0, 0, 0, 0])], [([10, 16, 47, 48, 78, 81, 97, 117], [17, 30, 15, 12, 2]), ([7, 17, 43, 51, 75, 83, 103, 113], [0, 0, 0, 1, 0]), ([12, 17, 43, 51, 75, 83, 103, 119], [0, 0, 0, 0, 3]), ([8, 17, 43, 51, 75, 83, 97, 114], [2, 0, 0, 1, 1]), ([7, 16, 38, 48, 69, 80, 96, 115], [16, 5, 6, 9, 1]), ([13, 17, 43, 51, 64, 80, 99, 117], [19, 1, 0, 1, 2]), ([6, 17, 43, 51, 75, 83, 102, 113], [23, 0, 0, 0, 0]), ([4, 17, 40, 51, 66, 82, 108, 118], [12, 34, 56, 22, 3])], [([0, 16, 32, 48, 64, 80, 100, 119], [20, 0, 0, 2, 3]), ([12, 17, 43, 51, 75, 83, 103, 119], [0, 0, 0, 0, 3]), ([8, 17, 43, 51, 75, 83, 97, 114], [2, 0, 0, 1, 1]), ([6, 17, 43, 51, 75, 83, 102, 113], [23, 0, 0, 0, 0]), ([4, 17, 40, 51, 66, 82, 108, 118], [12, 34, 56, 22, 3]), ([3, 0, 16, 32, 48, 64, 80, 98, 112], [2, 0, 0, 2, 0]), ([8, 17, 43, 51, 75, 83, 103, 115], [0, 0, 0, 1, 1]), ([9, 16, 41, 48, 73, 80, 105, 112], [9, 9, 9, 11, 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 | [0, 0, 0, 2, 0] | [0, 0, 0, 2, 0] | Passed |
| oracle 1 | [0, 0, 0, 23, 1] | [0, 0, 0, 23, 1] | Passed |
| oracle 2 | [1, 2, 3, 6, 1] | [1, 2, 3, 6, 1] | Passed |
| oracle 3 | [17, 30, 15, 12, 2] | [17, 30, 15, 12, 2] | Passed |
| oracle 4 | [20, 0, 0, 2, 3] | [20, 0, 0, 2, 3] | Passed |
| oracle 5 | [0, 0, 0, 1, 0] | [0, 0, 0, 1, 0] | Passed |
| oracle 6 | None | None | Passed |
| oracle 7 | None | None | Passed |
SHA-256 / 2371afe953693f3c332c00021ed70bfb0a37cc6964b333365bb819dc75accde2
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:06.385880+00:00.
Case digest / c7b06e49ba4c218be6536237857b1d5de51a7a2f82602c39c543db0eae66be5a