Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to to Audio Recording from microphone to wav file in Qt

How to to Audio Recording from microphone to wav file in Qt

Scheduled Pinned Locked Moved QML and Qt Quick
13 Posts 2 Posters 8.5k 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.
  • JKSHJ Offline
    JKSHJ Offline
    JKSH
    Moderators
    wrote on last edited by
    #2

    Hi,

    Open Qt Creator -> Welcome -> Examples, and search for "Audio Recorder Example". Are you able to use that to produce a wav file?

    Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

    1 Reply Last reply
    0
    • P Offline
      P Offline
      prabhatjha
      wrote on last edited by
      #3

      hey JKSH i am able to create wav file but when i tried to add this file in matlab am getting error that invalid wav file..incorrevt chunk size.......

      my code is given below:

      @QAudioEncoderSettings settings; settings.setCodec(“audio/pcm”); settings.setSampleRate(ui->lineEdit->text().toInt());

      settings.setBitRate(ui->lineEdit_2->text().toInt()); settings.setQuality(QMultimedia::HighQuality); settings.setEncodingMode(QMultimedia::ConstantQualityEncoding); audioRecorder->setEncodingSettings(settings, QVideoEncoderSettings(),“audio/x-wav”); audioRecorder->setContainerFormat(“wav”); audioRecorder->setOutputLocation(QUrl(“C:/Users/Kaptron3/Desktop/testprabhat5.wav”)); audioRecorder->record();

      1 Reply Last reply
      0
      • JKSHJ Offline
        JKSHJ Offline
        JKSH
        Moderators
        wrote on last edited by
        #4

        Hi prabhatjha,

        Yes I saw your code in your previous post.

        However, I meant: Are you able to produce a .wav file using the Audio Recorder Example in Qt Creator?

        Also, what happens if you open the .wav file in Windows Media Player?

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        1 Reply Last reply
        0
        • P Offline
          P Offline
          prabhatjha
          wrote on last edited by
          #5

          hmmm i am able to produce a .wav file and i am also able to play this file in media player properly.........but when i added this file in matlab it showing inavalid wav file .....and invalid chunk size.....

          1 Reply Last reply
          0
          • JKSHJ Offline
            JKSHJ Offline
            JKSH
            Moderators
            wrote on last edited by
            #6

            Then I don't think there's anything wrong with the .wav file.

            Are you sure your MATLAB code is correct? See http://www.mathworks.com.au/matlabcentral/newsreader/view_thread/108000

            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

            1 Reply Last reply
            0
            • P Offline
              P Offline
              prabhatjha
              wrote on last edited by
              #7

              ya i am sure i used wavread command in matlab through which we read the wav file in matlab........i am able to read other wave file from this command.....
              when i created .amr file from qt and changed this file in .wav through internet i can read this file in matlab.......so i think there is something chunk size issue ...

              1 Reply Last reply
              0
              • JKSHJ Offline
                JKSHJ Offline
                JKSH
                Moderators
                wrote on last edited by
                #8

                Can you upload a sample .wav file somewhere?

                Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                1 Reply Last reply
                0
                • P Offline
                  P Offline
                  prabhatjha
                  wrote on last edited by
                  #9

                  hey i have no idea how to upload my .wav file here.....
                  tell me your mail id ...i can send my .wav file on your mail id.
                  thanks for ur reply...

                  1 Reply Last reply
                  0
                  • JKSHJ Offline
                    JKSHJ Offline
                    JKSH
                    Moderators
                    wrote on last edited by
                    #10

                    Sorry for the delay. You can upload your file to a file hosting site (Dropbox, Google Drive, Microsoft OneDrive, etc.) and post the link here.

                    Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                    1 Reply Last reply
                    0
                    • P Offline
                      P Offline
                      prabhatjha
                      wrote on last edited by
                      #11

                      https://drive.google.com/file/d/0BwR7_R9HuUvpRmhSMEVYa1FOYm8/edit?usp=sharing

                      1 Reply Last reply
                      0
                      • P Offline
                        P Offline
                        prabhatjha
                        wrote on last edited by
                        #12

                        Hey, i did recording from microphone using qt in .wav file.
                        i am able to play this file in media playe.but when i added this file in matlab for wavread this is giving a error invalid chunk size …..
                        and throgh matlab code i fixed the chunk size of my .wav file .
                        the matlab code is given below….
                        function wavchunksizefix( test13)
                        d = dir(‘test13.wav’);
                        fileSize = d.bytes
                        fid=fopen(‘test13.wav’,‘r+’,‘l’);
                        fseek(fid,4,-1);
                        fwrite(fid,fileSize-8,‘uint32’);
                        fseek(fid,40,-1);
                        fwrite(fid,fileSize-44,‘uint32’);
                        fclose(fid);
                        but i want to fix this problem throgh qt code.
                        plzzz give me some hint.

                        1 Reply Last reply
                        0
                        • JKSHJ Offline
                          JKSHJ Offline
                          JKSH
                          Moderators
                          wrote on last edited by
                          #13

                          Hi,

                          I downloaded your .wav file and followed the diagram at https://ccrma.stanford.edu/courses/422/projects/WaveFormat/

                          Your file size is 956132 bytes.

                          Inside the file,

                          • Byte 4: ChunkSize = 956124 (= fileSize-8)
                          • Byte 40: Subchunk2Size = 956080

                          ChunkSize is correct, but Subchunk2Size is wrong (it should be 956088).

                          So you are right, the WAVE file that QMediaRecorder produced has a wrong value. This is a bug, but I don't know where the bug came from. Qt uses the Windows multimedia backend to record audio.

                          Can you check if you can produce a "good" wave file, using Windows Sound Recorder? (If you use Windows 7 or 8, follow this: http://social.technet.microsoft.com/Forums/windows/en-US/bd9563fe-a3ec-49c3-8b28-a2f8ed1082eb/record-wav-audio )

                          If Sound Recorder works, then it's likely to be a Qt bug. Please submit a bug report to http://bugreports.qt-project.org/

                          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                          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