COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :

Go Back   Cockos Incorporated Forums > Other Software Discussion > WDL users forum

Reply
 
Thread Tools Display Modes
Old 01-08-2019, 10:30 AM   #1
Nonlinear
Human being with feelings
 
Join Date: Apr 2018
Posts: 178
Default Techniques for resetting when Reset() doesn't work?

I need to clear my plugin's buffers on either transport Stop or before Start and I have found several hosts that do not call Reset(). What's even worse is that these hosts (like Wavelab) suspend processing altogether when Play is stopped - so plugin buffers don't get flushed during idle either.

I have tested plugins by others in these same hosts and found that they DO reset - some on stop, some on play - so they must be using some other means to detect DAW status.

What other methods for flushing a plugin can be used on playback start/stop when "Reset()" doesn't work?


(BTW - my plugin is a compressor. If I don't flush it's buffers it will apply whatever gain reduction it had when last stopped to whatever new section the cursor is moved to causing a fade-in. If the compressor's Release time is set slow this can take many samples. Not good!)

Last edited by Nonlinear; 01-08-2019 at 12:26 PM.
Nonlinear is offline   Reply With Quote
Old 01-08-2019, 02:10 PM   #2
asenet
Human being with feelings
 
Join Date: Jun 2010
Posts: 9
Default

You could try to detect it yourself based on the play position.

Two cases might apply:
1. if old_playpos > new_playpos -> reset
2. if new_playpos > expected_playpos from last buffer -> reset

The first cases might be pretty simple to detect. The second case might be somewhat tricky.

But to be clear in general I see no reason why this is needed at all. If an user moves the playing position in the DAW it is OK that the plugin creates "wrong" results. If the DAW algorithm causes jumps the DAW is responsible to take care of this situation or it is a bug in the DAW. So don't bother about this non-issue any longer!
asenet is offline   Reply With Quote
Old 01-08-2019, 03:15 PM   #3
Nonlinear
Human being with feelings
 
Join Date: Apr 2018
Posts: 178
Default

Quote:
Originally Posted by asenet View Post
You could try to detect it yourself based on the play position.

Two cases might apply:
1. if old_playpos > new_playpos -> reset
2. if new_playpos > expected_playpos from last buffer -> reset

The first cases might be pretty simple to detect. The second case might be somewhat tricky.

But to be clear in general I see no reason why this is needed at all. If an user moves the playing position in the DAW it is OK that the plugin creates "wrong" results. If the DAW algorithm causes jumps the DAW is responsible to take care of this situation or it is a bug in the DAW. So don't bother about this non-issue any longer!
First of all, IMO, it is NOT OK if a plugin produces spikes, pops or wrong results as the play cursor is moved around by the user. Any plugins I have come across that behave like that I delete. Users have expensive monitors and don't want them blown by an errant plugin! There is NO WAY any DAW can prevent this because the DAW has no idea what code is in your plugin. The PLUGIN has to do it.

Now, regarding your suggestion (much appreciated), I have tried checking for position, "TransportIsPlaying", etc., from GetTimeInfo but the problem I ran into is where to place that code? If the DAW suspends processing on transport Stop where would this code be seen/run from the host?

I know this can be done because I have seen it done in other plugins - but HOW are they doing it? How are they detecting when playback starts/stops if Reset() is not called?
Nonlinear is offline   Reply With Quote
Old 01-08-2019, 04:03 PM   #4
asenet
Human being with feelings
 
Join Date: Jun 2010
Posts: 9
Default

Usually you call gettimeinfo in your process routine. There you can also check for the two cases I mentioned.

If the DAW is currently not playing you might also use the last timeinfo and check in a parallel thread if it has been changed or if it seems to be stopped.

All above mentioned techniques can be used to achive the behaviour you want but this is far away from good DSP code and should be treated very carefully.

I can agree that a DSP code should never create any harmful spikes (unless intended). But crackles, drops or any other harmless issues can be accepted if the user is doing the actions you mentioned.

Anyway: try also to solve the issues in your DSP code instead to workaround. In case of an compressor you could e.g. add a "security" limiter to avoid harmful spikes.
asenet is offline   Reply With Quote
Old 01-08-2019, 05:28 PM   #5
Nonlinear
Human being with feelings
 
Join Date: Apr 2018
Posts: 178
Default

Quote:
Originally Posted by asenet View Post
Usually you call gettimeinfo in your process routine. There you can also check for the two cases I mentioned.

If the DAW is currently not playing you might also use the last timeinfo and check in a parallel thread if it has been changed or if it seems to be stopped.

All above mentioned techniques can be used to achive the behaviour you want but this is far away from good DSP code and should be treated very carefully.

I can agree that a DSP code should never create any harmful spikes (unless intended). But crackles, drops or any other harmless issues can be accepted if the user is doing the actions you mentioned.

Anyway: try also to solve the issues in your DSP code instead to workaround. In case of an compressor you could e.g. add a "security" limiter to avoid harmful spikes.
Thank you for the input. Yes, it seems there are some quite complicated ways to do this that is above my skill level, especially when trying to make it work cross-platform. I do use DSP code protection internally in some cases.

So, there are no plugin functions for detecting transport stop/start? What are outboard transport controllers (apps and hardware) using to detect and control DAW transports? Is it possible for plugins to read that info?
Nonlinear is offline   Reply With Quote
Old 01-12-2019, 11:11 AM   #6
Nonlinear
Human being with feelings
 
Join Date: Apr 2018
Posts: 178
Default

Quote:
Originally Posted by Nonlinear View Post
So, there are no plugin functions for detecting transport stop/start?
I did some research and discovered that JUCE actually has TWO functions that deal with this: prepareToPlay() and releaseResources()

prepareToPlay() is used to initialize the plugin before playback starts and releaseResources() can be used to flush the plugin when playback stops.

This must be how other plugins I have observed are resetting on stop/start. I am not smart enough to figure out how to implement this in iPlug.
Nonlinear is offline   Reply With Quote
Old 01-12-2019, 11:41 AM   #7
asenet
Human being with feelings
 
Join Date: Jun 2010
Posts: 9
Default

Neither JUCE nor IPlug has the functionality build in you are looking for. The general lifecycle of plugins build with any of the mentioned meta frameworks are pretty similar. In case of Iplug it is just reset(), usually called by VST/AU/AAX when the plugin is initialised and playing starts.

Have you ever checked the opcodes called in the cases you are looking for? Just debug the code and find the opcode sequence for the plugin host. Maybe you spot any good opcode(s) to detect the DAW's "stop".
asenet is offline   Reply With Quote
Old 01-12-2019, 01:35 PM   #8
olilarkin
Human being with feelings
 
olilarkin's Avatar
 
Join Date: Apr 2009
Location: Huddersfield, UK
Posts: 1,135
Default

i just checked it with Wavelab 8.5 on macOS.

OnActivate() is called when playback is started/stoped

Looks like this hasn't changed since WDL-OL.

to test it you can implement OnActivate in your plug-in class and debug with wavelab...


void OnActivate(bool active) override
{
DBGMSG("%i\n", active);
}
__________________
VirtualCZ | pMix | Endless Series | iPlug2 | Linkedin | Facebook
Available for Audio Dev tuition via Skype (IPlug/JUCE/C++)
olilarkin is offline   Reply With Quote
Old 01-12-2019, 03:19 PM   #9
Nonlinear
Human being with feelings
 
Join Date: Apr 2018
Posts: 178
Default

Quote:
Originally Posted by olilarkin View Post
i just checked it with Wavelab 8.5 on macOS.

OnActivate() is called when playback is started/stoped

Looks like this hasn't changed since WDL-OL.

to test it you can implement OnActivate in your plug-in class and debug with wavelab...


void OnActivate(bool active) override
{
DBGMSG("%i\n", active);
}
YES! It works!

Thank you!

Last edited by Nonlinear; 01-12-2019 at 07:18 PM.
Nonlinear is offline   Reply With Quote
Old 01-13-2019, 06:59 AM   #10
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 7,559
Default

Quote:
Originally Posted by Nonlinear View Post
YES! It works!

Thank you!
Wow, I wouldn't have expected that to do anything useful since the IPlugBase.h comments says about OnActivate :

Code:
// Not usually needed ... Reset is called on activate regardless of whether this is implemented.
Maybe that comment should be changed?
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass, Paul(X)Stretch and λ) :
http://xenakios.wordpress.com/
Xenakios is online now   Reply With Quote
Old 01-13-2019, 11:12 AM   #11
Nonlinear
Human being with feelings
 
Join Date: Apr 2018
Posts: 178
Default

Quote:
Originally Posted by Xenakios View Post
Wow, I wouldn't have expected that to do anything useful since the IPlugBase.h comments says about OnActivate :

Code:
// Not usually needed ... Reset is called on activate regardless of whether this is implemented.
Maybe that comment should be changed?
Yes, something strange has happened here. Oli said this has always been part of WDL-OL - but then how come no one here seems to know this?

Maybe I'm just crazy but I swear the first time I tried this it did not do ANYTHING - but I tried it again yesterday and it does EXACTLY what I wanted.

Place this line in the public section of your plugin.h:

void OnActivate(bool active);

And place this code in your plugin.cpp:

void YourPlugin::OnActivate(bool active)
{
TRACE;
IMutexLock lock(this);
if (active/!active) {"Reset code";}
}


If "active" is true it launches the "Reset code" (or whatever else you want it to do) when DAW playback STARTS.

If active is false it launches the "Reset code" when playback stops.

This is the function was I hoping for in this thread. There are many other posts in this forum asking the same question with no replies. Finally the answer!

Last edited by Nonlinear; 01-13-2019 at 11:17 AM. Reason: OnActivate(bool active)
Nonlinear is offline   Reply With Quote
Old 01-13-2019, 11:17 AM   #12
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 7,559
Default

Quote:
Originally Posted by Nonlinear View Post

Maybe I'm just crazy but I swear the first time I tried this it did not do ANYTHING
Maybe you made a small typo with the function name or signature? Since C++11 you can use the keyword "override" to avoid those kinds of errors at compile time.

Code:
// correct, compiles as desired
void OnActivate(bool active) override;
Code:
// incorrect, causes compilation error if there is no virtual method with this name
void OnActivated(bool active) override;
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass, Paul(X)Stretch and λ) :
http://xenakios.wordpress.com/
Xenakios is online now   Reply With Quote
Old 01-13-2019, 11:19 AM   #13
Nonlinear
Human being with feelings
 
Join Date: Apr 2018
Posts: 178
Default

Quote:
Originally Posted by Xenakios View Post
Maybe you made a small typo with the function name or signature? Since C++11 you can use the keyword "override" to avoid those kinds of errors at compile time.

Code:
// correct, compiles as desired
void OnActivate(bool active) override;
Code:
// incorrect, causes compilation error if there is no virtual method with this name
void OnActivated(bool active) override;
That is VERY possible - but still doesn't explain why no one here seems to know about this function. Seems it would be required for many plugins. Whatever the case I'm VERY happy to have this!
Nonlinear is offline   Reply With Quote
Old 01-13-2019, 04:48 PM   #14
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 7,559
Default

Incidentally, I don't think it was ever discussed have you been working on a VST2 or a VST3 plugin...?
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass, Paul(X)Stretch and λ) :
http://xenakios.wordpress.com/
Xenakios is online now   Reply With Quote
Old 01-13-2019, 07:14 PM   #15
Nonlinear
Human being with feelings
 
Join Date: Apr 2018
Posts: 178
Default

Quote:
Originally Posted by Xenakios View Post
Incidentally, I don't think it was ever discussed have you been working on a VST2 or a VST3 plugin...?
I’m working on VST2 and VST3 right now for PC (x64) but hoping to expand this week to VST2, VST3 and AU for MAC as well. If it turns out that OnActivate only works in VST3 I will have to move forward however best I can with the others.
Nonlinear 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 02:13 PM.


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