Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to get QAudioBuffer from QAudioProbe in Pyqt5 ?



  • It's my first question here.

    I want to get the audio volume level when I use the QAudioRecorder, I looked it up in all websites, they told me to use audioBufferProbed signal from QAudioProbe, but what should I do after connecting the signal with the slot function to process the buffer, and I don't even know where the QAudioBuffer data is from

    a part of my code is below, what should I add to get access to processing the audio recoded by the recorder?
    Thank you!

            self.m_audioRecorder = QAudioRecorder()
            self.m_probe = QAudioProbe()
            self.m_probe.setSource(self.m_audioRecorder)
            self.m_probe.audioBufferProbed.connect(self.processBuffer)
            def processBuffer(self)
                    pass
    


  • The processBuffer function should have a QAudioBuffer as parameter.
    So when the function is called, you get a QAudioBuffer object, from the parameter.
    Sorry I don't use Py, but your processBuffer definition seems to need another parameter.



  • thank you ,so in C++ version where is the AudioBuffer object from?

    I saw code like this in C++ QT tutorial, I don't understand where the parameter buffer for processBuffer function is from

    connect(m_probe, &QAudioProbe::audioBufferProbed,
                this, &AudioRecorder::processBuffer);
    
    void AudioRecorder::processBuffer(const QAudioBuffer& buffer);
    

  • Lifetime Qt Champion

    @HandsomeLeonard said in How to get QAudioBuffer from QAudioProbe in Pyqt5 ?:

    I don't understand where the parameter buffer for processBuffer function is from

    Here: https://doc.qt.io/qt-5/qaudioprobe.html#audioBufferProbed
    The signal parameter is passed from the signal emitter (m_probe in your case).



  • @HandsomeLeonard change to def processBuffer(self, buffer):


Log in to reply