ALSA: QSoundEffect heavily distorted after migration from Qt5 to Qt6
-
After migrating from Qt 5.9 to Qt 6.4.3, playing sounds with QSoundEffect and the ALSA backend results in a heavily distorted audio output on my embedded system. While the correct sound effect does play, it's both far too loud and badly distorted. The command line
aplayutility is able to play the same WAV files just fine, without any distortion. Reducing the volume below 1% does help, but the distortion remains.System configuration:
- Raspberry Pi CM4
- Yocto Kirkstone
- MAX98357A I2S amplifier on a carrier board
Here's some captures from an oscilloscope showing the difference between the expect signal (
aplay), and the signal produced by QSoundEffect at 60% and .392156862% (1/255) volume respectively. Apologies for the quality of the captures, I'm no electrical engineer.



I've verified that the correct audio device is being selected, that I'm playing WAV files with a supported audio encoding (PCM s16le), and that the issue does not reproduce on a desktop development station (Ubuntu 20.04) running Qt6 (prebuilt binaries for Linux with pulseaudio/ALSA.)
Here's the multimedia configuration for my Qt build:
Qt Multimedia: Spatial Audio .......................... no Spatial Audio (Quick3D) ................ no Low level Audio Backend: ALSA (experimental) .................. yes PulseAudio ........................... no MMRenderer ........................... no CoreAudio ............................ no Windows Media SDK .................... no Open SLES (Android) .................. no Web Assembly ......................... no Plugin: GStreamer 1.0 ........................ yes FFmpeg ............................... no MMRenderer ........................... no AVFoundation ......................... no Windows Media Foundation ............. no Hardware acceleration and features: Video for Linux ...................... yes VAAPI support ........................ no Linux DMA buffer support ............. yes VideoToolbox ......................... noI also tried a Yocto build with pulseaudio, and a corresponding Qt build with PulseAudio enabled:
Qt Multimedia: Spatial Audio .......................... no Spatial Audio (Quick3D) ................ no Low level Audio Backend: ALSA (experimental) .................. no PulseAudio ........................... yes MMRenderer ........................... no CoreAudio ............................ no Windows Media SDK .................... no Open SLES (Android) .................. no Web Assembly ......................... no Plugin: GStreamer 1.0 ........................ yes FFmpeg ............................... no MMRenderer ........................... no AVFoundation ......................... no Windows Media Foundation ............. no Hardware acceleration and features: Video for Linux ...................... yes VAAPI support ........................ no Linux DMA buffer support ............. yes VideoToolbox ......................... noWhile I was able to play sounds via
paplaywhen using pulseaudio, QSoundEffect didn't play anything (including distorted audio), nor were any errors logged. I did verify that Qt was attempting to use the pulseaudio backend though, as stopping the pulseaudio server caused errors to be logged in the Qt application.Does anyone know what might be going on? Given that this broke after the migration from Qt5 to Qt6, I'm guessing it has something to do with the QtMultimedia rewrite, but I can't figure out what's happening; as far as I can tell, it's not an ALSA issue.