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. Setting encoding format [solved]
Forum Updated to NodeBB v4.3 + New Features

Setting encoding format [solved]

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 3.3k 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.
  • W Offline
    W Offline
    wizmer
    wrote on 8 Dec 2013, 22:30 last edited by
    #1

    Hi everyone,

    I'm trying to save in a file my microphone output in a certain format (to be used by the speech recognition library CMU sphinx). The format has to be a single-channel (monaural), little-endian, unheadered 16-bit signed PCM audio file sampled at 16000 Hz.

    I'm currently using these parameters:
    @ QAudioEncoderSettings settings;
    settings.setSampleRate(16000);
    settings.setCodec("audio/PCM");
    settings.setBitRate(16);
    settings.setEncodingMode(QMultimedia::ConstantBitRateEncoding);
    audioRecorder->setEncodingSettings(settings,QVideoEncoderSettings());@

    The only thing I managed so far is setting it in 16 kHz.
    I thought that using settings.setBitRate(16) would produce a 16bit file but audacity tells me that the file is 32bit and stereo.
    And about the other parameters, I don't even know how to check them (is it single-channel ? monaural ? PCM ?...)

    Can somebody help me to understand these QAudioEncoderSettings methods ?

    Thank you !

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 8 Dec 2013, 23:18 last edited by
      #2

      Hi and welcome to devnet,

      You don't seem to set the channelCount to 1

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • W Offline
        W Offline
        wizmer
        wrote on 8 Dec 2013, 23:31 last edited by
        #3

        Ah !! Yes indeed, now I get a monaural format. Thank you !

        I still have a sample size of 32 bit instead of 16.
        By playing with the audiorecorder example I noticed that the codecs
        audio/vorbis and audio/FLAC produce 16bit sample sizes while audio/PCM produce 32bit sample sizes.
        Is it something fixed for each codec or can it be changed ?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 9 Dec 2013, 09:29 last edited by
          #4

          AFAIK, it should not be fixed, what OS/Qt Version are you on ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • W Offline
            W Offline
            wizmer
            wrote on 9 Dec 2013, 16:39 last edited by
            #5

            I am running under Lubuntu 64 bit with Qt 5.1.1
            I finally solved the problem by using QAudioInput instead of an QAudioRecorder object. This allowed me to set my settings via QAudioFormat instead of QAudioEncoderSettings. A difference between the two classes is that the latest has a method setSampleSize. I posted a sample code here: http://stackoverflow.com/a/20462224/2533394

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 9 Dec 2013, 21:44 last edited by
              #6

              I have overlooked QAudioRecorderSettings, the sample size is indeed not there. I don't know if it's missing on purpose or not. You could ask on the interest mailing list if you would like to know more

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0

              1/6

              8 Dec 2013, 22:30

              • Login

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