<div dir="auto"><div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le dim. 28 juill. 2019 16 h 34, Nicolas Dufresne <<a href="mailto:nicolas@ndufresne.ca">nicolas@ndufresne.ca</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le dim. 28 juill. 2019 14 h 55,  <<a href="mailto:virtually_me@claub.net" target="_blank" rel="noreferrer">virtually_me@claub.net</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I have some questions about the time resolution of audiointerleave.<br>
<br>
I have been working with gstreamer pipelines for a couple of years to<br>
implement loudspeaker crossovers via LADSPA plugins. This in general entails<br>
a number of steps from source to sink, including de-interleaving the<br>
incoming audio, teeing into N mono channels that are processed with one or<br>
more LADSPA plugins, and (re) interleaving the channels into a N channel<br>
"output stream" that is directed to a sink. Since the wall-clock processing<br>
time may be longer or shorter on each channel, the element audiointerleave<br>
is used to correct for the various latencies of each LADSPA-processed stream<br>
automatically. <br>
<br>
I am concerned that the resolution that audiointerleave can achieve is too<br>
low. My assumption is that the code looks for an optimum time-alignment<br>
point on a sample-by-sample basis. Is that correct? In that case the<br>
resolution would be about one sample in time, e.g. for 48kHz there is one<br>
sample every 0.0208 milliseconds.<br>
<br>
Let me explain how this would negatively impact my particular application. A<br>
3kHz tone one period is 0.33 milliseconds. Considering the phase within each<br>
period, there are 360 degrees. If the time resolution is 0.021 milliseconds<br>
then the phase resolution is 360deg * 0.021 msec / 0.333 msec = 33 degrees. <br>
<br>
A resolution of 33 degrees is not sufficient for my needs. This is because<br>
delay is often used to align the wavefronts that are launched by each driver<br>
in the loudspeaker, and the phase angle between one driver and the next<br>
needs to be maintained regardless of any processing latencies to a<br>
resolution of several degrees. In my example I chose 3kHz, however, the<br>
resolution in terms of phase will get worse and worse as frequency<br>
increases. For example at 6kHz the resolution increases to 66 degrees. The<br>
resulting phase angle would depend on the exact latency experienced by each<br>
stream before interleaving, and modifying the number of LADSPA plugins (or<br>
any other pipeline element) could have a very large and negative impact on<br>
the phase angle and resulting audio performance from the loudspeaker. <br>
<br>
Related to this issue, I would like to implement some type of delay for<br>
time-alignment as part of the loudspeaker crossover. I can do this using<br>
e.g. audioecho or by modifying timestamps, however, one-sample resolution<br>
will be insufficient. I need much better resolution.<br>
<br>
I would like to know what approaches might overcome this problem. If I<br>
increase the sample rate by N times I could improve the resolution by N<br>
times, however, I need an improvement by about an order of magnitude (10<br>
times) and such high samples rates are unachievable. Are there any other<br>
techniques that can be used within gstreamer to get a more fine-grained time<br>
resolution for synchronization purposes when interleaving streams? <br>
<br>
The only approach to get better time alignment (that can think of) prior to<br>
interleaving the streams would be to resample each mono stream to the<br>
pipeline sample rate plus a time offset that has a time resolution of ten<br>
microseconds or better. This would work, but would be rather computationally<br>
expensive. Is there a better or more efficient way that already exists<br>
within gstreamer?<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">That is an interesting project, indeed audiointerleave only supports per-sample alignment. It also have configurable tolerance to clock drift, which by default, is likely multiple samples.</div><div dir="auto"><br></div><div dir="auto">I'm not aware of such a thing as sub-sample interleaving in GStreamer. This discussion reminded me some aspect of Arun's beamforming blog. Which may of may not be of interest here.</div><div dir="auto"><br></div><div dir="auto">Of course adding such precision to audiointerleave would require a very close look at how we perform the initial alignment, as any overclip could be disastrous to your use case. And the an extra per stream offset will need to be maintained. Should this be in nanosecond, and what are the best algorithm for this, I don't know, and I'm not an expert, but I'm sure there is a slightly more efficient way then going through massive upsampling which would on top of adding more CPU, will also increase the memory bandwidth.</div></div></blockquote></div></div><div dir="auto"><br></div><div dir="auto"><a href="https://arunraghavan.net/2016/06/beamforming-in-pulseaudio/">https://arunraghavan.net/2016/06/beamforming-in-pulseaudio/</a><br></div><div dir="auto"><br></div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
_______________________________________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.freedesktop.org" rel="noreferrer noreferrer" target="_blank">gstreamer-devel@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" rel="noreferrer noreferrer noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a></blockquote></div></div></div>
</blockquote></div></div></div>