- Print
- PDF
Node Script
A custom node contains a javascript file that provides all the functionality. It should implement certain methods that will be called by Data Flow at appropriate times.
The Node Object
Node script is expected to define a function named "createNode"
createNode = function (nodeConfig, startMessage)
{
...
return new TestNode();
}
This function will receive the node configuration and the startMessage as parameters and it is expected to return an object. This returned object represents the custom node, ie. the node object.
createNode
function is called right after startMessage is received. It is called while the project is still being built. For that reason, you cannot call raiseEvent()
inside createNode
function since the node connections has not been formed yet.
Handling Events
The node object is responsible for handling incoming events in its onEvent function.
TestNode.prototype.onEvent = function (eventInformation)
{
...
}
eventInformation is an object that contains information about a single specific event. The content may vary depending on the event itself. See here for details about event information.
Handling Audio Information
The node object is able to read audio information. In order to receive audio information in the custom node you need to implement onAudio function for your node object. If this function is defined it will be called once for every audio package flowing through the system.
TestNode.prototype.onAudio = function (audioData)
{
//audioData.channelIndex -> 0 based index of channel this audio is relevant to
//audioData.sampleIndexInChannel -> the index of this frame in all the audio data that have been received in this channel.
//audioData.sampleCount -> number of samples received in this audioData object
}