|
12-19-2017, 05:26 PM
|
#1
|
Human being with feelings
Join Date: Jan 2008
Posts: 506
|
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
|
|
|
12-19-2017, 06:00 PM
|
#2
|
Human being with feelings
Join Date: Nov 2016
Posts: 341
|
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?
|
|
|
12-19-2017, 06:14 PM
|
#3
|
Human being with feelings
Join Date: Jan 2008
Posts: 506
|
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)
|
|
|
12-19-2017, 06:29 PM
|
#4
|
Human being with feelings
Join Date: Nov 2016
Posts: 341
|
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.
|
|
|
12-19-2017, 07:38 PM
|
#5
|
Human being with feelings
Join Date: Jan 2008
Posts: 506
|
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.
|
|
|
12-19-2017, 07:45 PM
|
#6
|
Human being with feelings
Join Date: Nov 2016
Posts: 341
|
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.
|
|
|
12-19-2017, 07:57 PM
|
#7
|
Human being with feelings
Join Date: Jan 2008
Posts: 506
|
Quote:
Originally Posted by Bobflip
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
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.
|
|
|
12-19-2017, 08:04 PM
|
#8
|
Human being with feelings
Join Date: Nov 2016
Posts: 341
|
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.
|
|
|
12-19-2017, 10:02 PM
|
#9
|
Human being with feelings
Join Date: Jan 2008
Posts: 506
|
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?
|
|
|
12-19-2017, 10:13 PM
|
#10
|
Human being with feelings
Join Date: Nov 2016
Posts: 341
|
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);
|
|
|
12-19-2017, 10:16 PM
|
#11
|
Human being with feelings
Join Date: Jan 2008
Posts: 506
|
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.
|
|
|
12-19-2017, 10:23 PM
|
#12
|
Human being with feelings
Join Date: Nov 2016
Posts: 341
|
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!
|
|
|
12-21-2017, 04:55 PM
|
#13
|
Human being with feelings
Join Date: Jan 2008
Posts: 506
|
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!
|
|
|
12-21-2017, 05:00 PM
|
#14
|
Human being with feelings
Join Date: Nov 2016
Posts: 341
|
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?
|
|
|
12-22-2017, 03:59 AM
|
#15
|
Human being with feelings
Join Date: Apr 2012
Posts: 279
|
Quote:
Originally Posted by Bobflip
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?
|
|
|
12-22-2017, 07:26 AM
|
#16
|
Human being with feelings
Join Date: Jan 2008
Posts: 506
|
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.
|
|
|
12-22-2017, 07:38 AM
|
#17
|
Human being with feelings
Join Date: Nov 2016
Posts: 341
|
Ah, that can also be sorted by using public/private parameters, and also GetParam(kName)->SetCanAutomate(false);
|
|
|
12-22-2017, 07:42 AM
|
#18
|
Human being with feelings
Join Date: Jan 2008
Posts: 506
|
Quote:
Originally Posted by Bobflip
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?
|
|
|
12-22-2017, 08:36 AM
|
#19
|
Human being with feelings
Join Date: Nov 2016
Posts: 341
|
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.
|
|
|
12-22-2017, 08:37 AM
|
#20
|
Human being with feelings
Join Date: Nov 2016
Posts: 341
|
Quote:
Originally Posted by stw
|
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.
|
|
|
12-23-2017, 04:23 AM
|
#21
|
Human being with feelings
Join Date: Apr 2009
Location: Berlin, Germany
Posts: 1,248
|
|
|
|
12-23-2017, 04:37 AM
|
#22
|
Human being with feelings
Join Date: Dec 2015
Posts: 331
|
Quote:
Originally Posted by Bobflip
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.
|
|
|
12-23-2017, 12:02 PM
|
#23
|
Human being with feelings
Join Date: Jan 2008
Posts: 506
|
Quote:
Originally Posted by olilarkin
|
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)
|
|
|
12-23-2017, 01:53 PM
|
#24
|
Human being with feelings
Join Date: Jan 2008
Posts: 506
|
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.
|
|
|
12-27-2017, 07:38 PM
|
#25
|
Human being with feelings
Join Date: Nov 2016
Posts: 341
|
Quote:
Originally Posted by earlevel
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.
|
|
|
12-27-2017, 08:00 PM
|
#26
|
Human being with feelings
Join Date: Jan 2008
Posts: 506
|
Quote:
Originally Posted by Bobflip
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.
|
|
|
12-27-2017, 08:08 PM
|
#27
|
Human being with feelings
Join Date: Nov 2016
Posts: 341
|
Quote:
Originally Posted by Guod3
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 :-)
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 04:31 AM.
|