FAILURE MAP
← Case archive

FA-81566 / MIDI event timing / Open access

Eighth-note swing time remapping: straight timing rejected · case 01

A swing of exactly 50% (straight eighths) is rejected instead of returning the input unchanged.

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

ROOT CAUSE

The lower bound of the swing range is exclusive.

VERIFIED REPAIR

Restore the swing range step so that it reads `50 <= swing <= 75`.

Unsuccessful approach: Dropping the lower bound accepts swing below 50%, which rushes offbeats.

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 + 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]), ([[240, 300, 479], 480, 66], [316, 357, 479]), ([[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)], [([[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), ([[0, 240], 481, 60], None), ([[100, 300], 480, 55], [110, 318]), ([[250, 470], 480, 50], [250, 470])], [([[0, 240, 480, 720], 480, 50], [0, 240, 480, 720]), ([[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]), ([[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]), ([[240, 300, 479], 480, 66], [316, 357, 479]), ([[0, 240], 480, 49], None), ([[90], 120, 62], [97]), ([[5, 55], 100, 64], [6, 67]), ([[250, 470], 480, 50], [250, 470]), ([[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]), ([[240, 300, 479], 480, 66], [316, 357, 479]), ([[120, 360], 480, 60], [144, 384]), ([[960, 1200, 1320], 480, 75], [960, 1320, 1380]), ([[1, 239, 241], 480, 70], [1, 334, 336]), ([[0, 240], 480, 49], None), ([[250, 470], 480, 50], [250, 470])]]
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 0None[0, 240, 480, 720]Failed
oracle 1[0, 316, 480, 796][0, 316, 480, 796]Passed
oracle 2[316, 357, 479][316, 357, 479]Passed
oracle 3[144, 384][144, 384]Passed
oracle 4[960, 1320, 1380][960, 1320, 1380]Passed
oracle 5[1, 334, 336][1, 334, 336]Passed
oracle 6[0, 69][0, 69]Passed
oracle 7NoneNonePassed

SHA-256 / 9814accb04408542a160ac29984a159dda9ce92ae3b9659ff968297ce4207827

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 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]), ([[240, 300, 479], 480, 66], [316, 357, 479]), ([[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)], [([[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), ([[0, 240], 481, 60], None), ([[100, 300], 480, 55], [110, 318]), ([[250, 470], 480, 50], [250, 470])], [([[0, 240, 480, 720], 480, 50], [0, 240, 480, 720]), ([[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]), ([[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]), ([[240, 300, 479], 480, 66], [316, 357, 479]), ([[0, 240], 480, 49], None), ([[90], 120, 62], [97]), ([[5, 55], 100, 64], [6, 67]), ([[250, 470], 480, 50], [250, 470]), ([[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]), ([[240, 300, 479], 480, 66], [316, 357, 479]), ([[120, 360], 480, 60], [144, 384]), ([[960, 1200, 1320], 480, 75], [960, 1320, 1380]), ([[1, 239, 241], 480, 70], [1, 334, 336]), ([[0, 240], 480, 49], None), ([[250, 470], 480, 50], [250, 470])]]
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, 240, 480, 720][0, 240, 480, 720]Passed
oracle 1[0, 316, 480, 796][0, 316, 480, 796]Passed
oracle 2[316, 357, 479][316, 357, 479]Passed
oracle 3[144, 384][144, 384]Passed
oracle 4[960, 1320, 1380][960, 1320, 1380]Passed
oracle 5[1, 334, 336][1, 334, 336]Passed
oracle 6[0, 69][0, 69]Passed
oracle 7[0, 235]NoneFailed

SHA-256 / f285390de350c5c780d9be3df147d81649e4ccd48edc46ab4af223b2e2e7c51f

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]), ([[240, 300, 479], 480, 66], [316, 357, 479]), ([[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)], [([[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), ([[0, 240], 481, 60], None), ([[100, 300], 480, 55], [110, 318]), ([[250, 470], 480, 50], [250, 470])], [([[0, 240, 480, 720], 480, 50], [0, 240, 480, 720]), ([[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]), ([[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]), ([[240, 300, 479], 480, 66], [316, 357, 479]), ([[0, 240], 480, 49], None), ([[90], 120, 62], [97]), ([[5, 55], 100, 64], [6, 67]), ([[250, 470], 480, 50], [250, 470]), ([[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]), ([[240, 300, 479], 480, 66], [316, 357, 479]), ([[120, 360], 480, 60], [144, 384]), ([[960, 1200, 1320], 480, 75], [960, 1320, 1380]), ([[1, 239, 241], 480, 70], [1, 334, 336]), ([[0, 240], 480, 49], None), ([[250, 470], 480, 50], [250, 470])]]
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, 240, 480, 720][0, 240, 480, 720]Passed
oracle 1[0, 316, 480, 796][0, 316, 480, 796]Passed
oracle 2[316, 357, 479][316, 357, 479]Passed
oracle 3[144, 384][144, 384]Passed
oracle 4[960, 1320, 1380][960, 1320, 1380]Passed
oracle 5[1, 334, 336][1, 334, 336]Passed
oracle 6[0, 69][0, 69]Passed
oracle 7NoneNonePassed

SHA-256 / 2d7f6902aa0b8912657d91ace208cc89d18a3cf23395cfbb19e47f3e035dfc35

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

Case digest / 74318e06a14023907828376d6d5cfce32db350fb488409f7acf1190719c25802