mirror of
https://github.com/HKUDS/CLI-Anything.git
synced 2026-08-28 23:27:04 +08:00
a92e590b02
In the RIFF/WAV format, 8-bit PCM samples are unsigned (0..255, silence
== 128), while 16/24/32-bit are signed. Both samples_to_wav_bytes() and
write_wav() packed 8-bit with a signed byte ("<b"), so every 8-bit file
was written with the wrong encoding. This module's own read_wav() decodes
8-bit as unsigned ((val - 128) / 128), and so does every standard player,
so 8-bit output was misdecoded: e.g. silence (0.0) round-tripped to full
scale (-1.0). The wav-8 export preset selects this path.
Pack 8-bit as unsigned ("<B", int_val + 128); int_val is already clamped
to [-128, 127]. Add an 8-bit write/read round-trip regression test
(TestWavIO only covered 16/24-bit).