Class: EventIn

EventIn

The EventIn operator allows to manually create a stream of data or to feed a stream from another source (e.g. sensors) into a processing graph.

Constructor

new EventIn(options)

Parameters:
Name Type Description
options Object

Override parameters' default values.

Properties
Name Type Attributes Default Description
frameType String <optional>
'signal'

Type of the input - allowed values: signal, vector or scalar.

frameSize Number <optional>
1

Size of the output frame.

sampleRate Number <optional>
null

Sample rate of the source stream, if of type signal.

frameRate Number <optional>
null

Rate of the source stream, if of type vector.

description Array | String <optional>

Optionnal description describing the dimensions of the output frame

absoluteTime Boolean <optional>
false

Define if time should be used as forwarded as given in the process method, or relatively to the time of the first process call after start.

Source:
To Do:
  • - Add a `logicalTime` parameter to tag frame according to frame rate.
Example
import * as lfo from 'waves-lfo/client';

const eventIn = new lfo.source.EventIn({
  frameType: 'vector',
  frameSize: 3,
  frameRate: 1 / 50,
  description: ['alpha', 'beta', 'gamma'],
});

// connect source to operators and sink(s)

// initialize and start the graph
eventIn.start();

// feed `deviceorientation` data into the graph
window.addEventListener('deviceorientation', (e) => {
  const frame = {
    time: window.performace.now() / 1000,
    data: [e.alpha, e.beta, e.gamma],
  };

  eventIn.processFrame(frame);
}, false);

Methods

process(time, data, metadata)

Alternative interface to propagate a frame in the graph. Pack time, data and metadata in a frame object.

Parameters:
Name Type Default Description
time Number

Frame time.

data Float32Array | Array

Frame data.

metadata Object null

Optionnal frame metadata.

Source:
Example
eventIn.process(1, [0, 1, 2]);
// is equivalent to
eventIn.processFrame({ time: 1, data: [0, 1, 2] });

processFrame(frame)

Propagate a frame object in the graph.

Parameters:
Name Type Description
frame Object

Input frame.

Properties
Name Type Attributes Description
time Number

Frame time.

data Float32Array | Array

Frame data.

metadata Object <optional>

Optionnal frame metadata.

Source:
Example
eventIn.processFrame({ time: 1, data: [0, 1, 2] });

start()

Propagate the streamParams in the graph and allow to push frames into the graph. Any call to process or processFrame before start will be ignored.

Source:
See:

stop()

Finalize the stream and stop the whole graph. Any call to process or processFrame after stop will be ignored.

Source:
See: