COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 05-09-2015, 05:16 AM   #1
random_id
Human being with feelings
 
random_id's Avatar
 
Join Date: May 2012
Location: PA, USA
Posts: 356
Default Latency Best Practices

I have a problem with SetLatency, and I am trying to figure out "Best Practices" for handling it. The problem is related to Cubase and Wavelab. Everything works with the plugins until rendering, then there are problems and crashes. I don't have anything in my code that checks for the rendering status, and I am almost positive it is related to SetLatency.

I have been using something similar for changing latency to this thread (http://forum.cockos.com/showthread.p...hlight=latency). Whenever a parameter changes that affects latency, a bool is set. In ProcessDoubleReplacing(), the bool is checked at the start. If needed, the latency is changed. This has been working well with other host formats. In fact, it was the only way I could find to make Studio One not crash with VST3 format (even though it makes sense to not put the SetLatency() in ProcessDoubleReplacing()).

So, back to my issue with VST3 and Steinberg. A little searching and I found an similar problem with JUCE (http://www.juce.com/forum/topic/repo...lug-ins?page=1). It looks like the solution is to have SetLatency() use an asynchronous callback. With all of the MutexLocks, what would be a good solution?
__________________
Website: LVC-Audio
random_id is offline   Reply With Quote
Old 05-10-2015, 07:21 AM   #2
random_id
Human being with feelings
 
random_id's Avatar
 
Join Date: May 2012
Location: PA, USA
Posts: 356
Default

One other thing to add...

I was focusing all of my efforts on fixing latency with VST3 and Steinberg app; however, a user also informed me of an issue with Bitwig (VST2). In Bitwig, latency is never recalculated. In my limiter plugin, I have oversampling and lookahead, both of which will change latency.

I wasn't necessarily expecting Bitwig to calculate on-the-fly latency like Reaper, but it won't change even after starting and stopping playback. At this point, I have tried SetLatency() in the ProcessDoubleReplacing() (as mentioned above) and in Reset(). I looked at a couple other plugins (I think JUCE-based), and the latency was changing during playback.
__________________
Website: LVC-Audio
random_id is offline   Reply With Quote
Old 05-11-2015, 10:04 AM   #3
random_id
Human being with feelings
 
random_id's Avatar
 
Join Date: May 2012
Location: PA, USA
Posts: 356
Default

I haven't figured out VST3 yet, but I do have something that is helping Bitwig update the displayed latency for VST2 formats
In IPlugVST.cpp
Code:
void IPlugVST::SetLatency(int samples)
{
  mAEffect.initialDelay = samples;
  IPlugBase::SetLatency(samples);
  InformHostOfProgramChange();// <-adding this line
}
__________________
Website: LVC-Audio
random_id is offline   Reply With Quote
Old 07-19-2016, 09:23 AM   #4
Youlean
Human being with feelings
 
Youlean's Avatar
 
Join Date: May 2015
Location: Serbia
Posts: 654
Default

Did you figured out VST3 latency report?
Youlean is offline   Reply With Quote
Old 07-21-2016, 05:03 AM   #5
random_id
Human being with feelings
 
random_id's Avatar
 
Join Date: May 2012
Location: PA, USA
Posts: 356
Default

Quote:
Originally Posted by Youlean View Post
Did you figured out VST3 latency report?
I think most hosts do a decent job with VST3 latency; however, I sometimes run into problems with Steinberg stuff. It appears that SetLatency() for VST3 needs to be within a particular thread for it to work.

At this point, I set latency within the plugin's Reset() method. I also have a check within ProcessDoubleReplacing(). I have a bool that is set whenever latency is changed, and will call the SetLatency() if needed.

One other thing I did was add this to IPlugVST3::SetLatency()
Code:
void IPlugVST3::SetLatency(int latency)
{
  IPlugBase::SetLatency(latency);

  FUnknownPtr<IComponentHandler>handler(componentHandler);
  if (handler != nullptr){ //added this to prevent crashes
    handler->restartComponent(kLatencyChanged);
  }
}
__________________
Website: LVC-Audio
random_id is offline   Reply With Quote
Old 07-21-2016, 06:09 AM   #6
Youlean
Human being with feelings
 
Youlean's Avatar
 
Join Date: May 2015
Location: Serbia
Posts: 654
Default

Thanks.

Are still using this code for VST2:

Code:
void IPlugVST::SetLatency(int samples)
{
  mAEffect.initialDelay = samples;
  IPlugBase::SetLatency(samples);
  InformHostOfProgramChange();// <-adding this line
}
I noticed also crashes in VST3 because of handler...
Youlean is offline   Reply With Quote
Old 07-21-2016, 12:01 PM   #7
random_id
Human being with feelings
 
random_id's Avatar
 
Join Date: May 2012
Location: PA, USA
Posts: 356
Default

Yes, I am still using it for VST. I haven't run into issues lately with latency, so I am hopeful that is working on most hosts. I try to test with a bunch, but it is hard to hit every major DAW.
__________________
Website: LVC-Audio
random_id is offline   Reply With Quote
Old 07-26-2016, 10:51 AM   #8
Youlean
Human being with feelings
 
Youlean's Avatar
 
Join Date: May 2015
Location: Serbia
Posts: 654
Default

Great, thanks!
Youlean is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 08:51 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.