Class: Slicer

Slicer

Change the frameSize and hopSize of a signal input according to the given options. This operator updates the stream parameters according to its configuration.

Constructor

new Slicer(options)

Parameters:
Name Type Description
options Object

Override default parameters.

Properties
Name Type Attributes Default Description
frameSize Number <optional>
512

Frame size of the output signal.

hopSize Number <optional>
null

Number of samples between two consecutive frames. If null, hopSize is set to frameSize.

centeredTimeTags Boolean <optional>

Move the time tag to the middle of the frame.

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

const eventIn = new lfo.source.EventIn({
  frameType: 'signal',
  frameSize: 10,
  sampleRate: 2,
});

const slicer = new lfo.operator.Slicer({
  frameSize: 4,
  hopSize: 2
});

const logger = new lfo.sink.Logger({ time: true, data: true });

eventIn.connect(slicer);
slicer.connect(logger);
eventIn.start();

eventIn.process(0, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
> { time: 0, data: [0, 1, 2, 3] }
> { time: 1, data: [2, 3, 4, 5] }
> { time: 2, data: [4, 5, 6, 7] }
> { time: 3, data: [6, 7, 8, 9] }