FAILURE MAP
← Case archive

FA-81801 / MIDI event timing / Open access

MIDI Time Code quarter-frame assembly: frame count nibbles swapped · case 01

Frame 21 (pieces 5 and 1) decodes as frame 81, which carries into several extra seconds.

Verified by executionVariant 1 · 8 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The frame count treats piece 0 as the high nibble and piece 1 as the low nibble.

THE FAILURE

The frame count treats piece 0 as the high nibble and piece 1 as the low nibble.

Unsuccessful approach: Shifting the high nibble by three overlaps the two nibbles.

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] << 4) | nib[1]
    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]), ([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]), ([8, 17, 43, 51, 75, 83, 97, 114], [2, 0, 0, 1, 1]), ([0, 16, 32, 48, 64, 80, 96], None), ([16, 32, 48, 64, 80, 96, 112, 0], None), ([3, 0, 16, 32, 48, 64, 80, 98, 112], [2, 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]), ([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]), ([13, 17, 43, 51, 64, 80, 99, 117], [19, 1, 0, 1, 2]), ([16, 32, 48, 64, 80, 96, 112, 0], None), ([3, 0, 16, 32, 48, 64, 80, 98, 112], [2, 0, 0, 2, 0])], [([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]), ([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])], [([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]), ([8, 17, 43, 51, 75, 83, 103, 115], [0, 0, 0, 1, 1])], [([0, 16, 32, 48, 64, 80, 96, 112], [0, 0, 0, 2, 0]), ([12, 17, 43, 51, 75, 83, 103, 119], [0, 0, 0, 0, 3]), ([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]), ([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 fixtureActualExpectedOutcome
oracle 0[0, 0, 0, 2, 0][0, 0, 0, 2, 0]Passed
oracle 1[0, 0, 3, 8, 1][0, 0, 0, 23, 1]Failed
oracle 2[17, 30, 20, 12, 2][17, 30, 15, 12, 2]Failed
oracle 3[20, 0, 0, 2, 3][20, 0, 0, 2, 3]Passed
oracle 4[2, 0, 4, 6, 1][2, 0, 0, 1, 1]Failed
oracle 5NoneNonePassed
oracle 6NoneNonePassed
oracle 7[2, 0, 0, 2, 0][2, 0, 0, 2, 0]Passed

SHA-256 / f30a2f653d7c39be22fec40db7789a07d4fc229cf1dc9c4da37ee44f9c0bb2a0

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] << 3)
    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]), ([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]), ([8, 17, 43, 51, 75, 83, 97, 114], [2, 0, 0, 1, 1]), ([0, 16, 32, 48, 64, 80, 96], None), ([16, 32, 48, 64, 80, 96, 112, 0], None), ([3, 0, 16, 32, 48, 64, 80, 98, 112], [2, 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]), ([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]), ([13, 17, 43, 51, 64, 80, 99, 117], [19, 1, 0, 1, 2]), ([16, 32, 48, 64, 80, 96, 112, 0], None), ([3, 0, 16, 32, 48, 64, 80, 98, 112], [2, 0, 0, 2, 0])], [([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]), ([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])], [([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]), ([8, 17, 43, 51, 75, 83, 103, 115], [0, 0, 0, 1, 1])], [([0, 16, 32, 48, 64, 80, 96, 112], [0, 0, 0, 2, 0]), ([12, 17, 43, 51, 75, 83, 103, 119], [0, 0, 0, 0, 3]), ([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]), ([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 fixtureActualExpectedOutcome
oracle 0[0, 0, 0, 2, 0][0, 0, 0, 2, 0]Passed
oracle 1[0, 0, 0, 15, 1][0, 0, 0, 23, 1]Failed
oracle 2[17, 30, 15, 12, 2][17, 30, 15, 12, 2]Passed
oracle 3[20, 0, 0, 2, 3][20, 0, 0, 2, 3]Passed
oracle 4[1, 59, 59, 10, 1][2, 0, 0, 1, 1]Failed
oracle 5NoneNonePassed
oracle 6NoneNonePassed
oracle 7[2, 0, 0, 2, 0][2, 0, 0, 2, 0]Passed

SHA-256 / 5f007539667391805674f29fe0f7d20d41e36c0393e49c1e52c8d19cf8591b7b

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 8 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

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.349222+00:00.

Case digest / 029748569570ccca0bf98b1741bc6ef6259770391b61a0ab3aa6c61be6e9301b