[SOLVED]: click when reproducing audio

  • Hello,
    following the documentation I use this code to play a wave file:


    QAudioFormat format;
    QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());
    if (!info.isFormatSupported(format)) {
       qWarning() << "Raw audio format not supported by backend, cannot play audio.";
    m_audio = new QAudioOutput(format, this);


    But when the audio start I hear a "click" noise.
    Playing the some file with another player (aplay for example) there is no such a noise.

    My platform is Raspberry Pi, Qt5.2, custom buildroot image.

  • What is the file Format of the audio file? That click is probably the header of the wave file?

  • It's a standard PCM Wave, 44100 Hz, 16-bit Stereo.
    Do you mean Qt doesn't take care of the header section!?
    So, how to correctly play a standard wave file?

    I tried with QMediaPlayer but I get the following warning and no audio:

    defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.mediaplayer"

  • You'll have to read the header yourself and set the output format accordingly. You can find the header definition here: https://ccrma.stanford.edu/courses/422/projects/WaveFormat/ or take a look at http://qt-project.org/doc/qt-4.8/demos-spectrum-app-wavfile-cpp.html

  • Skipping the header file leads to no click at all.
    I'm going to parse the header to extract the actual audio format - anyway it's a pity Qt doesn't handle this by itself!


  • Solved using the class you linked. Thanks again

  • I agree, I also think that Qt should provide the reading/writing of Audio files, at least for some basic formats ...

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.