The fallback divided every decode by 32768.0, which is only correct for
16-bit input. pydub reports 8-bit as sample_width 1 and widens 24-bit to a
full-range int32 (sample_width 4), so a reference clip came back 32768x too
loud for 24- and 32-bit sources and 256x too quiet for 8-bit ones. Nothing
downstream clamps, so the clip silently became noise.
Measured on x86_64 with pydub 0.25.1, peak of a 0.5-amplitude sine:
PCM_U8 0.00195 PCM_24 32768.0
PCM_16 0.5 PCM_32 32768.0
Catching ImportError made this reachable for everyone: before, the fallback
ran only for formats torchaudio could not open, but on torchaudio >= 2.9
without TorchCodec it is the only path, turning a loud failure into a silent
wrong result. Fixing it here rather than leaving it for the next reader.
pydub already exposes the right divisor as max_possible_amplitude. No 24-bit
special case is needed: its own comment claims 24-bit values are "not scaled
up to the 32 bit range", but the conversion writes the pad byte first, so it
lands in the LSB and the sample does occupy the full int32 range. Verified
empirically across all five subtypes above.
Also corrects this file's motivation: torch 2.8.0 from the pinned cu128
index does carry sm_120 (arch_list confirmed on an sm_120 device, matching
CU128_ARCHS in tests/test_cuda_arch_compat.py), so the earlier claim that
RTX 50-series owners must leave the pin was wrong.
Raised by CodeRabbit and Greptile on the PR.
Signed-off-by: Moep90 <volleyballlive@googlemail.com>
Signed-off-by: moep90 <volleyballlive@googlemail.com>