FAILURE MAP
← Case archive

FA-10806 / PCM sample encoding / Open access

Float to pcm16 endpoint clamp · case 01

Positive full scale quantizes to unrepresentable 32768 without final clamping.

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

ROOT CAUSE

Positive full scale quantizes to unrepresentable 32768 without final clamping.

VERIFIED REPAIR

Apply the explicit PCM/playback contract: Convert finite float amplitudes to signed16 using scale32768, nearest ties toward positive infinity, then saturate.

Unsuccessful approach: Scaling by32767 changes negative full scale and midscale quantization.

Case contract

Convert finite float amplitudes to signed16 using scale32768, nearest ties toward positive infinity, then saturate.

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 [math.floor(x*32768+.5) for x in samples]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1',solve(*([-1, 0, 1],)),[-32768, 0, 32767])
check('fixture 2',solve(*([0.5, -0.5],)),[16384, -16384])
check('fixture 3',solve(*([2, -2],)),[32767, -32768])
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 fixtureActualExpectedOutcome
fixture 1[-32768, 0, 32768][-32768, 0, 32767]Failed
fixture 2[16384, -16384][16384, -16384]Passed
fixture 3[65536, -65536][32767, -32768]Failed
fixture 4[][]Passed

SHA-256 / 241e1ad5aa7e55d82d53713d6815096181ee2544356935dabdecc2c7adcc971b

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 [math.floor(x*32767+.5) for x in samples]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1',solve(*([-1, 0, 1],)),[-32768, 0, 32767])
check('fixture 2',solve(*([0.5, -0.5],)),[16384, -16384])
check('fixture 3',solve(*([2, -2],)),[32767, -32768])
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 fixtureActualExpectedOutcome
fixture 1[-32767, 0, 32767][-32768, 0, 32767]Failed
fixture 2[16384, -16383][16384, -16384]Failed
fixture 3[65534, -65534][32767, -32768]Failed
fixture 4[][]Passed

SHA-256 / 05968941dc87855c2eee94ebeaf1b200932f596bc35659843e0e030dc6acb5fe

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,math.floor(x*32768+.5))) for x in samples]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1',solve(*([-1, 0, 1],)),[-32768, 0, 32767])
check('fixture 2',solve(*([0.5, -0.5],)),[16384, -16384])
check('fixture 3',solve(*([2, -2],)),[32767, -32768])
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 fixtureActualExpectedOutcome
fixture 1[-32768, 0, 32767][-32768, 0, 32767]Passed
fixture 2[16384, -16384][16384, -16384]Passed
fixture 3[32767, -32768][32767, -32768]Passed
fixture 4[][]Passed

SHA-256 / a40b9b6c2d46335cf7292c4831f9ca5ecef56bda461b1bedbc750aff13d8b0df

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

Case digest / e38e836401f6cc2397b692e2466ca0d64ed27b2ec51eb0bf27b7fb2d3928a013