COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 11-02-2016, 01:31 PM   #1
chaz13
Human being with feelings
 
Join Date: Oct 2016
Posts: 15
Default IKnob control depending on eachother

Hi,

I'm trying to use IKnob controls to set two thresholds, the second which must be greater than the first. So I need it to work in a way that the second knob will change the first, too, if you go lower than the first's threshold, and vice versa.

I have this working codewise, by using something like:

Code:
case kThresh1:
      mThresh1 = GetParam(kThresh1)->Value();

	  if (mThresh2 < mThresh1) {
		  GetParam(kThresh2)->Set(mThresh1);
		  mThresh2 = mThresh1;
	  }

On the parameter change, but it didn't update the actual image being displayed the for knob not in operation. How can I tell it to re-draw?

Thanks!

Last edited by chaz13; 11-02-2016 at 04:45 PM.
chaz13 is offline   Reply With Quote
Old 11-02-2016, 03:58 PM   #2
Add9
Human being with feelings
 
Join Date: Sep 2016
Posts: 4
Default

Quote:
Originally Posted by chaz13 View Post
it didn't update the actual image being displayed the for knob not in operation. How can I tell it to re-draw?
Thanks!
To re-draw, I think you have to do something like:

Code:
control->SetValueFromPlug(mThresh1);
where control is whatever IControl is associated with the knob in question.

I'm not sure though if there's a better way of accessing that particular control than doing something like this:

Code:
IControl* control = GetGUI()->GetControl(i);
where i is the index of the control. And if I'm not mistaken, the control index is determined by what order the controls were initially declared. I'm not sure if you can get the control using the paramIdx, other than looping through all controls until you find the one that matches... though that would be very useful if there is a way to do that.

Also, hello to everyone (first post, woohoo!) You all have helped me a lot in my own plugin development, so thank you all immensely!

Last edited by Add9; 11-02-2016 at 04:03 PM.
Add9 is offline   Reply With Quote
Old 11-02-2016, 04:29 PM   #3
chaz13
Human being with feelings
 
Join Date: Oct 2016
Posts: 15
Default

I'm honoured I'm your first reply!

Thanks for the suggestion. I've changed the code to:

Code:
	  if (mThresh2 < mThresh1) {
		  GetParam(kThresh2)->Set(mThresh1);
		  mThresh2 = mThresh1;

		  IControl* control = GetGUI()->GetControl(kThresh2);
		  control->SetValueFromPlug(mThresh1);
	  }
And it compiles just fine, but still no update of the drawing. I figured the control index would be the same as kThresh2 because they're literally the only two controls I've got at the moment. I tried manually entering 0,1 and 2, too, and no difference (kinda odd there was no error at 2, though). I feel like I perhaps need to call SetDirty() somehow... but I'm still a bit lost on how all the inheritance works in IPlug.

EDIT Ah, I tried control->SetDirty(); following that and it runs fine again, but still no update of the second knob.

Last edited by chaz13; 11-02-2016 at 04:45 PM.
chaz13 is offline   Reply With Quote
Old 11-02-2016, 04:56 PM   #4
random_id
Human being with feelings
 
random_id's Avatar
 
Join Date: May 2012
Location: PA, USA
Posts: 356
Default

I always get controls and parameters confused in my head. No matter what I do, I can't keep it straight.

That being said, I think you need to look at
Code:
GetGUI()->SetParameterFromPlug(paramid, double_value, bool_isnormalized_or_not);
__________________
Website: LVC-Audio
random_id is offline   Reply With Quote
Old 11-02-2016, 04:58 PM   #5
Add9
Human being with feelings
 
Join Date: Sep 2016
Posts: 4
Default

I'll be honest, this is what I'm doing right now and it isn't pretty but its working for me:

Code:
for (int i=0; i<GetGUI()->GetNControls(); i++) {
    IControl* control = GetGUI()->GetControl(i);
    if (control->ParamIdx() == kThresh2) {
      control->SetValueFromPlug(GetParam(kThresh1)->Value());
    }
  }
Yeah. Looping through every single control. Need to find a better way to do this... but it does work, at least for me.
Add9 is offline   Reply With Quote
Old 11-02-2016, 09:40 PM   #6
chaz13
Human being with feelings
 
Join Date: Oct 2016
Posts: 15
Default

Quote:
Originally Posted by random_id View Post
I always get controls and parameters confused in my head. No matter what I do, I can't keep it straight.

That being said, I think you need to look at
Code:
GetGUI()->SetParameterFromPlug(paramid, double_value, bool_isnormalized_or_not);
This worked perfectly, thank you!

Quote:
Originally Posted by Add9 View Post
I'll be honest, this is what I'm doing right now and it isn't pretty but its working for me:

Code:
for (int i=0; i<GetGUI()->GetNControls(); i++) {
    IControl* control = GetGUI()->GetControl(i);
    if (control->ParamIdx() == kThresh2) {
      control->SetValueFromPlug(GetParam(kThresh1)->Value());
    }
  }
Yeah. Looping through every single control. Need to find a better way to do this... but it does work, at least for me.
Ah that's another alternative, but you should check out the solution above too

Last edited by chaz13; 11-02-2016 at 09:46 PM.
chaz13 is offline   Reply With Quote
Old 11-03-2016, 11:48 PM   #7
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,645
Default

Quote:
Originally Posted by Add9 View Post
Yeah. Looping through every single control. Need to find a better way to do this... but it does work, at least for me.
You could record the control index when attaching the control i.e.:

Code:
mControlIdx = pGraphics->AttachControl(...);
Then you can use this index to access the control later on:

Code:
IControl* control = GetGUI()->GetControl(mControlIdx);
Tale 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 11:07 AM.


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