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 12-19-2017, 05:26 PM   #1
Guod3
Human being with feelings
 
Guod3's Avatar
 
Join Date: Jan 2008
Posts: 456
Default How to tell OnParamChange() called by user or host?

I need to respond to a parameter change slightly differently if the parameter change is the result of user action rather than the host loading the plugin state. How is this done?
Thanks
Guod3 is online now   Reply With Quote
Old 12-19-2017, 06:00 PM   #2
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 257
Default

Not sure if there's a specifically used approach, but it's possible to handle it. What type of control is it and what do you want to do with it?
Bobflip is offline   Reply With Quote
Old 12-19-2017, 06:14 PM   #3
Guod3
Human being with feelings
 
Guod3's Avatar
 
Join Date: Jan 2008
Posts: 456
Default

The plugin controls outboard hardware (Lexicon MX400) via midi.
One of the controls selects the effect type.
If the *user* changes the effect type, then all the settings need to be reset to defaults for the newly chosen effect.
But if the *Host* sets the effect type then the settings need to be sent as stored in the host's plugin parameters (not defaults).
(naturally the effect type and all settings are both plugin parameters)
Guod3 is online now   Reply With Quote
Old 12-19-2017, 06:29 PM   #4
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 257
Default

Other people on here might have other suggestions, but I'd try separating the effect type parameter and the effect type selector control. This way kEffectType can be stored in presets and modified by the host, and the OnParamChange case for kEffectTypeSelector would be able to change kEffectType's value as well as include code to reset the parameters to default.

A while ago I'd have set up an OnClick or IsClicked function in the control, but I think the above would be cleaner and more efficient.
Bobflip is offline   Reply With Quote
Old 12-19-2017, 07:38 PM   #5
Guod3
Human being with feelings
 
Guod3's Avatar
 
Join Date: Jan 2008
Posts: 456
Default

Thanks so much for your input.
So now have 2 parameters:
kEffectType (no gui control)
kEffectTypeSelector (with gui control)
Code:
*pseudocode*
in OnParamChange(int paramIdx):
.
.
case (kEffectType):
    send out Effect type CC to midi

case (kEffectTypeSelector ):
    if value of parameter EffectType != EffectTypeSelector (user has acted?) 
          set all params to default
          assign value of EffectTypeSelector to EffectType
          call  OnParamChange() for all affected parameters
Is this like what you had in mind?
Thanks again.
Guod3 is online now   Reply With Quote
Old 12-19-2017, 07:45 PM   #6
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 257
Default

That's the kind of thing, though you wouldn't need the last line to call OnParamChange as that should be done when you set all params to default (I think I use "GetGUI()->SetParameterFromPlug(kParameterName, <value>, false);" for that)

Also I think the second to last line would need the EffectTypeSelector and EffectType swapped over.

You'd probably also need to add a line into the kEffectType case to update the selector control.
Bobflip is offline   Reply With Quote
Old 12-19-2017, 07:57 PM   #7
Guod3
Human being with feelings
 
Guod3's Avatar
 
Join Date: Jan 2008
Posts: 456
Default

Quote:
Originally Posted by Bobflip View Post
Also I think the second to last line would need the EffectTypeSelector and EffectType swapped over.
User has changed EffectTypeSelector and we want EffectType to mirror this, right?
Quote:
Originally Posted by Bobflip View Post
You'd probably also need to add a line into the kEffectType case to update the selector control.
In the case the Host update the plugin state the values *should* be the same although I suppose it wouldn't hurt to update here.
Guod3 is online now   Reply With Quote
Old 12-19-2017, 08:04 PM   #8
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 257
Default

Yes to the first question, and for the second, you'd want the selector control to display the currently selected effect type if a preset is loaded.

Come to think of it, it may not be 100% necessary but I figure it'd be best to keep both parameters matched. It may end up needing tweaks to suit your needs but give it a try and see if it works as hoped.
Bobflip is offline   Reply With Quote
Old 12-19-2017, 10:02 PM   #9
Guod3
Human being with feelings
 
Guod3's Avatar
 
Join Date: Jan 2008
Posts: 456
Default

I'm getting correct values
DBGMSG("FxType1Control %d %d", GetParam(kFx1TypeControl)->Int(), GetParam(kFx1Type)->Int());
in OnParamChange().

However copying the values isn't working:
GetGUI()->SetParameterFromPlug(kFx1Type, GetParam(kFx1TypeControl)->Int(),false);
After the call, GetParam(kFx1Type)->Int() yields the old value.
Have I missed something?
The other params that get set to defaults are changing though.
Could it be the non GUI kFx1Type needs a different call to set it?
Guod3 is online now   Reply With Quote
Old 12-19-2017, 10:13 PM   #10
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 257
Default

Ah, may be that you need to set the IsMeta flag in the constructor for every parameter that the plugin will change.

GetParam(kParameterName)->SetIsMeta(true);
Bobflip is offline   Reply With Quote
Old 12-19-2017, 10:16 PM   #11
Guod3
Human being with feelings
 
Guod3's Avatar
 
Join Date: Jan 2008
Posts: 456
Default

GetParam(kFx1Type)->Set(GetParam(kFx1TypeControl)->Int());
is the correct call for this situation and is working!

[edit] just saw your reply, I'll keep that in mind, thanks.
Guod3 is online now   Reply With Quote
Old 12-19-2017, 10:23 PM   #12
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 257
Default

Ah, I'm still not fully sure of the difference between the various calls to set a value, though I bit that one from my own code. Glad you have it working anyway!
Bobflip is offline   Reply With Quote
Old 12-21-2017, 04:55 PM   #13
Guod3
Human being with feelings
 
Guod3's Avatar
 
Join Date: Jan 2008
Posts: 456
Default

I have it working well in Reaper and Savihost.
Ableton 9 and Bitwig 2 are both disfunctional.
I won't post the details just yet. Ideally I'll find a way to obtain the correct functionality I'm after with all the hosts I can test. Alternatively I can use host detection to workaround the dissimilarities (unfortunately host's support for GetHostNameStr is not uniformly implemented). Live9 and BW2 both reset knobs to 0 on change and seem to respond to the effect type using the the non gui (host) plugin control.
I guess these are among the challenges for plugin developers!
Guod3 is online now   Reply With Quote
Old 12-21-2017, 05:00 PM   #14
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 257
Default

Bleh, yeah sometimes things just don't work the way you think they should! Did you try SetParamFromPlug instead of Set along with the SetIsMeta flag?
Bobflip is offline   Reply With Quote
Old 12-22-2017, 03:59 AM   #15
stw
Human being with feelings
 
stw's Avatar
 
Join Date: Apr 2012
Posts: 246
Default

Quote:
Originally Posted by Bobflip View Post
Ah, I'm still not fully sure of the difference between the various calls to set a value, though I bit that one from my own code. Glad you have it working anyway!
I once made a comparison of these functions here: Maybe it's helpful

Referring to the initial question: Maybe this is an option?
stw is offline   Reply With Quote
Old 12-22-2017, 07:26 AM   #16
Guod3
Human being with feelings
 
Guod3's Avatar
 
Join Date: Jan 2008
Posts: 456
Default

Maybe it's helpful sure looks helpful, thanks! Need to absorb it and experiment but this kind of info is super welcome.

I'll look at trying this. The dual parameter method I've been working with is a little untidy in that you have extra duplicated parameters visible in the hosts control interface for the plugin. Keeping them in sync has been a challenge so far.
Guod3 is online now   Reply With Quote
Old 12-22-2017, 07:38 AM   #17
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 257
Default

Ah, that can also be sorted by using public/private parameters, and also GetParam(kName)->SetCanAutomate(false);
Bobflip is offline   Reply With Quote
Old 12-22-2017, 07:42 AM   #18
Guod3
Human being with feelings
 
Guod3's Avatar
 
Join Date: Jan 2008
Posts: 456
Default

Quote:
Originally Posted by Bobflip View Post
Ah, that can also be sorted by using public/private parameters, and also GetParam(kName)->SetCanAutomate(false);
So a parameter can be hidden from the host plugin controls?
Guod3 is online now   Reply With Quote
Old 12-22-2017, 08:36 AM   #19
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 257
Default

Yep. Doing this is also handy for things like readouts for controls, or a logo that you click on to bring up preferences.

It's not quite finished on the WDL-Youlean framework, but that's the overall idea.
Bobflip is offline   Reply With Quote
Old 12-22-2017, 08:37 AM   #20
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 257
Default

Quote:
Originally Posted by stw View Post
I once made a comparison of these functions here: Maybe it's helpful

Referring to the initial question: Maybe this is an option?
That comparison is helpful! It might be good if we had a sticky 'threads/snippets of interest' thread on the forum with things like this that can trip up new users otherwise.
Bobflip is offline   Reply With Quote
Old 12-23-2017, 04:23 AM   #21
olilarkin
Human being with feelings
 
olilarkin's Avatar
 
Join Date: Apr 2009
Location: Huddersfield, UK
Posts: 1,066
Default

there is a mod to do this here:

https://github.com/AlexHarker/wdl-ol...2897e651b19869

haven't tried it
__________________
VirtualCZ | pMix | Endless Series | WDL-OL | Linkedin | Facebook
Available for Audio Dev tuition via Skype (IPlug/JUCE/C++)
olilarkin is online now   Reply With Quote
Old 12-23-2017, 04:37 AM   #22
earlevel
Human being with feelings
 
Join Date: Dec 2015
Posts: 264
Default

Quote:
Originally Posted by Bobflip View Post
Yep. Doing this is also handy for things like readouts for controls, or a logo that you click on to bring up preferences.
Not being nitpicky, just wondering if I’m missing something. In the first, you’d just use the same parameter for the control and readout (also a control). In the second example, there’s no reason to have a parameter.
earlevel is offline   Reply With Quote
Old 12-23-2017, 12:02 PM   #23
Guod3
Human being with feelings
 
Guod3's Avatar
 
Join Date: Jan 2008
Posts: 456
Default

Quote:
Originally Posted by olilarkin View Post
there is a mod to do this here:

https://github.com/AlexHarker/wdl-ol...2897e651b19869

haven't tried it
Looks worth a try.

BTW: At reset or preset recall can it be reliably assumed that among various hosts that parameter change OnParamChange calls happen in sequenced order by their enum order? (that is, the order of OnParamChange calls is the order of the enum Eparams)
Guod3 is online now   Reply With Quote
Old 12-23-2017, 01:53 PM   #24
Guod3
Human being with feelings
 
Guod3's Avatar
 
Join Date: Jan 2008
Posts: 456
Default

It seems to work, and demystifies where all the OnParamChange() calls are coming from. This is good for me.
Code:
(IPlugBase.h)
  enum ParamChangeSource { kReset, kAutomation, kPresetRecall, kGUI, kUnknown };
I'll be adding kPlugin to identify calls to OnParamChange() from within the plugin code.
Guod3 is online now   Reply With Quote
Old 12-27-2017, 07:38 PM   #25
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 257
Default

Quote:
Originally Posted by earlevel View Post
Not being nitpicky, just wondering if I’m missing something. In the first, you’d just use the same parameter for the control and readout (also a control). In the second example, there’s no reason to have a parameter.
It's very possible that I've gone a roundabout way of doing things at points while I was rushing to get v1.0.0 complete.

The first, I want to add text entry for the readouts, but hadn't considered that the same parameter could be used for both, maybe I should look into this to tidy up my code.

In the second, I was finding that the prefs window was opening up when the plugin was first loaded, so used the parameter as a flag to show if the user had clicked. I guess a bog-standard variable is probably a better thing to use here.


Going back to my previous thought of a 'threads/snippets of interest' section, these are the kind of things that would be useful to have in one handy reference area.
Bobflip is offline   Reply With Quote
Old 12-27-2017, 08:00 PM   #26
Guod3
Human being with feelings
 
Guod3's Avatar
 
Join Date: Jan 2008
Posts: 456
Default

Quote:
Originally Posted by Bobflip View Post
Going back to my previous thought of a 'threads/snippets of interest' section, these are the kind of things that would be useful to have in one handy reference area.
The maybe it's helpful link is hugely helpful. And, if it's all accurate and correct, the info should be embedded within the source code so that it comes up in tool tips and Doxygen output, etc.
Guod3 is online now   Reply With Quote
Old 12-27-2017, 08:08 PM   #27
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 257
Default

Quote:
Originally Posted by Guod3 View Post
The maybe it's helpful link is hugely helpful. And, if it's all accurate and correct, the info should be embedded within the source code so that it comes up in tool tips and Doxygen output, etc.
Indeed, I bookmarked it when posted earlier in the thread, and would definitely be added to the list :-)
Bobflip 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 04:41 PM.


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