Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Audio Recording from microphone to wav file in Qt
Forum Updated to NodeBB v4.3 + New Features

Audio Recording from microphone to wav file in Qt

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 2.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sergex
    wrote on last edited by
    #1

    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
        audioRecorder->setAudioInput(audioRecorder->defaultAudioInput());
    
        // Sets Output location where to store the file
        if(!m_outputLocationSet)
            setOutputLocation();
    
        // Set recording Settings
        QAudioEncoderSettings settings;
        settings.setCodec("audio/amr");     // Not sure what to put here
        settings.setSampleRate(16000);
        settings.setBitRate(32);
        settings.setQuality(QMultimedia::HighQuality);
        settings.setEncodingMode(QMultimedia::ConstantQualityEncoding);
    
        audioRecorder->setEncodingSettings(settings); 
        audioRecorder->record();
    }
    
    else {
        stopRecording();
    }
    

    }

    @

    Any guidance greatly appreciated! Thanks.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      messi
      wrote on last edited by
      #2

      Hi sergex.

      Use "QAudioEncoderControl::supportedAudioCodecs":http://doc.qt.digia.com/qtmobility-1.2/qaudioencodercontrol.html 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.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved