FA-81571 / MIDI event timing / Open access
Eighth-note swing time remapping: swung positions rounded to nearest · case 01
Some swung notes land one tick later than the stipulated floored position.
ROOT CAUSE
The remapped position is rounded to nearest instead of floored.
VERIFIED REPAIR
Restore the remapped position rounding step so that it reads `int(new)`.
Unsuccessful approach: Taking the ceiling for any fractional part moves every inexact position a tick late.
Case contract
Input [ticks, ppq, swing] with even ppq > 0 and swing 50..75 percent. Within each beat, positions in the first half [0, ppq/2) scale linearly onto [0, split) and positions in the second half onto [split, ppq), where split = ppq*swing/100. The remapped position is floored. Invalid parameters 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
from fractions import Fraction
N = 1
observations = []
def solve(x):
if not isinstance(x, list) or len(x) != 3:
return None
ticks, ppq, swing = x
if ppq <= 0 or ppq % 2 or not 50 <= swing <= 75:
return None
half = ppq // 2
split = Fraction(ppq * swing, 100)
out = []
for t in ticks:
beat, pos = divmod(t, ppq)
if pos < half:
new = pos * split / half
else:
new = split + (pos - half) * (ppq - split) / half
out.append(beat * ppq + round(new))
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([[0, 240, 480, 720], 480, 50], [0, 240, 480, 720]), ([[0, 240, 480, 720], 480, 66], [0, 316, 480, 796]), ([[120, 360], 480, 60], [144, 384]), ([[960, 1200, 1320], 480, 75], [960, 1320, 1380]), ([[1, 239, 241], 480, 70], [1, 334, 336]), ([[0, 60], 120, 58], [0, 69]), ([[0, 240], 480, 49], None), ([[0, 240], 480, 76], None)], [([[240, 300, 479], 480, 66], [316, 357, 479]), ([[0, 60], 120, 58], [0, 69]), ([[0, 240], 480, 49], None), ([[0, 240], 480, 76], None), ([[0, 240], 481, 60], None), ([[100, 300], 480, 55], [110, 318]), ([[90], 120, 62], [97]), ([[250, 470], 480, 50], [250, 470])], [([[0, 240, 480, 720], 480, 66], [0, 316, 480, 796]), ([[240, 300, 479], 480, 66], [316, 357, 479]), ([[1, 239, 241], 480, 70], [1, 334, 336]), ([[0, 60], 120, 58], [0, 69]), ([[100, 300], 480, 55], [110, 318]), ([[90], 120, 62], [97]), ([[5, 55], 100, 64], [6, 67]), ([[250, 470], 480, 50], [250, 470])], [([[0, 240, 480, 720], 480, 50], [0, 240, 480, 720]), ([[240, 300, 479], 480, 66], [316, 357, 479]), ([[120, 360], 480, 60], [144, 384]), ([[1, 239, 241], 480, 70], [1, 334, 336]), ([[0, 60], 120, 58], [0, 69]), ([[90], 120, 62], [97]), ([[5, 55], 100, 64], [6, 67]), ([[30, 100], 120, 67], [40, 106])], [([[0, 240, 480, 720], 480, 50], [0, 240, 480, 720]), ([[0, 240, 480, 720], 480, 66], [0, 316, 480, 796]), ([[120, 360], 480, 60], [144, 384]), ([[960, 1200, 1320], 480, 75], [960, 1320, 1380]), ([[0, 240], 480, 49], None), ([[90], 120, 62], [97]), ([[5, 55], 100, 64], [6, 67]), ([[30, 100], 120, 67], [40, 106])]]
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, 240, 480, 720] | [0, 240, 480, 720] | Passed |
| oracle 1 | [0, 317, 480, 797] | [0, 316, 480, 796] | Failed |
| oracle 2 | [144, 384] | [144, 384] | Passed |
| oracle 3 | [960, 1320, 1380] | [960, 1320, 1380] | Passed |
| oracle 4 | [1, 335, 337] | [1, 334, 336] | Failed |
| oracle 5 | [0, 70] | [0, 69] | Failed |
| oracle 6 | None | None | Passed |
| oracle 7 | None | None | Passed |
SHA-256 / 8f6d87bd7cdd8591095cabc63f3d220c606eb69de3710cce1d9d7c4cb61a4943
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(x):
if not isinstance(x, list) or len(x) != 3:
return None
ticks, ppq, swing = x
if ppq <= 0 or ppq % 2 or not 50 <= swing <= 75:
return None
half = ppq // 2
split = Fraction(ppq * swing, 100)
out = []
for t in ticks:
beat, pos = divmod(t, ppq)
if pos < half:
new = pos * split / half
else:
new = split + (pos - half) * (ppq - split) / half
out.append(beat * ppq + int(new) + (1 if new % 1 else 0))
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([[0, 240, 480, 720], 480, 50], [0, 240, 480, 720]), ([[0, 240, 480, 720], 480, 66], [0, 316, 480, 796]), ([[120, 360], 480, 60], [144, 384]), ([[960, 1200, 1320], 480, 75], [960, 1320, 1380]), ([[1, 239, 241], 480, 70], [1, 334, 336]), ([[0, 60], 120, 58], [0, 69]), ([[0, 240], 480, 49], None), ([[0, 240], 480, 76], None)], [([[240, 300, 479], 480, 66], [316, 357, 479]), ([[0, 60], 120, 58], [0, 69]), ([[0, 240], 480, 49], None), ([[0, 240], 480, 76], None), ([[0, 240], 481, 60], None), ([[100, 300], 480, 55], [110, 318]), ([[90], 120, 62], [97]), ([[250, 470], 480, 50], [250, 470])], [([[0, 240, 480, 720], 480, 66], [0, 316, 480, 796]), ([[240, 300, 479], 480, 66], [316, 357, 479]), ([[1, 239, 241], 480, 70], [1, 334, 336]), ([[0, 60], 120, 58], [0, 69]), ([[100, 300], 480, 55], [110, 318]), ([[90], 120, 62], [97]), ([[5, 55], 100, 64], [6, 67]), ([[250, 470], 480, 50], [250, 470])], [([[0, 240, 480, 720], 480, 50], [0, 240, 480, 720]), ([[240, 300, 479], 480, 66], [316, 357, 479]), ([[120, 360], 480, 60], [144, 384]), ([[1, 239, 241], 480, 70], [1, 334, 336]), ([[0, 60], 120, 58], [0, 69]), ([[90], 120, 62], [97]), ([[5, 55], 100, 64], [6, 67]), ([[30, 100], 120, 67], [40, 106])], [([[0, 240, 480, 720], 480, 50], [0, 240, 480, 720]), ([[0, 240, 480, 720], 480, 66], [0, 316, 480, 796]), ([[120, 360], 480, 60], [144, 384]), ([[960, 1200, 1320], 480, 75], [960, 1320, 1380]), ([[0, 240], 480, 49], None), ([[90], 120, 62], [97]), ([[5, 55], 100, 64], [6, 67]), ([[30, 100], 120, 67], [40, 106])]]
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, 240, 480, 720] | [0, 240, 480, 720] | Passed |
| oracle 1 | [0, 317, 480, 797] | [0, 316, 480, 796] | Failed |
| oracle 2 | [144, 384] | [144, 384] | Passed |
| oracle 3 | [960, 1320, 1380] | [960, 1320, 1380] | Passed |
| oracle 4 | [2, 335, 337] | [1, 334, 336] | Failed |
| oracle 5 | [0, 70] | [0, 69] | Failed |
| oracle 6 | None | None | Passed |
| oracle 7 | None | None | Passed |
SHA-256 / e5bbac675fe012d90543c8e1bd74b34f02cb095dfcbf4fdc44109714bc5013c2
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(x):
if not isinstance(x, list) or len(x) != 3:
return None
ticks, ppq, swing = x
if ppq <= 0 or ppq % 2 or not 50 <= swing <= 75:
return None
half = ppq // 2
split = Fraction(ppq * swing, 100)
out = []
for t in ticks:
beat, pos = divmod(t, ppq)
if pos < half:
new = pos * split / half
else:
new = split + (pos - half) * (ppq - split) / half
out.append(beat * ppq + int(new))
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([[0, 240, 480, 720], 480, 50], [0, 240, 480, 720]), ([[0, 240, 480, 720], 480, 66], [0, 316, 480, 796]), ([[120, 360], 480, 60], [144, 384]), ([[960, 1200, 1320], 480, 75], [960, 1320, 1380]), ([[1, 239, 241], 480, 70], [1, 334, 336]), ([[0, 60], 120, 58], [0, 69]), ([[0, 240], 480, 49], None), ([[0, 240], 480, 76], None)], [([[240, 300, 479], 480, 66], [316, 357, 479]), ([[0, 60], 120, 58], [0, 69]), ([[0, 240], 480, 49], None), ([[0, 240], 480, 76], None), ([[0, 240], 481, 60], None), ([[100, 300], 480, 55], [110, 318]), ([[90], 120, 62], [97]), ([[250, 470], 480, 50], [250, 470])], [([[0, 240, 480, 720], 480, 66], [0, 316, 480, 796]), ([[240, 300, 479], 480, 66], [316, 357, 479]), ([[1, 239, 241], 480, 70], [1, 334, 336]), ([[0, 60], 120, 58], [0, 69]), ([[100, 300], 480, 55], [110, 318]), ([[90], 120, 62], [97]), ([[5, 55], 100, 64], [6, 67]), ([[250, 470], 480, 50], [250, 470])], [([[0, 240, 480, 720], 480, 50], [0, 240, 480, 720]), ([[240, 300, 479], 480, 66], [316, 357, 479]), ([[120, 360], 480, 60], [144, 384]), ([[1, 239, 241], 480, 70], [1, 334, 336]), ([[0, 60], 120, 58], [0, 69]), ([[90], 120, 62], [97]), ([[5, 55], 100, 64], [6, 67]), ([[30, 100], 120, 67], [40, 106])], [([[0, 240, 480, 720], 480, 50], [0, 240, 480, 720]), ([[0, 240, 480, 720], 480, 66], [0, 316, 480, 796]), ([[120, 360], 480, 60], [144, 384]), ([[960, 1200, 1320], 480, 75], [960, 1320, 1380]), ([[0, 240], 480, 49], None), ([[90], 120, 62], [97]), ([[5, 55], 100, 64], [6, 67]), ([[30, 100], 120, 67], [40, 106])]]
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, 240, 480, 720] | [0, 240, 480, 720] | Passed |
| oracle 1 | [0, 316, 480, 796] | [0, 316, 480, 796] | Passed |
| oracle 2 | [144, 384] | [144, 384] | Passed |
| oracle 3 | [960, 1320, 1380] | [960, 1320, 1380] | Passed |
| oracle 4 | [1, 334, 336] | [1, 334, 336] | Passed |
| oracle 5 | [0, 69] | [0, 69] | Passed |
| oracle 6 | None | None | Passed |
| oracle 7 | None | None | Passed |
SHA-256 / c3f44c6ae4b4d7875e2508cf88a2698025c6e9a45fb80f04a8eceae082e02686
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.355517+00:00.
Case digest / b80b5220ca1feaec6738ad50f02ca2b50001766d4649e3a32462ee7ea90907c9