FA-81656 / MIDI event timing / Open access
14-bit pitch bend to cents: eight-bit data bytes accepted · case 01
A data byte of 128 (a status byte) is accepted and folded into the bend value.
ROOT CAUSE
Data bytes are validated as full bytes instead of 7-bit values.
VERIFIED REPAIR
Restore the data byte range step so that it reads `0 <= v <= 127`.
Unsuccessful approach: Excluding 127 rejects the legitimate maximum bend.
Case contract
Input [lsb, msb, range_semitones] with 7-bit data bytes. value = msb*128 + lsb, offset = value - 8192. Positive offsets scale to +range by dividing by 8191, negative ones by 8192. cents = offset * range * 100 / divisor, rounded half away from zero. Invalid bytes or negative range 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
lsb, msb, rng = x
if not all(isinstance(v, int) and 0 <= v <= 255 for v in (lsb, msb)) or rng < 0:
return None
value = (msb << 7) | lsb
offset = value - 8192
den = 8191 if offset > 0 else 8192
c = Fraction(abs(offset) * rng * 100, den)
cents = int(c + Fraction(1, 2))
return cents if offset >= 0 else -cents
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([0, 64, 2], 0), ([127, 127, 2], 200), ([0, 0, 2], -200), ([0, 96, 2], 100), ([0, 32, 2], -100), ([0, 56, 1], -13), ([0, 128, 2], None), ([127, 127, 48], 4800)], [([0, 32, 2], -100), ([0, 56, 1], -13), ([0, 24, 1], -63), ([0, 40, 1], -38), ([1, 64, 2], 0), ([127, 63, 2], 0), ([128, 64, 2], None), ([100, 127, 48], 4784)], [([127, 127, 2], 200), ([0, 40, 1], -38), ([1, 64, 2], 0), ([0, 72, 12], 150), ([0, 56, 3], -38), ([0, 128, 2], None), ([0, 64, -1], None), ([127, 127, 12], 1200)], [([127, 63, 2], 0), ([0, 56, 3], -38), ([128, 64, 2], None), ([0, 64, -1], None), ([0, 0, 12], -1200), ([64, 100, 2], 114), ([0, 88, 1], 38), ([127, 127, 48], 4800)], [([127, 127, 2], 200), ([0, 128, 2], None), ([127, 127, 12], 1200), ([64, 100, 2], 114), ([0, 88, 1], 38), ([0, 0, 48], -4800), ([100, 127, 48], 4784), ([0, 96, 48], 2400)]]
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 | 0 | Passed |
| oracle 1 | 200 | 200 | Passed |
| oracle 2 | -200 | -200 | Passed |
| oracle 3 | 100 | 100 | Passed |
| oracle 4 | -100 | -100 | Passed |
| oracle 5 | -13 | -13 | Passed |
| oracle 6 | 200 | None | Failed |
| oracle 7 | 4800 | 4800 | Passed |
SHA-256 / 343855a91ddf3fc2bee9aadd5b960bd8a5508b7082f02b6c9be7d13d23dcfc2e
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
lsb, msb, rng = x
if not all(isinstance(v, int) and 0 <= v < 127 for v in (lsb, msb)) or rng < 0:
return None
value = (msb << 7) | lsb
offset = value - 8192
den = 8191 if offset > 0 else 8192
c = Fraction(abs(offset) * rng * 100, den)
cents = int(c + Fraction(1, 2))
return cents if offset >= 0 else -cents
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([0, 64, 2], 0), ([127, 127, 2], 200), ([0, 0, 2], -200), ([0, 96, 2], 100), ([0, 32, 2], -100), ([0, 56, 1], -13), ([0, 128, 2], None), ([127, 127, 48], 4800)], [([0, 32, 2], -100), ([0, 56, 1], -13), ([0, 24, 1], -63), ([0, 40, 1], -38), ([1, 64, 2], 0), ([127, 63, 2], 0), ([128, 64, 2], None), ([100, 127, 48], 4784)], [([127, 127, 2], 200), ([0, 40, 1], -38), ([1, 64, 2], 0), ([0, 72, 12], 150), ([0, 56, 3], -38), ([0, 128, 2], None), ([0, 64, -1], None), ([127, 127, 12], 1200)], [([127, 63, 2], 0), ([0, 56, 3], -38), ([128, 64, 2], None), ([0, 64, -1], None), ([0, 0, 12], -1200), ([64, 100, 2], 114), ([0, 88, 1], 38), ([127, 127, 48], 4800)], [([127, 127, 2], 200), ([0, 128, 2], None), ([127, 127, 12], 1200), ([64, 100, 2], 114), ([0, 88, 1], 38), ([0, 0, 48], -4800), ([100, 127, 48], 4784), ([0, 96, 48], 2400)]]
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 | 0 | Passed |
| oracle 1 | None | 200 | Failed |
| oracle 2 | -200 | -200 | Passed |
| oracle 3 | 100 | 100 | Passed |
| oracle 4 | -100 | -100 | Passed |
| oracle 5 | -13 | -13 | Passed |
| oracle 6 | None | None | Passed |
| oracle 7 | None | 4800 | Failed |
SHA-256 / a58e29547dd658e5e4ffeac08dc5d4a497785d4a6923ea854143e6883e978b07
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
lsb, msb, rng = x
if not all(isinstance(v, int) and 0 <= v <= 127 for v in (lsb, msb)) or rng < 0:
return None
value = (msb << 7) | lsb
offset = value - 8192
den = 8191 if offset > 0 else 8192
c = Fraction(abs(offset) * rng * 100, den)
cents = int(c + Fraction(1, 2))
return cents if offset >= 0 else -cents
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([0, 64, 2], 0), ([127, 127, 2], 200), ([0, 0, 2], -200), ([0, 96, 2], 100), ([0, 32, 2], -100), ([0, 56, 1], -13), ([0, 128, 2], None), ([127, 127, 48], 4800)], [([0, 32, 2], -100), ([0, 56, 1], -13), ([0, 24, 1], -63), ([0, 40, 1], -38), ([1, 64, 2], 0), ([127, 63, 2], 0), ([128, 64, 2], None), ([100, 127, 48], 4784)], [([127, 127, 2], 200), ([0, 40, 1], -38), ([1, 64, 2], 0), ([0, 72, 12], 150), ([0, 56, 3], -38), ([0, 128, 2], None), ([0, 64, -1], None), ([127, 127, 12], 1200)], [([127, 63, 2], 0), ([0, 56, 3], -38), ([128, 64, 2], None), ([0, 64, -1], None), ([0, 0, 12], -1200), ([64, 100, 2], 114), ([0, 88, 1], 38), ([127, 127, 48], 4800)], [([127, 127, 2], 200), ([0, 128, 2], None), ([127, 127, 12], 1200), ([64, 100, 2], 114), ([0, 88, 1], 38), ([0, 0, 48], -4800), ([100, 127, 48], 4784), ([0, 96, 48], 2400)]]
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 | 0 | Passed |
| oracle 1 | 200 | 200 | Passed |
| oracle 2 | -200 | -200 | Passed |
| oracle 3 | 100 | 100 | Passed |
| oracle 4 | -100 | -100 | Passed |
| oracle 5 | -13 | -13 | Passed |
| oracle 6 | None | None | Passed |
| oracle 7 | 4800 | 4800 | Passed |
SHA-256 / 17d90b7907a83d4529f98a4ceef0238bf4dc3e026b11d92278c9974876980e25
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:05.037818+00:00.
Case digest / 24470f8fc0a62f160dc7239a4cb675983ec029bf24f8af29513914d03291e809