Details
-
Suggestion
-
Resolution: Out of scope
-
P3: Somewhat important
-
None
-
5.2.0
-
None
-
tested on Windows 7, 64-bit
Description
When I used QAudioProbe with QMediaPlayer to generate and visualize a Fast-Fourier Transform from the audio signal, I observed that the audio buffer is first played and then sent to QAudioProbe. In my case the buffer contained 4410 samples at 44.1KHz playback rate, so this equals 100ms of latency.
In other words: my visualization lags 100ms behind the audio playback. But every delay greater than 10-12 ms is recognized by human beings.
Suggestion: When the buffer has been filled, send it first to QAudioProbe and then send it to the output device. By retrieving the sample rate, it is then possible to synchronize visualization to the playback in a separate thread.
Example: If the buffer size equals 100ms of playback time, I can divide it into 10 ms chunks with time stamps and feed the viualization to another thread which can perform the visualization. This will not yield 100% accuracy, but it will be very close to the playback.
If you are using a ring-buffer with 2 or more buffers during audio playback This is a common technique), it should be possible to retrieve this information from QAudioProbe. I.e. this is another lag / timing offset, which any visualization code must take into account.
The same applies to QVideoProbe, using the frame rate and buffer sizes - but I didn't test this.