Node
The "Script" part of Scriptnode
means that you can use HiseScript to programmatically modify, add or remove nodes within a DSP network. This can be used to build up dynamic FX chains, programmatically create complex patches that would be annoying to patch up manually
or other use cases that require you to change the layout of your DSP network.
The Node
object is how you can access a node
with scripting. It is usually created / referenced from a DSPNetwork
scripting object and then can perform almost every operation that you do in the scriptnode workspace:
- create / remove nodes from a container
- setting parameters or properties
- adding / connecting parameters or modulation outputs
- bypassing / move the nodes within the parent container
// create a reference to a scriptnode network with the given ID
const var sn = Engine.createDspNetwork("my_network");
// create a reference to the root container of that network
// (!= the network itself)
const var rootNode = sn.get("my_network");
// Add a oscillator with the ID "osc"
const var node = sn.create("core.oscillator", "osc");
// Add the oscillator to the root container.
node.setParent(rootNode, -1);
Console.print(node.getNumParameters());
Class methods
connectTo
Connects this node to the given parameter target. sourceInfo is either the parameter name (String) or output slot (integer).
Node.connectTo(var parameterTarget, var sourceInfo)
This function can be used to connect the modulation output of this node to a target parameter.
If you want to connect a parameter of a container to another parameter you will need to use the Parameter.addConnectionFrom() method which operates on the target parameter.
You can call this method on any node that has one or more modulation outputs. This modulation output will be the source of the connection and the method will create a connection from this output to the targetParameter:
- the parameterTarget parameter must be a Parameter object that references the parameter that will be the target of the connection.
- the sourceInfo parameter is providing additional information for certain cases. If the node has multiple modulation outputs (like eg. the control.xfader node), you can specify at which output slot it should connect to. For single modulation slots this parameter is ignored.
connectToBypass
Connects the bypass button of this node to the given source info ("NodeId.ParameterId"). Edit on GitHub
Node.connectToBypass(var sourceInfo)
get
Returns a property of the node. Edit on GitHub
Node.get(var id)
getChildNodes
Returns a list of child nodes if this node is a container. Edit on GitHub
Node.getChildNodes(bool recursive)
getIndexInParent
Returns the index in the parent. Edit on GitHub
Node.getIndexInParent()
getNodeHolder
Not necessarily the DSP network. Edit on GitHub
Node.getNodeHolder()
getNumParameters
Returns the number of parameters. Edit on GitHub
Node.getNumParameters()
getOrCreateParameter
Returns a reference to a parameter or creates a parameter (if non existent and possible). Edit on GitHub
Node.getOrCreateParameter(var indexOrId)
isActive
Checks if the node is inserted into the signal path. Edit on GitHub
Node.isActive(bool checkRecursively)
isBypassed
Checks if the node is bypassed. Edit on GitHub
Node.isBypassed()
reset
Reset the node's internal state (eg. at voice start). Edit on GitHub
Node.reset()=0
set
Sets the property of the node.
Node.set(var id, var value)
There are two concepts of "states" for a node:
- Parameters are single double precision float numbers which can be changed in realtime via modulation slots or parameter connections. They are always dynamic and if you compile the network to a C++ class, you can still modify these through the parameter connections.
- Properties are type-agnostic values that define a static property of a node. If you compile a network to a C++ class, these will be turned into compile-time constants that define the behaviour.
Examples for parameters:
- volume parameter of a gain node
- frequency parameter of an oscillator
- filter type of a EQ
Examples for properties
- data slot index to an external audio file slot
- crossfade curve of the xfader node
- conversion function of the converter node
setBypassed
Bypasses the node. Edit on GitHub
Node.setBypassed(bool shouldBeBypassed)
setComplexDataIndex
Sets the complex data type at the dataSlot to the given index and data (if embedded). Edit on GitHub
Node.setComplexDataIndex(String dataType, int dataSlot, int indexValue)
setParent
Inserts the node into the given parent container. Edit on GitHub
Node.setParent(var parentNode, int indexInParent)