FA-81826 / MIDI event timing / Open access
Event placement inside an audio render buffer: event sample position truncated · case 01
Events between two samples always land on the earlier sample; a half-sample event plays early.
ROOT CAUSE
The time-to-sample conversion floors instead of rounding half up.
VERIFIED REPAIR
Restore the sample rounding step so that it reads `(2 * us * sr + 1000000) // 2000000`.
Unsuccessful approach: Rounding up any fraction moves events that are just past a sample to the next sample.
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 = us * sr // 1000000
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]), ([1000, 10, 5, [9500, 10000, 14499, 14500]], [0, 0, 4, 'future']), ([48000, 0, 64, [10, 11, 1333, 1343]], [0, 1, 'future', 'future']), ([48000, 0, 0, [0]], None), ([0, 0, 10, [0]], None)], [([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']), ([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'])], [([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']), ([1000, 0, 4, [499, 500, 3499, 3500]], [0, 1, 3, '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']), ([8000, 100, 10, [12500, 12562, 13687, 13688]], [0, 0, 9, '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'])], [([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']), ([48000, 0, 0, [0]], None), ([0, 0, 10, [0]], None), ([96000, 960, 96, [10000, 10005, 10995, 11000]], [0, 0, 'future', '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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| oracle 0 | [0, 48, 255, 'future'] | [0, 48, 'future', 'future'] | Failed |
| oracle 1 | [0, 0, 255, 255] | [0, 0, 'future', 'future'] | Failed |
| oracle 2 | [0, 0, 127, 'future'] | [0, 0, 'future', 'future'] | Failed |
| oracle 3 | [0, 'future', 511, 'late'] | [0, 'future', 511, 0] | Failed |
| oracle 4 | ['late', 0, 4, 4] | [0, 0, 4, 'future'] | Failed |
| oracle 5 | [0, 0, 63, 'future'] | [0, 1, 'future', 'future'] | Failed |
| oracle 6 | None | None | Passed |
| oracle 7 | None | None | Passed |
SHA-256 / 32a5bba1b64cd744458dec973f6a3ef483927951a3ffb0c47cf102f5b74c2a77
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 = (us * sr + 999999) // 1000000
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]), ([1000, 10, 5, [9500, 10000, 14499, 14500]], [0, 0, 4, 'future']), ([48000, 0, 64, [10, 11, 1333, 1343]], [0, 1, 'future', 'future']), ([48000, 0, 0, [0]], None), ([0, 0, 10, [0]], None)], [([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']), ([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'])], [([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']), ([1000, 0, 4, [499, 500, 3499, 3500]], [0, 1, 3, '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']), ([8000, 100, 10, [12500, 12562, 13687, 13688]], [0, 0, 9, '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'])], [([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']), ([48000, 0, 0, [0]], None), ([0, 0, 10, [0]], None), ([96000, 960, 96, [10000, 10005, 10995, 11000]], [0, 0, 'future', '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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| oracle 0 | [0, 48, 'future', 'future'] | [0, 48, 'future', 'future'] | Passed |
| oracle 1 | [0, 1, 'future', 'future'] | [0, 0, 'future', 'future'] | Failed |
| oracle 2 | [0, 1, 'future', 'future'] | [0, 0, 'future', 'future'] | Failed |
| oracle 3 | [0, 'future', 'future', 0] | [0, 'future', 511, 0] | Failed |
| oracle 4 | [0, 0, 'future', 'future'] | [0, 0, 4, 'future'] | Failed |
| oracle 5 | [1, 1, 'future', 'future'] | [0, 1, 'future', 'future'] | Failed |
| oracle 6 | None | None | Passed |
| oracle 7 | None | None | Passed |
SHA-256 / b9292e652f3cc9c987af0161ac02c4806b0cbeb3b0185e058b6c5fa5366e5847
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]), ([1000, 10, 5, [9500, 10000, 14499, 14500]], [0, 0, 4, 'future']), ([48000, 0, 64, [10, 11, 1333, 1343]], [0, 1, 'future', 'future']), ([48000, 0, 0, [0]], None), ([0, 0, 10, [0]], None)], [([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']), ([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'])], [([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']), ([1000, 0, 4, [499, 500, 3499, 3500]], [0, 1, 3, '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']), ([8000, 100, 10, [12500, 12562, 13687, 13688]], [0, 0, 9, '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'])], [([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']), ([48000, 0, 0, [0]], None), ([0, 0, 10, [0]], None), ([96000, 960, 96, [10000, 10005, 10995, 11000]], [0, 0, 'future', '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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| 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, 0, 4, 'future'] | [0, 0, 4, 'future'] | Passed |
| oracle 5 | [0, 1, 'future', 'future'] | [0, 1, 'future', 'future'] | Passed |
| oracle 6 | None | None | Passed |
| oracle 7 | None | None | Passed |
SHA-256 / e90d6467b973d749e1c99720ffeb9f9228de997e895a02cb305895816d87e822
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.394724+00:00.
Case digest / b5e9f02a2c75a24807cbdf0e57a99299bf60bd7fe969b5a01e6a1d903af24061