Class: BaseLfo

BaseLfo

Base lfo class to be extended in order to create new nodes.

Nodes are divided in 3 categories:

  • source are responsible for acquering a signal and its properties (frameRate, frameSize, etc.)
  • sink are endpoints of the graph, such nodes can be recorders, visualizers, etc.
  • operator are used to make computation on the input signal and forward the results below in the graph.

In most cases the methods to override / extend are:

  • the constructor to define the parameters of the new lfo node.
  • the processStreamParams method to define how the node modify the stream attributes (e.g. by changing the frame size)
  • the process{FrameType} method to define the operations that the node apply on the stream. The type of input a node can handle is defined by its implemented interface, if it implements processSignal, a stream of type signal can be processed, processVector to handle an input of type vector.

This class should be considered abstract and only be used as a base class to extend.

overview of the interface

initModule

Returns a Promise that resolves when the module is initialized. Is especially important for modules that rely on asynchronous underlying APIs.

processStreamParams(prevStreamParams)

base class (default implementation)

  • call prepareStreamParams
  • call propagateStreamParams

child class

  • override some of the inherited streamParams
  • creates the any related logic buffers
  • call propagateStreamParams

should not call super.processStreamParams

prepareStreamParams()

  • assign prevStreamParams to this.streamParams
  • check if the class implements the correct processInput method

shouldn't be extended, only consumed in processStreamParams

propagateStreamParams()

  • creates the frameData buffer
  • propagate streamParams to children

shouldn't be extended, only consumed in processStreamParams

processFrame()

base class (default implementation)

  • call prepareFrame
  • assign frameTime and frameMetadata to identity
  • call the proper function according to inputType
  • call propagateFrame

child class

  • call prepareFrame
  • do whatever you want with incomming frame
  • call propagateFrame

should not call super.processFrame

prepareFrame()

  • if reinit and trigger processStreamParams if needed

shouldn't be extended, only consumed in processFrame

propagateFrame()

  • propagate frame to children

shouldn't be extended, only consumed in processFrame

Constructor

new BaseLfo()

Source:

Members

frame :Object

Current frame. This object and its data are updated at each incomming frame without reallocating memory.

Type:
  • Object
Properties:
Name Type Description
time Number

Time of the current frame.

data Float32Array

Data of the current frame.

metadata Object

Metadata associted to the current frame.

Source:

nextModules :Array.<BaseLfo>

List of nodes connected to the ouput of the node (lower in the graph). At each frame, the node forward its frame to to all its nextModules.

Type:
  • Array.<BaseLfo>
Source:
See:

params :Object

Parameter bag containing parameter instances.

Type:
  • Object
Source:

prevModule :BaseLfo

The node from which the node receive the frames (upper in the graph).

Type:
  • BaseLfo
Source:
See:

streamParams :Object

Description of the stream output of the node. Set to null when the node is destroyed.

Type:
  • Object
Properties:
Name Type Description
frameSize Number

Frame size at the output of the node.

frameRate Number

Frame rate at the output of the node.

frameType String

Frame type at the output of the node, possible values are signal, vector or scalar.

description Array | String

If type is vector, describe the dimension(s) of output stream.

sourceSampleRate Number

Sample rate of the source of the graph. The value should be defined by sources and never modified.

sourceSampleCount Number

Number of consecutive discrete time values contained in the data frame output by the source. The value should be defined by sources and never modified.

Source:

Methods

connect(next)

Connect the current node (prevModule) to another node (nextOp). A given node can be connected to several operators and propagate frames to each of them.

Parameters:
Name Type Description
next BaseLfo

Next operator in the graph.

Source:
See:

destroy()

Destroy all the nodes in the sub-graph starting from the current node. When detroyed, the streamParams of the node are set to null, the operator is then considered as dead and cannot be reconnected.

Source:
See:

disconnect(nextopt)

Remove the given operator from its previous operators' nextModules.

Parameters:
Name Type Attributes Default Description
next BaseLfo <optional>
null

The operator to disconnect from the current operator. If null disconnect all the next operators.

Source:

finalizeStream(endTime)

Finalize the stream. A source node should call this method when stopped, finalizeStream is automatically propagated throught the graph.

Parameters:
Name Type Description
endTime Number

Logical time at which the graph is stopped.

Source:

getParamsDescription() → {Object}

Returns an object describing each available parameter of the node.

Source:
Returns:
Type
Object

initModule()

Return a Promise that resolve when the module is ready to be consumed. Some modules relies on asynchronous APIs at initialization and thus could be not ready to be consumed when the graph starts. A module should be consider as initialized when all next modules (children) are themselves initialized. The event bubbles up from sinks to sources. When all its next operators are ready, a source can consider the whole graph as ready and then start to produce frames. The default implementation resolves when all next operators are resolved themselves. An operator relying on external async API must override this method to resolve only when its dependecy is ready.

Source:
To Do:
  • - Handle dynamic connections
Returns:

Promise

initStream(streamParamsopt)

Helper to initialize the stream in standalone mode.

Parameters:
Name Type Attributes Default Description
streamParams Object <optional>
{}

Parameters of the stream.

Source:
See:

onParamUpdate(name, value, metas)

Function called when a param is updated. By default set the _reinit flag to true if the param is static one. This method should be extended to handle particular logic bound to a specific parameter.

Parameters:
Name Type Description
name String

Name of the parameter.

value Mixed

Value of the parameter.

metas Object

Metadata associated to the parameter.

Source:

prepareFrame()

Common logic to perform at the beginning of the processFrame.

Source:
See:

prepareStreamParams(prevStreamParams)

Common logic to do at the beginning of the processStreamParam, must be called at the beginning of any processStreamParam implementation.

The method mainly check if the current node implement the interface to handle the type of frame propagated by it's parent:

  • to handle a vector frame type, the class must implement processVector
  • to handle a signal frame type, the class must implement processSignal
  • in case of a 'scalar' frame type, the class can implement any of the following by order of preference: processScalar, processVector, processSignal.
Parameters:
Name Type Description
prevStreamParams Object

streamParams of the previous operator.

Source:
See:

processFrame(frame)

Define the particular logic the operator applies to the stream. According to the frame type of the previous node, the method calls one of the following method processVector, processSignal or processScalar

Parameters:
Name Type Description
frame Object

Frame (time, data, and metadata) as given by the previous operator. The incomming frame should never be modified by the operator.

Source:
See:

processFunction()

Pointer to the method called in processFrame according to the frame type of the previous operator. Is dynamically assigned in prepareStreamParams.

Source:
See:

processStreamParams(prevStreamParams)

Initialize or update the operator's streamParams according to the previous operators streamParams values.

When implementing a new operator this method should:

  1. call this.prepareStreamParams with the given prevStreamParams
  2. optionnally change values to this.streamParams according to the logic performed by the operator.
  3. optionnally allocate memory for ring buffers, etc.
  4. call this.propagateStreamParams to trigger the method on the next operators in the graph.
Parameters:
Name Type Description
prevStreamParams Object

streamParams of the previous operator.

Source:
See:

propagateFrame()

Forward the current frame to the next operators, is called at the end of processFrame.

Source:
See:

propagateStreamParams()

Create the this.frame.data buffer and forward the operator's streamParam to all its next operators, must be called at the end of any processStreamParams implementation.

Source:
See:

resetParams()

Reset all parameters to their initial value (as defined on instantication)

Source:
See:

resetStream()

Reset the frame.data buffer by setting all its values to 0. A source operator should call processStreamParams and resetStream when started, each of these method propagate through the graph automaticaly.

Source:
See: