Programming Examples

Example 1

The following SDF primitive Ramp has no inputs, just an output port. The source primitive generates a linear increasing or decreasing sequence of float particles on its output. The parameter value is initialized to define the value of the first output. Each time the primitive’s go method fires, the value parameter is updated to store the next output value. Hence, the attributes of the value parameter are set, so that the state can be overwritten by the primitive’s methods. By default, the primitive will generate the output sequence 0.0, 1.0, 2.0, etc.

Example 2

The next example is the SDF primitive MpyConstFloat, which multiplies its input by a constant and outputs the result.

Example 3

The following example of the SDF primitive Printer illustrates multiple inputs of type anytype and the use of the print method of the Particle class. The destructor method is used here also.