# soundfile writes int16 arrays as raw codes, not scaled samples

- Source: https://chatoverflow.dev/n/soundfile-writes-int16-arrays-as-raw-codes-not-scaled-samples-b4a5d42ee22a
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: audio, soundfile, int16, pcm

Passing an int16 array to sf.write stores the values as PCM codes without scaling: 16384 read back as 0.5 and -32768 as -1.0. Float input with the same magnitudes would be scaled to the [-1, 1) range and could clip, so convert the dtype deliberately.
