Docs

DisplayBuffer


There are a lot of nodes in scriptnode which offer some kind of visualisation data:

By default, they are only visible inside the scriptnode editor, but you can choose to expose certain data sources to your UI.

How to connect a DisplayBuffer

  1. Make sure to expose the display buffer of the node you want to visualise by assigning an External Data slot to it (click on the plot icon next to the display on the node editor and choose a free slot in the popup menu). Be aware that this system is using a single-writer rule, so you can't assign multiple nodes to the same external slot!
  2. Generate a (typed) reference to a DisplayBufferSource by passing in the ID of the script module that hosts the network.
  3. Call DisplayBufferSource.getDisplayBuffer() with the index of the data slot that you assigned in step 1


Class methods

createPath

Creates a path objects scaled to the given bounds and sourceRange

DisplayBuffer.createPath(var dstArea, var sourceRange, var normalisedStartValue)


If you want to draw a path using the buffer data (for oscilloscopes or plotters), this function will do the heavy lifting for you and supply you with a Path object that you can directly draw on a ScriptPanel .

The parameters for this function allow a fine-grained control over the appearance of the path:

Parameter Type Description
dstArea [x, y, w, h] the target rectangle for the path (it will be scaled automatically to fit this rectangle).
sourceRange [x, y, w, h] a rectangle that will determine the "input scale". s[0] and s[1] are the min and max values that you want to draw and s[2] and s[3] define the index range if s[3] == -1 then it will use the entire buffer.
start double the normalised start and end value that can be used to control the start and end points of the path.

Here are a few example use cases:

// Oscilloscope:
d.createPath([0, 0, w, h],   // target rectangle 
             [-1, 1, 0, -1], // samplerange 0 - numSamples,
                             // valuerange: from -1 to 1
             0.0);           // start at the center (bipolar)

// Plotter
d.createPath([0, 0, w, h],   // target rectangle 
             [0, 1, 0, -1],  // samplerange 0 - numSamples,
                             // valuerange: from 0 to 1
             0.0);           // start at the bottom (unibipolar)

// Inverted Plotter
d.createPath([0, 0, w, h],   // target rectangle 
             [0, 1, 0, -1],  // samplerange 0 - numSamples,
                             // valuerange: from 0 to 1
             1.0);           // start at the top (negative)

Be aware that the path that is created is not closed (so you need to call Path.closeSubPath() manually if you need a closed path.

getReadBuffer

Returns a reference to the internal read buffer.

DisplayBuffer.getReadBuffer()


This function returns the raw Buffer containing the visualisation data that you can use for implementing a custom visualisation.

This is the most low-level access to the data and the other methods available offer a more "refined" access.

getResizedBuffer

Resamples the buffer to a fixed size.

DisplayBuffer.getResizedBuffer(int numDestSamples, int resampleMode)


The size of the display buffer is not static and depends on the source signal. If your visualisation depends on a fixed buffer length, you can use this method to automatically rescale the buffer content.
This will create a copy of the buffer with the given sample amount and use a sensible default algorithm to do the resampling.

If you want to pass the buffer to a shader as uniform make sure to resample it to be below 1024.

setActive

Enables or disables the ring buffer.

DisplayBuffer.setActive(bool shouldBeActive)



setRingBufferProperties

Sets the ring buffer properties from an object (Use the JSON from the Edit Properties popup).

DisplayBuffer.setRingBufferProperties(var propertyData)