audioprocessing delaycompensation?

DSP related issues, mathematics, processing and techniques
Post Reply
User avatar
Nubeat7
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna
Contact:

audioprocessing delaycompensation?

Post 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?
Attachments
delaycompensation.fsm
(8.31 KiB) Downloaded 1448 times
User avatar
Walter Sommerfeld
Posts: 250
Joined: Wed Jul 14, 2010 6:00 pm
Location: HH - Made in Germany
Contact:

Re: audioprocessing delaycompensation?

Post 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
User avatar
Nubeat7
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna
Contact:

Re: audioprocessing delaycompensation?

Post by Nubeat7 »

Thanks walter, very useful tool!
User avatar
Nubeat7
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna
Contact:

Re: audioprocessing delaycompensation?

Post 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?
User avatar
Nubeat7
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna
Contact:

Re: audioprocessing delaycompensation?

Post 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 ?
User avatar
trogluddite
Posts: 1730
Joined: Fri Oct 22, 2010 12:46 am
Location: Yorkshire, UK

Re: audioprocessing delaycompensation?

Post 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.
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
User avatar
Nubeat7
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna
Contact:

Re: audioprocessing delaycompensation?

Post 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 :roll: 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..
KG_is_back
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: audioprocessing delaycompensation?

Post 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.
Attachments
optimal delay.fsm
(2.9 KiB) Downloaded 1425 times
User avatar
Nubeat7
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna
Contact:

Re: audioprocessing delaycompensation?

Post 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!
Post Reply