Notice: Array to string conversion in /var/www/ on line 304

Warning: Parameter 1 to Language::getMagic() expected to be a reference, value given in /var/www/ on line 58
Creating a custom node that calculates sine values - SourceBinder Wiki

Creating a custom node that calculates sine values

From SourceBinder Wiki

Jump to: navigation, search

In this tutorial, you can learn how to create a simple node that calculates the sine value of a value.


Creating the node

First step is to select File/New Node from the top menu.


Then select custom and click on the next button.


Here you have to give SourceBinder some data about the node you want to create

  • Node name would be Sin
  • Category is Math
  • Library it uses is none since it does not use any other custom libraries.

It's good practice to give a short description about the node like It calculates the sine value of a number


Writing some code

Then, by clicking on the next button you can create your node.

Currently, it does not do anything at all, so let's write some code.

Double click on the node and then select the Source Editor button.


We need two variables, one that represents the input value and an other that represents the output value. Both of them is a number.


Let's define the core of our node, which is the sine calculating.

The logic you need is something like this:

output = Math.sin(input * Math.PI/180);

You have to put this logic into the update function.


Every time when this node receives an input value, the framework calls this update function and fills the output variable with the sine value of the input variable.

Only one thing left, after the output variable has changed, you have to notify the framework by calling the invalidate() method.


Let's click on the Save and Compile button to compile this code. If everything goes well, it compiles the code.

Node attributes

After that, you have to set up the Node Attributes. Click on the Node Attributes button at the bottom.


You have to define which variables are input variables and which are output variables. In this case, input is an input variable, and output is an output variable.



The Primary Input or the Primary Output means that these variables get a yellow triangle in the node representation.


Congratulation, your node is ready.


You can create a simple composition like this.


You can create a Stepper node that feeds your node and a VerticalLineChart node that draws your sine values.

By setting the Stepper node correctly, you can draw a nice sine wave.



Here you can find this composition.

Personal tools