Chapter 2: Gain Example
Introduction
In this chapter we'll build a simple Gain effect. This will show you the basics of creating Main parameters, adding and connecting nodes in the network graph.
The nodes we'll use :
- 1x core.gain
How to connect nodes
First, in order to keep things clean let's rename the scriptFx module to something nicer :
Once the DSP network created, click into the graph. You'll get this popup showing :
Here you have access to all available nodes
Type in the search bar : "gain" and click on the gain node to add it to the graph :
Let's name it "GainFx" by right-clicking on the graph's title bar :
Done. Now let's make this gain knob available in the script editor so you can manipulate it.
Open the parameter control bar by clicking on the little upper knob, then click the "plus" icon to add a main parameter, and name it Gain
:
When you add a parameter like this, its range is always 0...1.
Now click on the target icon to acces the "connect" mode and click'n'drag a cable from the control to the parameter you want to manipulate (here the Gain
) :
How to delete a parmeter ? While in the "connect" mode, simply click on it and hit 'Suppr' or 'Del' on your keyboard.
Although it's possible to leave the knob's range as it is, the logical thing to do here it to modify the range of the Gain
. And while we're at it, why not make it possible to go above 0dB ? Let set the Max value to +24dB.Open the range editor by clicking on this little icon :
With the range editor you get the ability to drag the min and max value as well as the skew factor with the mouse. With a right-click you can access the context menu which allows you to quickly set it to different presets, or in this case, simple copy the target range to the source range (so that you don't have to edit the range of the main parameter). Now the Gain
has the correct range.
Use SHIFT+click on the left/right borders of the graph to enter custom values.
Use CTRL+click and drag the left/right borders to move the values by increments.
Uncheck the "Make sticky" option to go out of the range editor.
Then click again on the target icon to exit the "connect" mode.
How to connect the main controls to the GUI
Now that everything is set up, how to manipulate the Gain
from the plugin GUI ?
Create a slider in the interface editor, link it to the GainFx we just created, and don't forget to make its min/max values the same as the network's parameter (here : -100...+24).
But what if you want to manipulate it with script ? In the script editor, create a generic script reference of the ScriptFX module and create a custom callback for the slider on the plugin GUI.
Now you can access the network's parameter like any other in HISE. This is the whole script :
const var GainFX = Synth.getEffect("GainFX");
inline function onknobGainControl(component, value)
{
GainFX.setAttribute(GainFX.Gain, value);
};
Content.getComponent("knobGain").setControlCallback(onknobGainControl);
Voila ! You got yourself a nice little gain knob made with scriptnode. You are now ready to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