Qt recorder messes up wav.header?



  • Hello,

    I am trying to record sound via the microphone with Qt but I have come across something really strange. Although my code is almost identicall to the one of the audiorecorder examplte provided in the Qt documentation, the file that is produced by the audiorecorder in my code has always an alleged length of of 13:31:35. How do I fix this problem?

    Here is my code:

    @void MainWindow::on_pushButtonrecord_clicked()
    {

    QAudioRecorder* audioRecorder = new QAudioRecorder;
    if(record == false)
    {
    audioRecorder->setAudioInput(audioRecorder->audioInput());
    audioRecorder->setOutputLocation(QUrl::fromLocalFile("test.wav"));

    QAudioEncoderSettings audioSettings;
    audioSettings.setCodec("audio/pcm");
    audioSettings.setSampleRate(44100);
    audioSettings.setBitRate(32000);
    audioSettings.setQuality(QMultimedia::EncodingQuality(16000));
    audioSettings.setEncodingMode(QMultimedia::ConstantQualityEncoding);
    
    audioRecorder->setEncodingSettings(audioSettings,QVideoEncoderSettings(),"audio/x-wav");
    
    audioRecorder->record();
    record = true;
    

    }
    else
    {
    audioRecorder->stop();
    }
    }@


Log in to reply
 

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