COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 12-18-2017, 02:51 AM   #1
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 181
Default Linking knobs

Hi,

I have an EQ plugin.It has L/R dual mono processing.But i want to it L/R link.

Any easy solution for this?

Thanks.
Tunca is offline   Reply With Quote
Old 12-18-2017, 03:37 PM   #2
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 316
Default

You'll need to activate the meta flag for controls that are to be modified by other controls like this:

Code:
GetParam(kParameterNameL)->SetIsMeta(true);
GetParam(kParameterNameR)->SetIsMeta(true);
And then in OnParamChange set them like this:

Code:
case kParameterNameL: 
	GetGUI()->SetParameterFromPlug(kParameterNameR, GetParam(kParameterNameL)->Value(), false);
Bobflip is offline   Reply With Quote
Old 12-19-2017, 10:16 AM   #3
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 181
Default

Quote:
Originally Posted by Bobflip View Post
You'll need to activate the meta flag for controls that are to be modified by other controls like this:

Code:
GetParam(kParameterNameL)->SetIsMeta(true);
GetParam(kParameterNameR)->SetIsMeta(true);
And then in OnParamChange set them like this:

Code:
case kParameterNameL: 
	GetGUI()->SetParameterFromPlug(kParameterNameR, GetParam(kParameterNameL)->Value(), false);
Thanks!

But something is wrong,i guess...

When i link knobs,working great.But when i unlink,right knob still depending left knob.But it goes all the way up or down.

Am i doing something wrong?
Tunca is offline   Reply With Quote
Old 12-19-2017, 10:30 AM   #4
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 316
Default

Well, the code I put in was pretty skeletal, you'll need to put your own if statements to check if Link is activated or not, and you also need to duplicate that code for the R knob, swapping the left and right parameter names over.
Bobflip is offline   Reply With Quote
Old 12-19-2017, 11:09 AM   #5
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 181
Default

Quote:
Originally Posted by Bobflip View Post
Well, the code I put in was pretty skeletal, you'll need to put your own if statements to check if Link is activated or not, and you also need to duplicate that code for the R knob, swapping the left and right parameter names over.
I did what you said.

Created mLink."true" or "false".Duplicated for R knob...

When i unlink,R knob going crazy while playing with L knob.
Tunca is offline   Reply With Quote
Old 12-19-2017, 11:10 AM   #6
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 316
Default

You need to post code with these types of questions, at the moment the only answer we can give to "am I doing something wrong?" is "probably" ;-)
Bobflip is offline   Reply With Quote
Old 12-19-2017, 11:15 AM   #7
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 181
Default

Oh sorry.

Here is my codes...

Code:
    int Link = GetParam(kLink)->Value();
    if (Link == 0)
      mLink =  false;
    else if (Link == 1)
      mLink = true;
Code:
GetParam(kGainLL)->SetIsMeta(mLink);
GetParam(kGainLR)->SetIsMeta(mLink);
Code:
case kGainLL: 
	GetGUI()->SetParameterFromPlug(kGainLR, GetParam(kGainLL)->Value(), mLink);

case kGainLR: 
	GetGUI()->SetParameterFromPlug(kGainLL, GetParam(kGainLR)->Value(), mLink);
Tunca is offline   Reply With Quote
Old 12-19-2017, 11:29 AM   #8
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 316
Default

This jumped out:

GetParam(kGainLL)->SetIsMeta(mLink);
GetParam(kGainLR)->SetIsMeta(mLink);

IsMeta is a flag rather than a parameter. change the mLink in the brackets to true.
Bobflip is offline   Reply With Quote
Old 12-20-2017, 03:03 AM   #9
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 181
Default

Quote:
Originally Posted by Bobflip View Post
This jumped out:

GetParam(kGainLL)->SetIsMeta(mLink);
GetParam(kGainLR)->SetIsMeta(mLink);

IsMeta is a flag rather than a parameter. change the mLink in the brackets to true.
Ok but still same.I can't use R knob when unlinked knobs.

R knob shows only all the way up or down.

R knob still depending L knob.If i play with R knob,there is no problem.But if i play with L knob,R knob moving,too while they are unlinked.
Tunca is offline   Reply With Quote
Old 12-20-2017, 03:08 AM   #10
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 316
Default

It sounds like it's reading the parameter as an int rather than float. Have you set up the control with anything like this?

GetParam(kParamL)->InitDouble("Parameter L", 0.5, 0.0, 1.0, 0.01, "");
Bobflip is offline   Reply With Quote
Old 12-20-2017, 03:13 AM   #11
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 181
Default

Quote:
Originally Posted by Bobflip View Post
It sounds like it's reading the parameter as an int rather than float. Have you set up the control with anything like this?

GetParam(kParamL)->InitDouble("Parameter L", 0.5, 0.0, 1.0, 0.01, "");
Yes,i did like this.

Code:
  GetParam(kGainLL)->InitDouble("GainLL", 0., -18., 18., 0.01, "%");
  GetParam(kGainLL)->SetShape(1.);
  
  GetParam(kGainLR)->InitDouble("GainLR", 0., -18., 18., 0.01, "%");
  GetParam(kGainLR)->SetShape(1.);
Tunca is offline   Reply With Quote
Old 12-20-2017, 03:25 AM   #12
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 316
Default

Not sure offhand what's causing the issue, but just noticed you also changed the 'false' in the SetParameterFromPlug calls to 'mLink'. It's worth looking over the definitions of these functions when you first use them to get a gist of the variables they require.

This one has a comment saying:
// Normalized means the value is in [0, 1].
void ClampControl(int paramIdx, double lo, double hi, bool normalized);
void SetParameterFromPlug(int paramIdx, double value, bool normalized);

Don't think it'll clear your problem up but it's worth correcting anyway.
Bobflip is offline   Reply With Quote
Old 04-24-2018, 08:17 AM   #13
mrlimbic
Human being with feelings
 
mrlimbic's Avatar
 
Join Date: Nov 2009
Location: UK
Posts: 528
Default

I've tried linking controls using the above where a boolean parameter controls whether to link sets of other parameters.

I've got a strange issue in that although the dials & the custom XY control view of the values are updating correctly, the caption controls that display their values underneath as text are not updating when linked.

Why would other controls update fine, but not captions? When I am not linking the parameters, then captions work again.
__________________
Mac OS X 10.11.x, Motu Ultralite, Reaper, FCP X.
http://vordio.net
http://twitter.com/vordio
mrlimbic is offline   Reply With Quote
Old 04-24-2018, 08:34 AM   #14
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 316
Default

Not sure atm, can you post a bit of code/pseudocode?
Bobflip is offline   Reply With Quote
Old 04-24-2018, 08:54 AM   #15
mrlimbic
Human being with feelings
 
mrlimbic's Avatar
 
Join Date: Nov 2009
Location: UK
Posts: 528
Default

Setting up two X parameters that can be linked and appears in two sets of 3 controls - each set has an XY pad view, a dial for X, and a caption control to show X value & allow text entry updates.

Code:
GetParam(kPanner1 + kX)->InitDouble("1.LR", 0., -100., +100., 1., "LR");
GetParam(kPanner2 + kX)->InitDouble("2.LR", 0., -100., +100., 1., "LR");
Adding 3 controls for each of these X parameters.

Code:
// Attach 1.X controls
  pGraphics->AttachControl(new IXYPad(this, gridLayout(0, 1, 4, 4), kPanner1));
  pGraphics->AttachControl(new IDialControl(this, gridLayout(0, 5), kPanner1 + kX, &lineColor));
  IText text1X = IText(14);
  ICaptionControl* caption1X = new ICaptionControl(this, gridLayout(0, 6), kPanner1 + kX, &text1X);
  caption1X->DisablePrompt(false);
  pGraphics->AttachControl(caption1X);

// Attach 2.X controls
pGraphics->AttachControl(new IXYPad(this, gridLayout(5, 1, 4, 4), kPanner2));
  pGraphics->AttachControl(new IDialControl(this, gridLayout(5, 5), kPanner2 + kX, &lineColor));
  IText text2X = IText(14);
  ICaptionControl* caption2X = new ICaptionControl(this, gridLayout(5, 6), kPanner2 + kX, &text2X);
  caption2X->DisablePrompt(false);
  pGraphics->AttachControl(caption2X);
Linking the parameters (X & Y can be flipped i.e. mirrored/opposite values)

Code:
  if (GetGUI()) {
    // Force update on controls for all parameters
    GetGUI()->SetParameterFromPlug(paramIdx, GetParam(paramIdx)->Value(), false);
  }
  
  // Handle parameter linking
  if (GetParam(kLinkPanners)->Bool()) {
    if (paramIdx >= kPanner1 + kX && paramIdx <= kPanner1 + kDFB) {
      // panner 1 changed
      int offset = paramIdx - kPanner1;
      bool flip = (GetParam(kFlipX)->Bool() && offset == kX) || (GetParam(kFlipY)->Bool() && offset == kY);
      
      if (flip) {
         GetGUI()->SetParameterFromPlug(kPanner2 + offset, 1.0 - GetParam(kPanner1 + offset)->Value(), false);
      } else {
         GetGUI()->SetParameterFromPlug(kPanner2 + offset, GetParam(kPanner1 + offset)->Value(), false);
      }
    } else if (paramIdx >= kPanner2 + kX && paramIdx <= kPanner2 + kDFB) {
      int offset = paramIdx - kPanner2;
      bool flip = (GetParam(kFlipX)->Bool() && offset == kX) || (GetParam(kFlipY)->Bool() && offset == kY);

      if (flip) {
        GetGUI()->SetParameterFromPlug(kPanner1 + offset, 1.0 - GetParam(kPanner2 + offset)->Value(), false);
      } else {
        GetGUI()->SetParameterFromPlug(kPanner1 + offset, GetParam(kPanner2 + offset)->Value(), false);
      }
    };
  }
Why would the XYPad and Dials work fine, but not the captions when linked?
__________________
Mac OS X 10.11.x, Motu Ultralite, Reaper, FCP X.
http://vordio.net
http://twitter.com/vordio

Last edited by mrlimbic; 04-24-2018 at 09:04 AM.
mrlimbic is offline   Reply With Quote
Old 04-24-2018, 09:30 AM   #16
mrlimbic
Human being with feelings
 
mrlimbic's Avatar
 
Join Date: Nov 2009
Location: UK
Posts: 528
Default

Quote:
Originally Posted by mrlimbic View Post
Why would the XYPad and Dials work fine, but not the captions when linked?
Actually it's not always the captions, sometimes it's the dial, depending on which parameter is being linked.

Here is how it is behaving as gif.

First show all 3 controls work unlinked. After when linked only 2 work, 1 doesn't update.

__________________
Mac OS X 10.11.x, Motu Ultralite, Reaper, FCP X.
http://vordio.net
http://twitter.com/vordio
mrlimbic is offline   Reply With Quote
Old 04-24-2018, 09:34 AM   #17
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 316
Default

Can't see what it could be offhand, hopefully someone else can spot it. Is IDialControl your own thing inherited from IKnobControl?
Bobflip is offline   Reply With Quote
Old 04-24-2018, 09:41 AM   #18
mrlimbic
Human being with feelings
 
mrlimbic's Avatar
 
Join Date: Nov 2009
Location: UK
Posts: 528
Default

Quote:
Originally Posted by Bobflip View Post
Can't see what it could be offhand, hopefully someone else can spot it. Is IDialControl your own thing inherited from IKnobControl?
Yes Dial control is basically same as knob control but with a circle added. At this stage I don't really want to get into making images for the UI, so drawing really basic controls.

The problem seems very inconsistent.

Maybe it depends on the parameter index order of what is being linked. Different controls stop working if they are before or after.

You can see that when linked if I alter the left side vs the right side, then different controls stop working.
__________________
Mac OS X 10.11.x, Motu Ultralite, Reaper, FCP X.
http://vordio.net
http://twitter.com/vordio

Last edited by mrlimbic; 04-24-2018 at 09:48 AM.
mrlimbic is offline   Reply With Quote
Old 04-24-2018, 06:09 PM   #19
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 316
Default

I presume you've also added all the GetParam(param)->SetIsMeta(true) calls?
Bobflip is offline   Reply With Quote
Old 04-25-2018, 05:17 AM   #20
mrlimbic
Human being with feelings
 
mrlimbic's Avatar
 
Join Date: Nov 2009
Location: UK
Posts: 528
Default

Quote:
Originally Posted by Bobflip View Post
I presume you've also added all the GetParam(param)->SetIsMeta(true) calls?
I have tried with GetParam(param)->SetIsMeta(true) and without. It didn't seem to make any noticeable difference.

What is the purpose of the meta flag?
__________________
Mac OS X 10.11.x, Motu Ultralite, Reaper, FCP X.
http://vordio.net
http://twitter.com/vordio
mrlimbic is offline   Reply With Quote
Old 04-25-2018, 05:42 AM   #21
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 316
Default

I don't know specifically what it does, but it's needed for controls that affect other controls. Could try setting it for all the ones that are being affected as well.

I've had similar issues, and it can take a bit of prodding to solve. With breakpoints and printf lines you can trace the path and see where things aren't being updated. I'll put printfs showing the control and parameter values in ProcessDoubleReplacing to see if it's the kParameter, Control, or the display that isn't being changed. Also breakpoints and printfs in the IDialControl to make sure that it's redrawing when it ought to be, and what the value there is.

There's a few different ways of setting a control's value, and I get confused as to which is best for what!
Bobflip is offline   Reply With Quote
Old 05-01-2018, 03:46 PM   #22
bozmillar
Human being with feelings
 
bozmillar's Avatar
 
Join Date: Sep 2009
Posts: 585
Default

Quote:
Originally Posted by mrlimbic View Post
I have tried with GetParam(param)->SetIsMeta(true) and without. It didn't seem to make any noticeable difference.

What is the purpose of the meta flag?
Without it, it won't pass AU validation.
__________________
http://www.bozdigitallabs.com
bozmillar is offline   Reply With Quote
Old 05-03-2018, 09:45 AM   #23
mrlimbic
Human being with feelings
 
mrlimbic's Avatar
 
Join Date: Nov 2009
Location: UK
Posts: 528
Default

I solved the linking/updating issue by adding one line.

Code:
GetParam(kPanner2 + offset)->Set(value);
GetGUI()->SetParameterFromPlug(kPanner2 + offset, value, false);
SetParameterFromPlug isn't enough on it's own. I needed to also set the linked parameter's value directly. Doh!

I didn't do this originally as I thought it would create an infinite parameter change loop but somehow it doesn't.
__________________
Mac OS X 10.11.x, Motu Ultralite, Reaper, FCP X.
http://vordio.net
http://twitter.com/vordio

Last edited by mrlimbic; 05-03-2018 at 02:30 PM.
mrlimbic 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 06:53 AM.


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