Noober q's


#1

Guess I’m just saying hi to the community, I look forward to using Juce. Currently use Iplug - which is A LOT simpler than this, So Juce looks confusing as heck to me. After looking at the source last night, I have a couple of questions.

addAndMakeVisible (robSlider = new Slider (T("gain 2"))); robSlider->addListener (this); robSlider->setRange(0.0,1.0,0.01); robSlider->setTooltip (T("woohoo! juce baby")); robSlider->setValue (ownerFilter->getParameter (1), false);

“getParameter (1)” - that “1”, Do you change this for each control that you add, say your first control is going to be 0, your second control is 1. In Iplug we had:

[code]enum EParams

{
finputgain = 0,
fhipass =1,
kNumParams
};
[/code]

Also:

[code]float DemoJuceFilter::getParameter (int index)
{
return (index == 0) ? gain
: 0.0f;
code]

If I wanted to add another control would I do:

[code]

int DemoJuceFilter::getNumParameters()
{
return 2;
}

float DemoJuceFilter::getParameter (int index)
{
return (index == 0) ? gain
: 0.0f;

return (index == 1) ? gain
: 0.0f;
}[/code]

I’m trying to add another control, but since there’s only one control in the example, its hard to tell what needs to be changed to add another control. Can I suggest adding another gain control slider to the example plugin?

I did manage to get another slider on the form, but its acting weird with the first slider, interacting. And I can’t get the plug to load because I tried taking out the keyboard, and I obviously messed something up lol.

I guess I’m just wondering what are the steps to add another control to the example plugin, as I think I’ve missed some, or completely done it wrong. Again, this is just my first couple of Q’s while looking at the code, I am off to search the heck out of the forum and read everything I can. Does that juce tutorial apply to vst plugins as well?

I know i’m gonna get hell, but is it possible to update the example plugin with like a pan control, a vu meter and bypass switch? I hate beeing a noob :twisted:

~Rob.


#2

Yes, using enums is a better way to manage the parameter indices. So, using your example enum, you would instead have:

But, your guess at the getParameter function would fail, as the first return will be the only one executed. So, instead you would want something like this:

[code]float DemoJuceFilter::getParameter (int index)
{
float paramVal = 0.0;

switch(index)
{
    case finputgain :
        paramVal = gain;

    case fhipass :
        paramVal = hipass;
}

return paramVal;

}[/code]


#3

Now, the last case statement has to also be done in “const String DemoJuceFilter::getParameterName (int index)”,“const String DemoJuceFilter::getParameterText (int index)” and “void DemoJuceFilter::setParameter (int index, float newValue)” ? Seems like theres 10 things you have to do to add a control, Def not used to this.

Thank you,

~Rob.


#4

…plug in your Parameter class here…


#5

So, it looks like all controls are passed in, and a parameter is assigned there, but What is this parameter used for? Is this assigned the value of the slider at this point(or whatever control is true). I don’t understand why this is here, and the values arent just hardcoded in somewhere? I’m so confused over these case statements, like setparam, getparam,param name. As of what they are doing…
Is there a class floating around to convert a enum list ? I’m going nowhere fast here lol. I can add the controls(still confused about the listeners a bit), but this part i’m not understanding WHAT its doing by setting the params, getting etc.
~Rob

EDIT: I guess i’m getting confused on the actual FLOW of a slider value through this, does it all end up coming back to:

Which comes from:

Which comes form:

float DemoJuceFilter::getParameter (int index)
{
double paramVal = 0.0;
 switch(index)
    {
		
        case 0 :
            paramVal = gain; /// WHERE IS THIS getting its value from...the slider position??

        case 1:
            paramVal = gain1;
    }
return paramVal;
}

But, where is GAIN picking up from the slider? Does gainslider = whatevever the user puts in and assigned to gainslider?
code]gainSlider->setValue (ownerFilter->getParameter (0), false);[/code]
oh boy, does that make sense? :shock:


#6

I did see this in VSTGU(which i havent used):

[code]void ADelay::setParameter (long index, float value)
{
ADelayProgram * ap = &programs[curProgram];

switch (index)
{
	case kDelay :    setDelay (value); break;
	case kFeedBack : fFeedBack = ap->fFeedBack = value; break;
	case kOut :      fOut = ap->fOut = value; break;
}
if (editor)
	editor->postUpdate ();

}
[/code]
So I guess its not a syntax issue, or JUCE function issue, its more of the logic behind the parameter getting and setting, updating. Where can I find more info about how the logic structures and flow of VST programming works.?

If the sample plugin came with 2 volume knobs that would be MUCH easier to understand. Because then I can see exactly what needs to change in order to add another slider etc, by looking at the differences.

~Rob.


#7

Rob,

In the example, gain and hipass are member variables of the DemoJuceFilter class.

class DemoJuceFilter : public AudioProcessor,
                                  public ChangeBroadcaster
{
  ...
private:
    float gain;
    float hipass;
};

They hold the current values for those parameters. I think you are confusing the ‘dsp’ side of the plugin and the ‘gui’ side of the plugin. ‘gain’ is the current value of the gain parameter in the plugin, not the slider. The slider retrieves the ‘gain’ parameter and displays it, and when moved, tells the plugin to update the parameter.

It also seems like you may be new to programming? or c++? I’m just asking for context.


#8

just not used to everything being spread all over, the way it is, hard to knob what is happening at each point, instead of it being in a centeral location. AND YES, GUI and the DSP i am confusing here. See what you said, its retrieving the current gain, I thought it is just one way, that the slider tells it what it is, and thats all. Is there an explanation anywhere about what parts do what? Theres no vst tutorial anywhere.


#9

I don’t know if this will help, but just think of the ‘processing’ part of the VST as a single unit, that can be queried and controlled via the getParameter and setParameter calls.


#10

Thank you cpr that was it. I am new to programming, I mean the actual Logic of how a lot of programs work. Having NOT used VSTGUI, I was totally left in the dark when it came to the slider thing. I thought when I created a slider, It already had the parameter “gain” and would automatically update the Value, and just pass that right into the processing function. Downloading VSTGUI helped me understand it A LITTLE bit better. Still a bit iffy, but, I can add sliders and get all the params and values working now. Knowing the syntax and the actually coding is no problem, but where Do I learn more about Some of the logical techniques used in JUCE(example, setting,getting, interfacing gui with the dsp). I’m kinda at a standstill and want to really understand how programs work. Like for instance, and audiomaster callback, I have no idea what that is, How does the host communicate with the plugin, how does the plugin communicate with the host, what is thread safety. Any suggestions on any reading material that might be helpful?

~Rob.