C++ Developing a Scrolling Audio Timeline

65 views Asked by At

I am developing a QT multimedia audio application that needs to have an audio monitor feature. The application currently has regular callback (Signals/Slots) with PCM data samples (44.1khz, Stereo). In order to display microphone activity, I take every 100th slot callback and display it but that is not very useful as it is just a snapshot of one audio packet.

I need to display a live audio timeline similar to the ones seen on audio recorder tools like audacity or I would prefer a display timeline like that in a WhatsApp audio message with highs and lows following audio speech energy.

My plotting code uses QCustomPlot where it displays 1000 PCM16 audio samples where each Y value represents the audio value and X represents the time. I am thinking I need to do something along the following lines:

This previous X axis represented 1000 * (1/44100) (i.e. 4.1ms) of audio.

If instead I wish to have a 5 second horizontal scrolling window represented in this same 1000 point plot, then the entire window would correspond to 44100 * 5 (i.e. 220,500) PCM samples.

In order to display something meaningful in this window (for example an RMS calculation on the audio (see here), I am thinking that I would need to maintain a 1024 rms sample ring buffer to contain the updated audio signal. I would push in a new result once I have an rms result (220,500/1000) and discard the oldest or something along those lines.

0

There are 0 answers