FAILURE MAP
← Case archive

FA-81836 / MIDI event timing / Open access

Event placement inside an audio render buffer: absolute sample position returned as offset · case 01

For any buffer after the first, events are given absolute sample positions far beyond the buffer size.

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

ROOT CAUSE

The offset is not made relative to the buffer start.

VERIFIED REPAIR

Restore the buffer-relative offset step so that it reads `out.append(pos - start)`.

Unsuccessful approach: Reducing modulo the buffer size only works when buffers start at multiples of their size.

Case contract

Input [sample_rate, buffer_start_sample, buffer_size, event_times_us]. Each event maps to sample position us*rate/1000000 rounded half up. Positions before the buffer start are "late", positions at or after start+size are "future", otherwise the offset within the buffer. Invalid rate or size returns 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) != 4:
        return None
    sr, start, size, events = x
    if sr <= 0 or size <= 0:
        return None
    out = []
    for us in events:
        pos = (2 * us * sr + 1000000) // 2000000
        if pos < start:
            out.append('late')
        elif pos >= start + size:
            out.append('future')
        else:
            out.append(pos)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([48000, 0, 256, [0, 1000, 5333, 5334]], [0, 48, 'future', 'future']), ([48000, 480, 256, [10000, 10010, 15332, 15333]], [0, 0, 'future', 'future']), ([44100, 441, 128, [10000, 10011, 12902, 12903]], [0, 0, 'future', 'future']), ([48000, 48000, 512, [1000000, 1010667, 1010656, 999990]], [0, 'future', 511, 0]), ([48000, 0, 64, [10, 11, 1333, 1343]], [0, 1, 'future', 'future']), ([48000, 0, 0, [0]], None), ([0, 0, 10, [0]], None), ([1000, 0, 4, [499, 500, 3499, 3500]], [0, 1, 3, 'future'])], [([48000, 480, 256, [10000, 10010, 15332, 15333]], [0, 0, 'future', 'future']), ([44100, 441, 128, [10000, 10011, 12902, 12903]], [0, 0, 'future', 'future']), ([48000, 48000, 512, [1000000, 1010667, 1010656, 999990]], [0, 'future', 511, 0]), ([1000, 10, 5, [9500, 10000, 14499, 14500]], [0, 0, 4, 'future']), ([44100, 1024, 256, [23220, 23232, 29025, 29037]], [0, 1, 'future', 'future']), ([8000, 100, 10, [12500, 12562, 13687, 13688]], [0, 0, 9, 'future']), ([0, 0, 10, [0]], None), ([1000, 0, 4, [499, 500, 3499, 3500]], [0, 1, 3, 'future'])], [([48000, 0, 256, [0, 1000, 5333, 5334]], [0, 48, 'future', 'future']), ([44100, 441, 128, [10000, 10011, 12902, 12903]], [0, 0, 'future', 'future']), ([48000, 48000, 512, [1000000, 1010667, 1010656, 999990]], [0, 'future', 511, 0]), ([1000, 10, 5, [9500, 10000, 14499, 14500]], [0, 0, 4, 'future']), ([48000, 0, 64, [10, 11, 1333, 1343]], [0, 1, 'future', 'future']), ([44100, 1024, 256, [23220, 23232, 29025, 29037]], [0, 1, 'future', 'future']), ([8000, 100, 10, [12500, 12562, 13687, 13688]], [0, 0, 9, 'future']), ([96000, 960, 96, [10000, 10005, 10995, 11000]], [0, 0, 'future', 'future'])], [([48000, 0, 256, [0, 1000, 5333, 5334]], [0, 48, 'future', 'future']), ([48000, 480, 256, [10000, 10010, 15332, 15333]], [0, 0, 'future', 'future']), ([1000, 10, 5, [9500, 10000, 14499, 14500]], [0, 0, 4, 'future']), ([48000, 0, 64, [10, 11, 1333, 1343]], [0, 1, 'future', 'future']), ([44100, 1024, 256, [23220, 23232, 29025, 29037]], [0, 1, 'future', 'future']), ([8000, 100, 10, [12500, 12562, 13687, 13688]], [0, 0, 9, 'future']), ([48000, 0, 0, [0]], None), ([96000, 960, 96, [10000, 10005, 10995, 11000]], [0, 0, 'future', 'future'])], [([48000, 0, 256, [0, 1000, 5333, 5334]], [0, 48, 'future', 'future']), ([44100, 441, 128, [10000, 10011, 12902, 12903]], [0, 0, 'future', 'future']), ([48000, 0, 64, [10, 11, 1333, 1343]], [0, 1, 'future', 'future']), ([44100, 1024, 256, [23220, 23232, 29025, 29037]], [0, 1, 'future', 'future']), ([48000, 0, 0, [0]], None), ([0, 0, 10, [0]], None), ([96000, 960, 96, [10000, 10005, 10995, 11000]], [0, 0, 'future', 'future']), ([1000, 0, 4, [499, 500, 3499, 3500]], [0, 1, 3, 'future'])]]
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, 48, 'future', 'future'][0, 48, 'future', 'future']Passed
oracle 1[480, 480, 'future', 'future'][0, 0, 'future', 'future']Failed
oracle 2[441, 441, 'future', 'future'][0, 0, 'future', 'future']Failed
oracle 3[48000, 'future', 48511, 48000][0, 'future', 511, 0]Failed
oracle 4[0, 1, 'future', 'future'][0, 1, 'future', 'future']Passed
oracle 5NoneNonePassed
oracle 6NoneNonePassed
oracle 7[0, 1, 3, 'future'][0, 1, 3, 'future']Passed

SHA-256 / 0d23918d744a51a93009d83f68209f59b7c5aec97844c145cdc4367886ca65ff

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) != 4:
        return None
    sr, start, size, events = x
    if sr <= 0 or size <= 0:
        return None
    out = []
    for us in events:
        pos = (2 * us * sr + 1000000) // 2000000
        if pos < start:
            out.append('late')
        elif pos >= start + size:
            out.append('future')
        else:
            out.append(pos % size)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([48000, 0, 256, [0, 1000, 5333, 5334]], [0, 48, 'future', 'future']), ([48000, 480, 256, [10000, 10010, 15332, 15333]], [0, 0, 'future', 'future']), ([44100, 441, 128, [10000, 10011, 12902, 12903]], [0, 0, 'future', 'future']), ([48000, 48000, 512, [1000000, 1010667, 1010656, 999990]], [0, 'future', 511, 0]), ([48000, 0, 64, [10, 11, 1333, 1343]], [0, 1, 'future', 'future']), ([48000, 0, 0, [0]], None), ([0, 0, 10, [0]], None), ([1000, 0, 4, [499, 500, 3499, 3500]], [0, 1, 3, 'future'])], [([48000, 480, 256, [10000, 10010, 15332, 15333]], [0, 0, 'future', 'future']), ([44100, 441, 128, [10000, 10011, 12902, 12903]], [0, 0, 'future', 'future']), ([48000, 48000, 512, [1000000, 1010667, 1010656, 999990]], [0, 'future', 511, 0]), ([1000, 10, 5, [9500, 10000, 14499, 14500]], [0, 0, 4, 'future']), ([44100, 1024, 256, [23220, 23232, 29025, 29037]], [0, 1, 'future', 'future']), ([8000, 100, 10, [12500, 12562, 13687, 13688]], [0, 0, 9, 'future']), ([0, 0, 10, [0]], None), ([1000, 0, 4, [499, 500, 3499, 3500]], [0, 1, 3, 'future'])], [([48000, 0, 256, [0, 1000, 5333, 5334]], [0, 48, 'future', 'future']), ([44100, 441, 128, [10000, 10011, 12902, 12903]], [0, 0, 'future', 'future']), ([48000, 48000, 512, [1000000, 1010667, 1010656, 999990]], [0, 'future', 511, 0]), ([1000, 10, 5, [9500, 10000, 14499, 14500]], [0, 0, 4, 'future']), ([48000, 0, 64, [10, 11, 1333, 1343]], [0, 1, 'future', 'future']), ([44100, 1024, 256, [23220, 23232, 29025, 29037]], [0, 1, 'future', 'future']), ([8000, 100, 10, [12500, 12562, 13687, 13688]], [0, 0, 9, 'future']), ([96000, 960, 96, [10000, 10005, 10995, 11000]], [0, 0, 'future', 'future'])], [([48000, 0, 256, [0, 1000, 5333, 5334]], [0, 48, 'future', 'future']), ([48000, 480, 256, [10000, 10010, 15332, 15333]], [0, 0, 'future', 'future']), ([1000, 10, 5, [9500, 10000, 14499, 14500]], [0, 0, 4, 'future']), ([48000, 0, 64, [10, 11, 1333, 1343]], [0, 1, 'future', 'future']), ([44100, 1024, 256, [23220, 23232, 29025, 29037]], [0, 1, 'future', 'future']), ([8000, 100, 10, [12500, 12562, 13687, 13688]], [0, 0, 9, 'future']), ([48000, 0, 0, [0]], None), ([96000, 960, 96, [10000, 10005, 10995, 11000]], [0, 0, 'future', 'future'])], [([48000, 0, 256, [0, 1000, 5333, 5334]], [0, 48, 'future', 'future']), ([44100, 441, 128, [10000, 10011, 12902, 12903]], [0, 0, 'future', 'future']), ([48000, 0, 64, [10, 11, 1333, 1343]], [0, 1, 'future', 'future']), ([44100, 1024, 256, [23220, 23232, 29025, 29037]], [0, 1, 'future', 'future']), ([48000, 0, 0, [0]], None), ([0, 0, 10, [0]], None), ([96000, 960, 96, [10000, 10005, 10995, 11000]], [0, 0, 'future', 'future']), ([1000, 0, 4, [499, 500, 3499, 3500]], [0, 1, 3, 'future'])]]
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, 48, 'future', 'future'][0, 48, 'future', 'future']Passed
oracle 1[224, 224, 'future', 'future'][0, 0, 'future', 'future']Failed
oracle 2[57, 57, 'future', 'future'][0, 0, 'future', 'future']Failed
oracle 3[384, 'future', 383, 384][0, 'future', 511, 0]Failed
oracle 4[0, 1, 'future', 'future'][0, 1, 'future', 'future']Passed
oracle 5NoneNonePassed
oracle 6NoneNonePassed
oracle 7[0, 1, 3, 'future'][0, 1, 3, 'future']Passed

SHA-256 / 0f18deec2dd52500608fe598e21bc767e8518ff7f1725307e6a8cc9a093bc009

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) != 4:
        return None
    sr, start, size, events = x
    if sr <= 0 or size <= 0:
        return None
    out = []
    for us in events:
        pos = (2 * us * sr + 1000000) // 2000000
        if pos < start:
            out.append('late')
        elif pos >= start + size:
            out.append('future')
        else:
            out.append(pos - start)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([48000, 0, 256, [0, 1000, 5333, 5334]], [0, 48, 'future', 'future']), ([48000, 480, 256, [10000, 10010, 15332, 15333]], [0, 0, 'future', 'future']), ([44100, 441, 128, [10000, 10011, 12902, 12903]], [0, 0, 'future', 'future']), ([48000, 48000, 512, [1000000, 1010667, 1010656, 999990]], [0, 'future', 511, 0]), ([48000, 0, 64, [10, 11, 1333, 1343]], [0, 1, 'future', 'future']), ([48000, 0, 0, [0]], None), ([0, 0, 10, [0]], None), ([1000, 0, 4, [499, 500, 3499, 3500]], [0, 1, 3, 'future'])], [([48000, 480, 256, [10000, 10010, 15332, 15333]], [0, 0, 'future', 'future']), ([44100, 441, 128, [10000, 10011, 12902, 12903]], [0, 0, 'future', 'future']), ([48000, 48000, 512, [1000000, 1010667, 1010656, 999990]], [0, 'future', 511, 0]), ([1000, 10, 5, [9500, 10000, 14499, 14500]], [0, 0, 4, 'future']), ([44100, 1024, 256, [23220, 23232, 29025, 29037]], [0, 1, 'future', 'future']), ([8000, 100, 10, [12500, 12562, 13687, 13688]], [0, 0, 9, 'future']), ([0, 0, 10, [0]], None), ([1000, 0, 4, [499, 500, 3499, 3500]], [0, 1, 3, 'future'])], [([48000, 0, 256, [0, 1000, 5333, 5334]], [0, 48, 'future', 'future']), ([44100, 441, 128, [10000, 10011, 12902, 12903]], [0, 0, 'future', 'future']), ([48000, 48000, 512, [1000000, 1010667, 1010656, 999990]], [0, 'future', 511, 0]), ([1000, 10, 5, [9500, 10000, 14499, 14500]], [0, 0, 4, 'future']), ([48000, 0, 64, [10, 11, 1333, 1343]], [0, 1, 'future', 'future']), ([44100, 1024, 256, [23220, 23232, 29025, 29037]], [0, 1, 'future', 'future']), ([8000, 100, 10, [12500, 12562, 13687, 13688]], [0, 0, 9, 'future']), ([96000, 960, 96, [10000, 10005, 10995, 11000]], [0, 0, 'future', 'future'])], [([48000, 0, 256, [0, 1000, 5333, 5334]], [0, 48, 'future', 'future']), ([48000, 480, 256, [10000, 10010, 15332, 15333]], [0, 0, 'future', 'future']), ([1000, 10, 5, [9500, 10000, 14499, 14500]], [0, 0, 4, 'future']), ([48000, 0, 64, [10, 11, 1333, 1343]], [0, 1, 'future', 'future']), ([44100, 1024, 256, [23220, 23232, 29025, 29037]], [0, 1, 'future', 'future']), ([8000, 100, 10, [12500, 12562, 13687, 13688]], [0, 0, 9, 'future']), ([48000, 0, 0, [0]], None), ([96000, 960, 96, [10000, 10005, 10995, 11000]], [0, 0, 'future', 'future'])], [([48000, 0, 256, [0, 1000, 5333, 5334]], [0, 48, 'future', 'future']), ([44100, 441, 128, [10000, 10011, 12902, 12903]], [0, 0, 'future', 'future']), ([48000, 0, 64, [10, 11, 1333, 1343]], [0, 1, 'future', 'future']), ([44100, 1024, 256, [23220, 23232, 29025, 29037]], [0, 1, 'future', 'future']), ([48000, 0, 0, [0]], None), ([0, 0, 10, [0]], None), ([96000, 960, 96, [10000, 10005, 10995, 11000]], [0, 0, 'future', 'future']), ([1000, 0, 4, [499, 500, 3499, 3500]], [0, 1, 3, 'future'])]]
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, 48, 'future', 'future'][0, 48, 'future', 'future']Passed
oracle 1[0, 0, 'future', 'future'][0, 0, 'future', 'future']Passed
oracle 2[0, 0, 'future', 'future'][0, 0, 'future', 'future']Passed
oracle 3[0, 'future', 511, 0][0, 'future', 511, 0]Passed
oracle 4[0, 1, 'future', 'future'][0, 1, 'future', 'future']Passed
oracle 5NoneNonePassed
oracle 6NoneNonePassed
oracle 7[0, 1, 3, 'future'][0, 1, 3, 'future']Passed

SHA-256 / a493c88108dddc5026816fab0c94a3b631380604983d00600842da3125ac9bf2

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

Case digest / 557da2f7f4fcecdf175f6e37ffb83c1e39953f39e3269cb42e24db9f44c8ac5a