COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 04-08-2017, 10:30 AM   #1
Anomaly
Human being with feelings
 
Anomaly's Avatar
 
Join Date: Sep 2007
Posts: 642
Default Sliders with readout?

I have another beginners question:

I have been searching quite some time any kind of documentation, help or anything that would reveal how to make a slider with user editable readout value with WDL-OL. But haven't found anything...

"kIFaderControl_Horiz" and "kIFaderControl_Vert" are not displaying any value readout. I know there is "IKnobMultiControlText" which is basically what I'd want, except that it's a knob, not a slider.

If there is no build-in method for this, how difficult it would be to make one? Any hints and help is welcome.

Thanks for reading.
__________________
___________________________
Sonic Anomaly | free JSFX & VST Plugins
Anomaly is offline   Reply With Quote
Old 04-08-2017, 11:54 AM   #2
earlevel
Human being with feelings
 
Join Date: Dec 2015
Posts: 331
Default

You can have multiple controls per parameter. So, you can use an ICaptionControl (be sure to DisablePrompt(false)—I don't know why it defaults to disabled).
earlevel is offline   Reply With Quote
Old 04-08-2017, 01:56 PM   #3
stw
Human being with feelings
 
stw's Avatar
 
Join Date: Apr 2012
Posts: 279
Default

Quote:
Originally Posted by Anomaly View Post
I have another beginners question:

I have been searching quite some time any kind of documentation, help or anything that would reveal how to make a slider with user editable readout value with WDL-OL. But haven't found anything...

"kIFaderControl_Horiz" and "kIFaderControl_Vert" are not displaying any value readout. I know there is "IKnobMultiControlText" which is basically what I'd want, except that it's a knob, not a slider.

If there is no build-in method for this, how difficult it would be to make one? Any hints and help is welcome.

Thanks for reading.
You can use IKnobMultiControl. Since it steps through stitched bitmap areas do your fader like any other knob and use it with IKnobMultiControl.
stw is offline   Reply With Quote
Old 04-09-2017, 01:36 AM   #4
Anomaly
Human being with feelings
 
Anomaly's Avatar
 
Join Date: Sep 2007
Posts: 642
Default

Thanks for the tips! I will be looking into this.

Using stitched bitmaps for a slider feels somewhat extreme, but could be a viable solution if everything else fails.
__________________
___________________________
Sonic Anomaly | free JSFX & VST Plugins
Anomaly is offline   Reply With Quote
Old 04-09-2017, 10:40 AM   #5
earlevel
Human being with feelings
 
Join Date: Dec 2015
Posts: 331
Default

Quote:
Originally Posted by Anomaly View Post
Using stitched bitmaps for a slider feels somewhat extreme, but could be a viable solution if everything else fails.
The system is designed for multiple controls—it won't fail. Just use the slider control you want to use, and a text control (ICaptionControl). Move the slider, the value in the text field updates to match, edit the text field, the slider updates to match.

The way it works is that multiple controls can reference the same parameter. When you change a control, the parameter is updated. But, of course, when a parameter is changed, any control that references it is updated to match. (If that were not true, preset and automation wouldn't work.) So, when you change a parameter with one control, all controls that reference it are updated to match.
earlevel is offline   Reply With Quote
Old 04-10-2017, 02:02 AM   #6
Anomaly
Human being with feelings
 
Anomaly's Avatar
 
Join Date: Sep 2007
Posts: 642
Default

Thanks earlevel. I started some testing with ICaptionControl. Basically I copied the code from IPlugControls example project to see how it works.

Code:
...

GetParam(kICaptionControl)->InitInt("ICaptionControl", 1, 1, 14, "label");

IText text = IText(14);
pGraphics->AttachControl(new ICaptionControl(this, IRECT(100, 100, 160, 130), kICaptionControl, &text));

...
Unfortunately, when I open the plugin in Reaper, it freezes and crashes. The debug says "Unhandled exception thrown: read access violation. this was nullptr..."

I'm not sure what might be wrong here..?
__________________
___________________________
Sonic Anomaly | free JSFX & VST Plugins
Anomaly is offline   Reply With Quote
Old 04-10-2017, 10:11 AM   #7
earlevel
Human being with feelings
 
Join Date: Dec 2015
Posts: 331
Default

Quote:
Originally Posted by Anomaly View Post
Unfortunately, when I open the plugin in Reaper, it freezes and crashes. The debug says "Unhandled exception thrown: read access violation. this was nullptr..."

I'm not sure what might be wrong here..?
Bet you didn't give it parameter number (kICaptionControl) that correspond to an existing parameter. Use the same parameter number that you use for the slider.

Also, as I mentioned before, you won't be able to edit the value unless you enable editing (yourControl->DisablePrompt(false); ).
earlevel is offline   Reply With Quote
Old 04-11-2017, 08:44 AM   #8
Anomaly
Human being with feelings
 
Anomaly's Avatar
 
Join Date: Sep 2007
Posts: 642
Default

Quote:
Originally Posted by earlevel View Post
Bet you didn't give it parameter number (kICaptionControl) that correspond to an existing parameter. Use the same parameter number that you use for the slider.

Also, as I mentioned before, you won't be able to edit the value unless you enable editing (yourControl->DisablePrompt(false); ).
Thanks, the crash was indeed due to that!

When you say to use the same number for both, I assume you mean:

enum EParams
{
kFader1 = 0,
kICaptionControl = 0
}

This is not really working. When I move the slider, the kICaptionControl is not updating. The kICaptionControl actually replaces the kFader1. kICaptionControl is listed as a parameter in the non-gui mode, instead of kFader1.

Another question, can you please clarify "yourControl->DisablePrompt(false);"
trying with kICaptionControl->DisablePrompt(false) says "Expression must have a pointer type".

Sorry for the questions
__________________
___________________________
Sonic Anomaly | free JSFX & VST Plugins
Anomaly is offline   Reply With Quote
Old 04-11-2017, 11:42 AM   #9
earlevel
Human being with feelings
 
Join Date: Dec 2015
Posts: 331
Default

Quote:
Originally Posted by Anomaly View Post
When you say to use the same number for both, I assume you mean:

enum EParams
{
kFader1 = 0,
kICaptionControl = 0
}

This is not really working. When I move the slider, the kICaptionControl is not updating. The kICaptionControl actually replaces the kFader1. kICaptionControl is listed as a parameter in the non-gui mode, instead of kFader1.
First, do yourself a favor: Recognize the difference between a parameter and a control, IParam and IControl, and be consistent in referring to them. When you create the control, you pass it the parameter ID that it controls. So, refer to it as such. A control is the thing on the screen, a parameter is the thing that ties a value to your DSP variables (and to the host, for things like automation—the host automates parameters, not controls; parameters in turn tell their controls to update to match).

That is, if the plugin is a single parametric EQ, and you have three parameters, frequency, Q, and gain, then you might have three parameters:

enum EParams {
kFreqParamID,
kQParamID,
kGainParamID
}

Then, it's clear that you would send kFreqParamID as the parameter ID to your "fader 1" (frequency slider) control, and also pass kFreqParamID to the text value control—because they are both controls for parameter kFreqParamID. When you mix up parameter IDs and control indexes, you will find yourself in debug hell, as it will often work out for some controls (when the freq param and freq control are the same ID/index), and fail at other times (when thy aren't).

Quote:
Another question, can you please clarify "yourControl->DisablePrompt(false);"
trying with kICaptionControl->DisablePrompt(false) says "Expression must have a pointer type".
You just showed that kICaptionControl is the value 0, so no, that won't work.

I don't know your code, but let's say you're creating the control something like this:

pGraphics->AttachControl(new ICaptionControl(this, IRECT(86, 60, 138, 72), kFreqParamID, &textProps);

Instead, keep a copy of the pointer to the object and use it to call the Disable Prompt method:

ICaptionControl *theCaptionControl = new ICaptionControl(this, IRECT(86, 60, 138, 72), kFreqParamID, &textProps);
theCaptionControl->DisablePrompt(false);
pGraphics->AttachControl(theCaptionControl);

Don't ask me why ICaptionControl doesn't default to being editable. (I'm actually using a object that inherits from ICaptionControl, so I can do some special things, and my control automatically sets the mDisablePrompt field to false.)
earlevel is offline   Reply With Quote
Old 04-13-2017, 01:19 AM   #10
Anomaly
Human being with feelings
 
Anomaly's Avatar
 
Join Date: Sep 2007
Posts: 642
Default

Thanks for the clarification. I can get it semi-working now, but some issues still remain.

Code:
// The fader
GetParam(kFader1)->InitDouble("Volume 1 & 2", 0, -60, 20, 0.1, "dB");
IBitmap bitmap = pGraphics->LoadIBitmap(KNOBSM_ID, KNOBSM_FN);
pGraphics->AttachControl(new IFaderControl(this, 30, 34, 250, kFader1, &bitmap, kHorizontal));

// The readout
IText text = IText(14, &COLOR_WHITE);
ICaptionControl *theCaptionControl = new ICaptionControl(this, IRECT(10, 10, 60, 30), kFader1, &text);
theCaptionControl->DisablePrompt(false);
pGraphics->AttachControl(theCaptionControl);
When I move the fader, it updates the kFader1 parameter. Also when I modify the value in caption, it updates the kFader1 parameter.

But the controls on the GUI are not updating each other. The fader control does not update value in caption and vice versa. So unless I have done it wrong again, I assume they need to be updated manually within code?

Is this something I should start looking next?
GetGUI()->SetControlFromPlug(control_ID, GetParam(paramIdx)->Value());

The problem is, how does the plugin differentiate that if fader control has been changed or if caption control has been changed, as they are using the same parameter ID?
__________________
___________________________
Sonic Anomaly | free JSFX & VST Plugins
Anomaly is offline   Reply With Quote
Old 04-13-2017, 03:26 PM   #11
earlevel
Human being with feelings
 
Join Date: Dec 2015
Posts: 331
Default

Sorry, I don't have time to sort this out, so I might not be telling you the right thing.

I have two controls controlling the same parameter bidirectionally—a knob and a numerical field—plus a group of controls (tempo, note division, dotted, triplet) that only works one way (changes to them affect the param/knob/field, but changes to param/knob/field don't change them).

It works great on AAX. A quick look at the code reveals that parameter updates call IGraphics::SetParameterFromPlug, which looks through the control list for controls that are assigned to that parameter, and calls SetValueFromPlug for them. So, all controls associated with the parameter get updated.

I don't have time to check if other plugin types do that. Obviously, they should—a control can be attached to only one parameter, but many controls can be attached to any one parameter. If the host is automating parameters, all associated controls should follow along. I think it's working for AU, but don't recall if I did anything special. I don't think this mechanism is in place for standalone apps, so don't test it there.
earlevel is offline   Reply With Quote
Old 04-14-2017, 12:14 AM   #12
Anomaly
Human being with feelings
 
Anomaly's Avatar
 
Join Date: Sep 2007
Posts: 642
Default

Ok, thanks again! I got it working correctly now by adding this to the OnParamChange function.

Code:
case kFader1:
 if (GetGUI()) {
  GetGUI()->SetParameterFromPlug(kFader1, GetParam(paramIdx)->Value(), false);
 }
 break;
__________________
___________________________
Sonic Anomaly | free JSFX & VST Plugins
Anomaly 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 03:14 AM.


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