Cockos Incorporated Forums

Cockos Incorporated Forums (https://forum.cockos.com/index.php)
-   WDL users forum (https://forum.cockos.com/forumdisplay.php?f=32)
-   -   Linking knobs (https://forum.cockos.com/showthread.php?t=200889)

Tunca 12-18-2017 02:51 AM

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.

Bobflip 12-18-2017 03:37 PM

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);


Tunca 12-19-2017 10:16 AM

Quote:

Originally Posted by Bobflip (Post 1927890)
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?

Bobflip 12-19-2017 10:30 AM

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.

Tunca 12-19-2017 11:09 AM

Quote:

Originally Posted by Bobflip (Post 1928224)
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.

Bobflip 12-19-2017 11:10 AM

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" ;-)

Tunca 12-19-2017 11:15 AM

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);


Bobflip 12-19-2017 11:29 AM

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.

Tunca 12-20-2017 03:03 AM

Quote:

Originally Posted by Bobflip (Post 1928259)
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.

Bobflip 12-20-2017 03:08 AM

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, "");

Tunca 12-20-2017 03:13 AM

Quote:

Originally Posted by Bobflip (Post 1928529)
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.);


Bobflip 12-20-2017 03:25 AM

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.

mrlimbic 04-24-2018 08:17 AM

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.

Bobflip 04-24-2018 08:34 AM

Not sure atm, can you post a bit of code/pseudocode?

mrlimbic 04-24-2018 08:54 AM

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?

mrlimbic 04-24-2018 09:30 AM

Quote:

Originally Posted by mrlimbic (Post 1982297)
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.

http://vordio.net/wp-content/uploads...am-linking.gif

Bobflip 04-24-2018 09:34 AM

Can't see what it could be offhand, hopefully someone else can spot it. Is IDialControl your own thing inherited from IKnobControl?

mrlimbic 04-24-2018 09:41 AM

Quote:

Originally Posted by Bobflip (Post 1982313)
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.

Bobflip 04-24-2018 06:09 PM

I presume you've also added all the GetParam(param)->SetIsMeta(true) calls?

mrlimbic 04-25-2018 05:17 AM

Quote:

Originally Posted by Bobflip (Post 1982444)
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?

Bobflip 04-25-2018 05:42 AM

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!

bozmillar 05-01-2018 03:46 PM

Quote:

Originally Posted by mrlimbic (Post 1982542)
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.

mrlimbic 05-03-2018 09:45 AM

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.


All times are GMT -7. The time now is 07:12 AM.

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