1 #include "IPlugControls.h"
2 #include "IPlug_include_in_plug_src.h"
6 IPlugControls::IPlugControls(IPlugInstanceInfo instanceInfo
)
7 : IPLUG_CTOR(kNumParams
, kNumPrograms
, instanceInfo
)
11 // Define parameter ranges, display units, labels.
13 GetParam(kISwitchControl_2
)->InitBool("ISwitchControl 2 image multi", 0, "images");
14 GetParam(kISwitchControl_3
)->InitInt("ISwitchControl 3 image multi", 0, 0, 2, "");
16 GetParam(kIInvisibleSwitchControl
)->InitBool("IInvisibleSwitchControl", false, "");
17 mIISC_Indicator
= false;
19 GetParam(kIRadioButtonsControl_H
)->InitInt("IRadioButtonsControl Horiz", 1, 1, 4, "button");
20 GetParam(kIRadioButtonsControl_V
)->InitInt("IRadioButtonsControl Vert", 1, 1, 3, "button");
22 GetParam(kIContactControl
)->InitBool("IContactControl", 0, "");
24 GetParam(kIFaderControl_Horiz
)->InitDouble("IFaderControl Horiz", .0, .0, 12., .1, "");
25 GetParam(kIFaderControl_Vert
)->InitDouble("IFaderControl Vert", .0, .0, 12., .1, "");
27 GetParam(kIKnobLineControl_def
)->InitDouble("IKnobLineControl Default", .0, .0, 12., .1, "");
28 GetParam(kIKnobLineControl_lo_gear
)->InitDouble("IKnobLineControl Lo Gear", .0, .0, 12., .1, "");
30 GetParam(kIKnobRotaterControl_def
)->InitDouble("IKnobRotaterControl Default", 2., .0, 5., .1, "");
31 GetParam(kIKnobRotaterControl_restrict
)->InitDouble("IKnobRotaterControl Restricted", 2., .0, 5., .1, "");
33 GetParam(kIKnobMultiControl_def
)->InitInt("IKnobMultiControl Default", 1, 1, 14, "");
34 GetParam(kIKnobMultiControl_Horiz
)->InitInt("IKnobMultiControl Horiz", 1, 1, 14, "");
36 GetParam(kIKnobRotatingMaskControl
)->InitDouble("IKnobRotatingMaskControl", .0, .0, 10., 0.1, "");
38 GetParam(kICaptionControl
)->InitInt("ICaptionControl", 1, 1, 14, "label");
40 // Instantiate a graphics engine.
42 IGraphics
* pGraphics
= MakeGraphics(this, kW
, kH
); // MakeGraphics(this, kW, kH);
43 pGraphics
->AttachBackground(BG_ID
, BG_FN
);
45 // Attach controls to the graphics engine. Controls are automatically associated
46 // with a parameter if you construct the control with a parameter index.
49 // Attach the ISwitchControl 2 image "switch"
50 IBitmap bitmap
= pGraphics
->LoadIBitmap(ISWITCHCONTROL_2_ID
, ISWITCHCONTROL_2_FN
, kISwitchControl_2_N
);
51 pGraphics
->AttachControl(new ISwitchControl(this, kISwitchControl_2_X
, kISwitchControl_2_Y
, kISwitchControl_2
, &bitmap
));
53 // Attach the ISwitchControl 2 image "switch"
54 bitmap
= pGraphics
->LoadIBitmap(ISWITCHCONTROL_3_ID
, ISWITCHCONTROL_3_FN
, kISwitchControl_3_N
);
55 pGraphics
->AttachControl(new ISwitchControl(this, kISwitchControl_3_X
, kISwitchControl_3_Y
, kISwitchControl_3
, &bitmap
));
58 // Attach the IInvisibleSwitchControl target area (IRECT expects the top left, then the bottom right coordinates)
59 pGraphics
->AttachControl(new IInvisibleSwitchControl(this, IRECT(kIInvisibleSwitchControl_X
, kIInvisibleSwitchControl_Y
, kIInvisibleSwitchControl_X
+ kIISC_W
, kIInvisibleSwitchControl_Y
+ kIISC_H
), kIInvisibleSwitchControl
));
61 // Attach a graphic for the InvisibleSwitchControl indicator, not associated with any parameter,
62 // which we keep an index for, so we can push updates from the plugin class.
64 bitmap
= pGraphics
->LoadIBitmap(IRADIOBUTTONSCONTROL_ID
, IRADIOBUTTONSCONTROL_FN
, kIRadioButtonsControl_N
);
66 mIISC_Indicator
= pGraphics
->AttachControl(new IBitmapControl(this, kIISC_I_X
, kIISC_I_Y
, &bitmap
));
68 //Attach the horizontal IRadioButtonsControl
69 bitmap
= pGraphics
->LoadIBitmap(IRADIOBUTTONSCONTROL_ID
, IRADIOBUTTONSCONTROL_FN
, kIRadioButtonsControl_N
);
70 pGraphics
->AttachControl(new IRadioButtonsControl(this, IRECT(kIRadioButtonsControl_H_X
, kIRadioButtonsControl_H_Y
, kIRadioButtonsControl_H_X
+ ((kIRBC_W
*kIRBC_HN
) + 10), kIRadioButtonsControl_H_Y
+ (kIRBC_H
*kIRBC_HN
)), kIRadioButtonsControl_H
, kIRBC_HN
, &bitmap
, kHorizontal
)); // added 10 to button area to show spreading the buttons out a bit
72 //Attach the vertical IRadioButtonsControl
73 bitmap
= pGraphics
->LoadIBitmap(IRADIOBUTTONSCONTROL_ID
, IRADIOBUTTONSCONTROL_FN
, kIRadioButtonsControl_N
);
74 pGraphics
->AttachControl(new IRadioButtonsControl(this, IRECT(kIRadioButtonsControl_V_X
, kIRadioButtonsControl_V_Y
, kIRadioButtonsControl_V_X
+ (kIRBC_W
*kIRBC_VN
), kIRadioButtonsControl_V_Y
+ (kIRBC_H
*kIRBC_VN
)), kIRadioButtonsControl_V
, kIRBC_VN
, &bitmap
));
77 //Attach the IContactControl
78 bitmap
= pGraphics
->LoadIBitmap(ICONTACTCONTROL_ID
, ICONTACTCONTROL_FN
, kIContactControl_N
);
79 pGraphics
->AttachControl(new IContactControl(this, kIContactControl_X
, kIContactControl_Y
, kIContactControl
, &bitmap
));
81 //Attach the horizontal IFaderControl
82 bitmap
= pGraphics
->LoadIBitmap(IFADERCONTROL_HORIZ_ID
, IFADERCONTROL_HORIZ_FN
);
83 pGraphics
->AttachControl(new IFaderControl(this, kIFaderControl_Horiz_X
, kIFaderControl_Horiz_Y
, kIFaderControl_Horiz_L
, kIFaderControl_Horiz
, &bitmap
, kHorizontal
));
85 //Attach the vertical IFaderControl
86 bitmap
= pGraphics
->LoadIBitmap(IFADERCONTROL_VERT_ID
, IFADERCONTROL_VERT_FN
);
87 pGraphics
->AttachControl(new IFaderControl(this, kIFaderControl_Vert_X
, kIFaderControl_Vert_Y
, kIFaderControl_Vert_L
, kIFaderControl_Vert
, &bitmap
)); // kVertical is default
89 IColor lineColor
= IColor(255, 0, 0, 128);
91 //Attach the default IKnobLineControl
92 pGraphics
->AttachControl(new IKnobLineControl(this, IRECT(kIKnobLineControl_def_X
, kIKnobLineControl_def_Y
, kIKnobLineControl_def_X
+ kIKLC_W
, kIKnobLineControl_def_Y
+ kIKLC_H
), kIKnobLineControl_def
, &lineColor
));
94 //Attach the low geared IKnobLineControl
95 pGraphics
->AttachControl(new IKnobLineControl(this, IRECT(kIKnobLineControl_lo_gear_X
, kIKnobLineControl_lo_gear_Y
, kIKnobLineControl_lo_gear_X
+ kIKLC_W
, kIKnobLineControl_lo_gear_Y
+ kIKLC_H
), kIKnobLineControl_lo_gear
, &lineColor
, 0., 0., (-0.75*PI
), (0.75*PI
), kVertical
, 2.0));
97 //Attach the IKnobRotaterControl default rotation range
98 bitmap
= pGraphics
->LoadIBitmap(IKNOBROTATERCONTROL_ID
, IKNOBROTATERCONTROL_FN
);
99 pGraphics
->AttachControl(new IKnobRotaterControl(this, kIKnobRotaterControl_def_X
, kIKnobRotaterControl_def_Y
, kIKnobRotaterControl_def
, &bitmap
));
101 //Attach the IKnobRotaterControl restricted rotation range
102 bitmap
= pGraphics
->LoadIBitmap(IKNOBROTATERCONTROL_ID
, IKNOBROTATERCONTROL_FN
);
103 pGraphics
->AttachControl(new IKnobRotaterControl(this, kIKnobRotaterControl_restrict_X
, kIKnobRotaterControl_restrict_Y
, kIKnobRotaterControl_restrict
, &bitmap
, -0.5*PI
, 1.0*PI
)); //restrict range going anticlockwise to 90 degrees and let clockwise movement go full range
105 //Attach the default IKnobMultiControl
106 bitmap
= pGraphics
->LoadIBitmap(IKNOBMULTICONTROL_ID
, IKNOBMULTICONTROL_FN
, kIKnobMultiControl_N
);
107 pGraphics
->AttachControl(new IKnobMultiControl(this, kIKnobMultiControl_def_X
, kIKnobMultiControl_def_Y
, kIKnobMultiControl_def
, &bitmap
));
109 //Attach the horizontally moused IKnobMultiControl
110 bitmap
= pGraphics
->LoadIBitmap(IKNOBMULTICONTROL_ID
, IKNOBMULTICONTROL_FN
, kIKnobMultiControl_N
);
111 pGraphics
->AttachControl(new IKnobMultiControl(this, kIKnobMultiControl_Horiz_X
, kIKnobMultiControl_Horiz_Y
, kIKnobMultiControl_Horiz
, &bitmap
, kHorizontal
));
113 //Attach the IKnobRotatingMaskControl (specify the min and max angle in degrees, not radians, in this control)
114 IBitmap base
= pGraphics
->LoadIBitmap(IKRMC_BASE_ID
, IKRMC_BASE_FN
);
115 IBitmap mask
= pGraphics
->LoadIBitmap(IKRMC_MASK_ID
, IKRMC_MASK_FN
);
116 IBitmap top
= pGraphics
->LoadIBitmap(IKRMC_TOP_ID
, IKRMC_TOP_FN
);
117 pGraphics
->AttachControl(new IKnobRotatingMaskControl(this, kIKRMC_X
, kIKRMC_Y
, kIKnobRotatingMaskControl
, &base
, &mask
, &top
, -135., 135.));
119 //Attach IBitmapOverlayControl
120 bitmap
= pGraphics
->LoadIBitmap(IBOC_ID
, IBOC_FN
);
121 pGraphics
->AttachControl(new IBitmapOverlayControl(this, kIBOC_X
, kIBOC_Y
, &bitmap
, IRECT(kIBOC_T_X
, kIBOC_T_Y
, (kIBOC_T_X
+ kIBOC_T_W
), (kIBOC_T_Y
+ kIBOC_T_W
))));
123 IText text
= IText(14);
125 //Attach ITextControl
126 pGraphics
->AttachControl(new ITextControl(this, IRECT(kITC_X
, kITC_Y
, (kITC_X
+ kITC_W
), (kITC_Y
+ kITC_H
)), &text
, "Display text strings"));
128 //Attach ICaptionControl
129 pGraphics
->AttachControl(new ICaptionControl(this, IRECT(kICC_X
, kICC_Y
, (kICC_X
+ kICC_W
), (kICC_Y
+ kICC_H
)), kICaptionControl
, &text
));
132 pGraphics
->AttachControl(new IURLControl(this, IRECT(kIUC_X
, kIUC_Y
, (kIUC_X
+ kIUC_W
), (kIUC_Y
+ kIUC_W
)), "https://github.com/audio-plugins/wdl-ce/wiki"));
134 // Attach the graphics engine to the plugin.
136 AttachGraphics(pGraphics
);
138 // No cleanup necessary, the graphics engine manages all of its resources and cleans up when closed.
140 MakeDefaultPreset((char *) "-", kNumPrograms
);
143 IPlugControls::~IPlugControls() {}
145 void IPlugControls::ProcessDoubleReplacing(double** inputs
, double** outputs
, int nFrames
)
147 // Mutex is already locked for us.
149 double* in1
= inputs
[0];
150 double* in2
= inputs
[1];
151 double* out1
= outputs
[0];
152 double* out2
= outputs
[1];
154 for (int s
= 0; s
< nFrames
; ++s
, ++in1
, ++in2
, ++out1
, ++out2
)
161 void IPlugControls::OnParamChange(int paramIdx
)
163 IMutexLock
lock(this);
165 if (paramIdx
== kIInvisibleSwitchControl
)
169 GetGUI()->SetControlFromPlug(mIISC_Indicator
, GetParam(paramIdx
)->Bool());
173 if (paramIdx
== kIKnobMultiControl_def
)
177 GetGUI()->SetParameterFromPlug(kICaptionControl
, GetParam(paramIdx
)->Int(), false);
179 InformHostOfParamChange(kICaptionControl
, (GetParam(paramIdx
)->Int())/14); //inform host of new normalized value