These are chat archives for supercollider/supercollider

17th
Apr 2017
Nathan Ho
@snappizz
Apr 17 2017 13:39
@baadc0de I don't understand latency compensation in this context too well... can you explain in more detail?
Bojan Šernek
@baadc0de
Apr 17 2017 13:41
sure. usually audio APIs (like ASIO on Windows) operate in a double-buffered mode, where you submit a buffer A and receive a buffer B back "at the same time". The A buffer contains data you wish for the driver to output and the B buffer is what was recorded last.
let's assume you have an analog audio device that takes its input from soundcard outputs and sends its output back to a soundcard input
when you submit buffer A, you will get the samples processed by the analog device with the next submitted buffer
so not in the current B but next B
additionally because of how A/D and D/A converters work, there is a filtering and conversion latency that happens between the first sample being output and the first sample being recorded
so if you sent 512 samples of white noise in a buffer A, you would still get buffer Bnext of 512 samples length, but the actual first processed sample would appear after some silence. Let's say additional 30-or-so samples for filters and conversion
so now if you want to sample accurately mix dry and wet signals (where wet is what is processed by the analog device)
you need to align those two
hence my question, is this something that is fairly easy to do in SC?
Nathan Ho
@snappizz
Apr 17 2017 13:48
If I'm understanding the problem correctly, wouldn't a correctly calculated delay line do the trick?
Bojan Šernek
@baadc0de
Apr 17 2017 13:51
indeed. if you delay the original by (driver buffer size in samples + fixed filter and conversion delay) both signals are in sync.
But I'm really new to SC so I was not sure if, on a high level, SC can communicate with the audio device in such a way?
Nathan Ho
@snappizz
Apr 17 2017 13:56
ControlDur.ir will give you the buffer size.
DelayN.ar is the best way to add a fixed delay (or DelayC if you need sub-sample accuracy).
Bojan Šernek
@baadc0de
Apr 17 2017 13:57
just samples is fine.
thanks, now to just figure out where to actually start :)
Nathan Ho
@snappizz
Apr 17 2017 13:58
The D/A and A/D converter latencies, you'll have to get from the soundcard manual ofc.
(Unless there's some metadata system for soundcards that I'm not aware of)
Bojan Šernek
@baadc0de
Apr 17 2017 13:59
there is for certain drivers, but in this case I have the exact ones supplied by the manufacturer, so I'm good on that
Nathan Ho
@snappizz
Apr 17 2017 13:59
cool
Bojan Šernek
@baadc0de
Apr 17 2017 14:00
(for reference, on ASIO: http://comp.ist.utl.pt/ec-ra/Laboratorio/ASIO%20SDK%202.pdf check out ASIOGetLatencies())