Audio Recording from microphone to wav file in Qt

  • Hello, I am trying to do an application with the purpose of being able to record phrases and have them automatically saved in a chosen directory as wav files. For this I am trying to use the QAudioRecorder class. When I hit the record button I speak something into the microphone and .wav file gets saved into the directory that I chose with the name that I want but when I playback the file it is just noise. I don't think I am using the recording class properly.

    What I have so far is :

    void RecordingWidget::startRecording()
    if(audioRecorder->state() == QMediaRecorder::StoppedState)

        //Set Audio Input
        // Sets Output location where to store the file
        // Set recording Settings
        QAudioEncoderSettings settings;
        settings.setCodec("audio/amr");     // Not sure what to put here
    else {



    Any guidance greatly appreciated! Thanks.

  • Hi sergex.

    Use "QAudioEncoderControl::supportedAudioCodecs": first to find out which codec your system support.

    One of this codec is responsible for wav.
    Take this string an add with setCodec()

    Also check QAudioEncoderControl::supportedEncodingOptions for this codec to be sure the everything is set correctly.

Log in to reply

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