Hi,
On 14.06.2024 09:35, Roman Haefeli wrote:
Hey all
The Pd main window has an indicator for audio I/O errors that flashes red whenever it detected a buffer underrun. Is that information exposed in a way it can be accessed in a patch?
Currently no.
If not, would that be a worthwhile feature? I think: yes.
I think so too!
In the polling scheduler we already do handle xruns (by zeroing the buffers), so just need to also report it the patch. This can be easily done with an atomic integer counter. I might give it a shot.
In the callback scheduler things we are the mercy of the audio backend. AFAICT, portaudio does not provide any API to report xruns. Jack, on the other hand, allows to install an xrun callback (https://jackaudio.org/api/group__ClientCallbacks.html#ga08196c75f06d9e68f9a3...), which we could use for this purpose.
Actually, this feature would be quite handy for my AOO library. I have an API method to report xruns, but I can't really use it yet on Pd because I don't get the xrun information.
A patch using audio input for recording could immediately tell if the recording is garbage, for instance.
My current use case is for clocks: When a drop-out is detected, it is a good moment for re-syncing the clock as the steadiness is lost anyway at that moment and the drop-out is basically the only reason for clock drifts.
Side note: this is only true on the same machine. Different machines have sightly different audio clock speeds that also drift over time. That might be a problem, or not. That's why AOO, for example, offers dynamic resampling to compensate for clock drift effects.
The poor man's drop-out detection (and what I do now) is to compare [time] and [realtime]. However, the delta between them varies depending on the configured buffersize. Only if the delta is larger than the buffersize, one can be sure that a drop-out happened.
This method would only somewhat work with the callback scheduler. The very point of the (default) polling scheduler is to allow individual DSP ticks to exceed the audio buffer duration, as long as subsequent ticks can make up for it.
Having that info reliably from Pd directly would be definitely better.
Roman
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list