COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 03-22-2018, 06:50 AM   #1
MLN
Human being with feelings
 
MLN's Avatar
 
Join Date: Mar 2018
Location: Portugal
Posts: 7
Default How can a user change values?

Hey guys, I'm trying to learn the basics of programming plugins (and I'm new to C++) and I'm practicing on a simple gain knob.

The basics are working fine... but I'd like to add something extra to it and can't find any solutions to this.

My ideia is to allow the user to input the minimum and maximum values for the gain knob. By default the values are -12dB and 6dB, but the idea is for the user to be able to click on them and change them if he wants to.

The attached image shows the numbers -12 and 6 but they currently are just non-editable text, just for reference.

How should I go about to make this happen?
Thanks so much in advance
Attached Images
File Type: png gain knob.png (3.6 KB, 27 views)
MLN is offline   Reply With Quote
Old 03-22-2018, 09:35 PM   #2
MSK
Human being with feelings
 
Join Date: Jan 2017
Posts: 43
Default

Hey MLN,

Glad you're getting into plugin development! The way I see it there are two things you need to implement:

First, you need a parameter that has dynamic minimum and maximum values. If you look at the class definition of IParam, located (for me) in /Frameworks and Libraries/WDL/IPlug/IParam.h, it doesn't look like you can change the minimum and maximum values. This means you'll have to do it yourself. There's a number of ways you could do it, some ideas that come to mind are:

- Change IParam's implementation to allow dynamic min/max values. (Probably hard)
- Make you own parameter class by inheriting from IParam. (Also probably hard)
- Set the absolute min/max parameter values and handle the logic yourself. (Maybe easier)

If I were doing this, the last way is probably what I would try first. I'd probably make a new class - something like DynamicParam - that had the parameter as a member, and then handle parameter changes/scaling through that class. If you're just starting with WDL/C++ that might not make much sense, I'd be happy to go into more detail or make an example for ya if it doesn't.

Second, you need an editable text box. It looks like ICaptionControl would be something to build off of, but I haven't really played with that control. A while back I made an editable text box using Cairo in Youlean's branch. I'd be happy to dig it up if you're interested. Building your own would definitely be a great exercise in learning C++ and this framework, but it might be tricky, especially if you don't have much experience with programming in general - you'll have to handle drawing, mouse clicks, input validation and then connect the text box to the parameter!

Let me know if you want any more info/examples, and welcome to the community!

Cheers,
Max
MSK is offline   Reply With Quote
Old 03-24-2018, 03:21 AM   #3
k.d.iv
Human being with feelings
 
Join Date: Mar 2018
Posts: 11
Default

Hi. There is a IKnobMultiControlText used in
WDL-OL/IPlugExamples/IplugMultiTargets, which I think can be modified for that you need. Hope that will help.
k.d.iv is offline   Reply With Quote
Old 03-25-2018, 05:36 PM   #4
MLN
Human being with feelings
 
MLN's Avatar
 
Join Date: Mar 2018
Location: Portugal
Posts: 7
Default

Thank you for your help! I was able to make it work

I have one last problem that should be simple to solve, but my basic C++ programming knowledge is getting in the way...

In IControl.h there's a parameter called mDefaultValue. I'd like to access and modify it from my main code. How can I do that?

Thank you so much!
MLN is offline   Reply With Quote
Old 03-25-2018, 11:20 PM   #5
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: Holland
Posts: 2,899
Default

Quote:
Originally Posted by MLN View Post
In IControl.h there's a parameter called mDefaultValue. I'd like to access and modify it from my main code. How can I do that?
I don't think you can, at least not out of the box. I guess you could add a SetDefaultValue() method to IControl.
Tale is offline   Reply With Quote
Old 03-26-2018, 06:14 PM   #6
MLN
Human being with feelings
 
MLN's Avatar
 
Join Date: Mar 2018
Location: Portugal
Posts: 7
Default

Thanks! That's actually what I was trying to do but I had to take a step back and learn some more C++ basics to know how to actually do it... and now it's all working like I wanted And that's really exciting!!
MLN 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 02:39 AM.


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