FA-10801 / PCM sample encoding / Open access
Pcm16 saturation before encoding · case 01
Overflow wraps a large positive sample into a negative amplitude.
ROOT CAUSE
Overflow wraps a large positive sample into a negative amplitude.
VERIFIED REPAIR
Apply the explicit PCM/playback contract: Saturate arbitrary integer intermediate amplitudes to the asymmetric signed 16-bit PCM range.
Unsuccessful approach: Symmetric clamping excludes the valid -32768 endpoint.
Case contract
Saturate arbitrary integer intermediate amplitudes to the asymmetric signed 16-bit PCM range.
Why this case matters
A pure Python local audio pipeline stage with explicit sample formats and frame conventions; no real-time device or signal-spectrum claims.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(samples):
return [((x+32768)%65536)-32768 for x in samples]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1',solve(*([-40000, 40000],)),[-32768, 32767])
check('fixture 2',solve(*([-32768, 32767],)),[-32768, 32767])
check('fixture 3',solve(*([0, 1, -1],)),[0, 1, -1])
check('fixture 4',solve(*([],)),[])
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 |
|---|---|---|---|
| fixture 1 | [25536, -25536] | [-32768, 32767] | Failed |
| fixture 2 | [-32768, 32767] | [-32768, 32767] | Passed |
| fixture 3 | [0, 1, -1] | [0, 1, -1] | Passed |
| fixture 4 | [] | [] | Passed |
SHA-256 / 9653a1e26265a0a9f6668368be04fd79890f1cbd8203bea3223b49573696eb01
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(samples):
return [max(-32767,min(32767,x)) for x in samples]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1',solve(*([-40000, 40000],)),[-32768, 32767])
check('fixture 2',solve(*([-32768, 32767],)),[-32768, 32767])
check('fixture 3',solve(*([0, 1, -1],)),[0, 1, -1])
check('fixture 4',solve(*([],)),[])
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 |
|---|---|---|---|
| fixture 1 | [-32767, 32767] | [-32768, 32767] | Failed |
| fixture 2 | [-32767, 32767] | [-32768, 32767] | Failed |
| fixture 3 | [0, 1, -1] | [0, 1, -1] | Passed |
| fixture 4 | [] | [] | Passed |
SHA-256 / a75b700ddb8ec8a865b88134c8efcc2a9279f0bfdea0e3af199325d6bbf7741c
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(samples):
return [max(-32768,min(32767,x)) for x in samples]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1',solve(*([-40000, 40000],)),[-32768, 32767])
check('fixture 2',solve(*([-32768, 32767],)),[-32768, 32767])
check('fixture 3',solve(*([0, 1, -1],)),[0, 1, -1])
check('fixture 4',solve(*([],)),[])
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 |
|---|---|---|---|
| fixture 1 | [-32768, 32767] | [-32768, 32767] | Passed |
| fixture 2 | [-32768, 32767] | [-32768, 32767] | Passed |
| fixture 3 | [0, 1, -1] | [0, 1, -1] | Passed |
| fixture 4 | [] | [] | Passed |
SHA-256 / 85b060522bc2a67175c4a6f6ab5ecec86c70ef2064bf359522e4a0adf261b809
Verification & scope
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:38:42.355665+00:00.
Case digest / 939466da27b304c0d38dd1c817647fb1529f520d91884725930a592e49181995