Qt audio loudness level



  • Hi.
    How can I meter loudness level of a streaming voice from microphone by qt? Is it that what I want?

    audioRecorder = new QAudioRecorder;
    
    QAudioEncoderSettings audioSettings;
    audioSettings.setCodec("audio/amr");
    audioSettings.setQuality(QMultimedia::HighQuality);
    
    audioRecorder->setEncodingSettings(audioSettings);
    
    audioRecorder->setOutputLocation(QUrl::fromLocalFile("test.amr"));
    
    audioProbe = new QAudioProbe(this);
    if (audioProbe->setSource(audioRecorder)) {
    // Probing succeeded, audioProbe->isValid() should be true.
    connect(audioProbe, SIGNAL(audioBufferProbed(QAudioBuffer)),
            this, SLOT(calculateLevel(QAudioBuffer)));
    }
    
    audioRecorder->record();
    

    And whats the output of this code? What audio standard(decibel or others) is its output?

    calculateLevel(QAudioBuffer)
    

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    AFAIK, there's only one standard to measure audio loudness it's decibel but you have to calculate that yourself.

    You have all the information available through the QAudioBuffer class in order to calculate that.



  • Tnx but could you tell me how can I calculate it(stream audio) as decibel by this class?
    I'm an absolute beginner.tnx


  • Qt Champions 2016

    Hi
    You have access to the raw buffer
    http://doc.qt.io/qt-5/qaudiobuffer.html#constData
    that has a given volume/loudness so its not exact science but you can google
    around for various ways ( sorry, not sound expert so cant give any concrete solution)
    https://stackoverflow.com/questions/2445756/how-can-i-calculate-audio-db-level


Log in to reply
 

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