Class: OnOff

OnOff

The OnOff operator allows to stop the propagation of the stream in a subgraph. When "on", frames are propagated, when "off" the propagation is stopped.

The streamParams propagation is never bypassed so the subsequent subgraph is always ready for incomming frames.

Constructor

new OnOff(options)

Parameters:
Name Type Description
options Object

Override default parameters.

Properties
Name Type Attributes Default Description
state String <optional>
'on'

Default state.

Source:
Example
import * as lfo from 'waves-lfo/common';

const frames = [
  { time: 0, data: [1, 2] },
  { time: 1, data: [3, 4] },
  { time: 2, data: [5, 6] },
];

const eventIn = new EventIn({
  frameSize: 2,
  frameRate: 0,
  frameType: 'vector',
});

const onOff = new OnOff();

const logger = new Logger({ data: true });

eventIn.connect(onOff);
onOff.connect(logger);

eventIn.start();

eventIn.processFrame(frames[0]);
> [0, 1]

// bypass subgraph
onOff.setState('off');
eventIn.processFrame(frames[1]);

// re-open subgraph
onOff.setState('on');
eventIn.processFrame(frames[2]);
> [5, 6]

Methods

setState(state)

Set the state of the OnOff.

Parameters:
Name Type Description
state String

New state of the operator (on or off)

Source: