Page 1 of 1
audioprocessing delaycompensation?
Posted: Thu Nov 07, 2013 3:17 pm
by Nubeat7
hi all,
in my last project i recognised an audible delay between the dry signal and the fx signal when using dry/wet mix
after putting a 1sample delay in the dry stream it sounds ok again
but now the outputsignal of my plugin is delayed by one sample, do i have to use the delay compensation primitive with one sample for this?
how can i identify the exact delay of the fx signal to do proper compensation?
here is a simple example schematic to show the issue and the way i tried to solve it,
i `doing this right?
Re: audioprocessing delaycompensation?
Posted: Thu Nov 07, 2013 4:59 pm
by Walter Sommerfeld
Hi Nubeat7,
look for 'Theuns Latency Analyzer ' in SM forum...
I also noticed a delay of one even if it's only a bypass...
Cheers,
Walter
Re: audioprocessing delaycompensation?
Posted: Thu Nov 07, 2013 6:10 pm
by Nubeat7
Thanks walter, very useful tool!
Re: audioprocessing delaycompensation?
Posted: Thu Nov 07, 2013 7:03 pm
by Nubeat7
okay i found out with this tool that a have a latency of 6 samples, and i found out that the cheapest way is to put 6 1 sample delays in a row inside the dry path to have no soundeffect when mix between dry and wet..
is this the common way?
hmm, but the story continues, i also have different routings, there are various serial/parallel combinations so depending on what routing i choose the latency differs from 0 to 6 samples..
okay i could build a selector inside the dry path and choose the needed latency for the individual routing, but what about the plugin delay compensationprimitiv?
am i able to change the samples on the fly, or is this initialized on loading the plugin into the host?
Re: audioprocessing delaycompensation?
Posted: Thu Nov 07, 2013 7:50 pm
by Nubeat7
Nubeat7 wrote:
okay i could build a selector inside the dry path and choose the needed latency for the individual routing, but what about the plugin delay compensationprimitiv?
am i able to change the samples on the fly, or is this initialized on loading the plugin into the host?
oh, got it, better to add the difference in the various routings, from fx path to dry path, into the fx path so that it is always 6 samples...
but still the question, is this methode with adding one sample delays the right way to do this, from view of performance i think it is okay costs me just 0.1-0.2% cpu on my i5 M480 2 x 2.66GHz ?
Re: audioprocessing delaycompensation?
Posted: Thu Nov 07, 2013 8:09 pm
by trogluddite
Nubeat7 wrote:am i able to change the samples on the fly, or is this initialized on loading the plugin into the host?
Possibly, but In a big project, changing the compensation value dynamically might cause a lot of internal re-calculating for the DAW - possibly making a CPU spike or audio glitch if done during playback. The documentation for Reaper warns about this, from what I recall.
But that may well depend on the host - the VST spec' only defines the API calls to set/get the value, but leaves it up to each DAW developer how they implement it.
Nubeat7 wrote:but still the question, is this methode with adding one sample delays the right way to do this, from view of performance
It all depends on the implementation. Using a regular 'Delay' FX module is definitely NOT the way to do it, as it uses a large buffer that has to be read using floating point assembly op's. But doing it the way that the single sample delay works, using discrete SSE variables, is much more efficient, so costs very little CPU. If you know the exact number of samples you need, then a small custom ASM routine might be slightly more efficient than multiple one-sample delay prim's, but any savings would be very small.
Re: audioprocessing delaycompensation?
Posted: Thu Nov 07, 2013 9:55 pm
by Nubeat7
trogluddite wrote:Possibly, but In a big project, changing the compensation value dynamically might cause a lot of internal re-calculating for the DAW - possibly making a CPU spike or audio glitch if done during playback. The documentation for Reaper warns about this, from what I recall.
ok,so it will be better to find out the maximum latency and set the delaycompensation to this samplevalue..
doing this i need to add extra delays also in the fx path when there is less latency then the maximum latency because of the routing or whatever...
this is going to be a real complex part, because i also have modulations for each fx their ppq sync modules are also adding latency when they are on

so all in all i have 6 different latencies in the fxpath
atm 14 onesampledelays in use + 2 asm selectors (which i need to avoid audioclicks on routingchanges) which should be all (i hope) - this all eats around 0.8% cpu in between
think there must be an asm solution for the whole latencycomp section.. anyway the whole plugin needs around 10% in full use which is already a lot..
so i would need a really lightweight sampledelay with min 1 sample and maximum 8 samples..
Re: audioprocessing delaycompensation?
Posted: Fri Nov 08, 2013 5:56 pm
by KG_is_back
This might be helpful. It is an optimized delay. it can delay mono4 stream, however the delay is equal in all 4 sse channels (the actual delay is taken form the first channel). The CPU consumption is roughly 1/3 compared to stock delay module and unlike the stock module (which has minimum delay of 1) it supports 0 sample delay.
Re: audioprocessing delaycompensation?
Posted: Fri Nov 08, 2013 8:55 pm
by Nubeat7
thanks KG, i also optimized the simple stock delay but to use the 4 channels independent so i can use just one module for the dry and the wet path but yours also when using 2 of it make 0.2% better cpu usage! and 0.6% better then using onesampledalays in series..
thanks for that!