Class: MovingMedian

MovingMedian

Compute a moving median operation on the incomming frames (scalar or vector type). If the input is of type vector, the moving median is computed for each dimension in parallel. If the source sample rate is defined frame time is shifted to the middle of the window defined by the order.

support standalone usage

Constructor

new MovingMedian(options)

Parameters:
Name Type Description
options Object

Override default parameters.

Properties
Name Type Attributes Default Description
order Number <optional>
9

Number of successive values in which the median is searched. This value must be odd. dynamic parameter

fill Number <optional>
0

Value to fill the ring buffer with before the first input frame. dynamic parameter

Source:
To Do:
  • - Implement `processSignal`
Example
import * as lfo from 'waves-lfo/common';

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

const movingMedian = new lfo.operator.MovingMedian({
  order: 5,
  fill: 0,
});

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

eventIn.connect(movingMedian);
movingMedian.connect(logger);

eventIn.start();

eventIn.processFrame(null, [1, 1]);
> [0, 0]
eventIn.processFrame(null, [2, 2]);
> [0, 0]
eventIn.processFrame(null, [3, 3]);
> [1, 1]
eventIn.processFrame(null, [4, 4]);
> [2, 2]
eventIn.processFrame(null, [5, 5]);
> [3, 3]

Methods

inputScalar(value) → {Number}

Allows for the use of a MovingMedian outside a graph (e.g. inside another node), in this case processStreamParams and resetStream should be called manually on the node.

Parameters:
Name Type Description
value Number

Value to feed the moving median with.

Source:
Returns:
  • Median value.
Type
Number
Example
import * as lfo from 'waves-lfo/client';

const movingMedian = new MovingMedian({ order: 5 });
movingMedian.initStream({ frameSize: 1, frameType: 'scalar' });

movingMedian.inputScalar(1);
> 0
movingMedian.inputScalar(2);
> 0
movingMedian.inputScalar(3);
> 1
movingMedian.inputScalar(4);
> 2

inputVector(values) → {Float32Array}

Allows for the use of a MovingMedian outside a graph (e.g. inside another node), in this case processStreamParams and resetStream should be called manually on the node.

Parameters:
Name Type Description
values Array

Values to feed the moving median with.

Source:
Returns:
  • Median values for each dimension.
Type
Float32Array
Example
import * as lfo from 'waves-lfo/client';

const movingMedian = new MovingMedian({ order: 3, fill: 0 });
movingMedian.initStream({ frameSize: 3, frameType: 'vector' });

movingMedian.inputArray([1, 1]);
> [0, 0]
movingMedian.inputArray([2, 2]);
> [1, 1]
movingMedian.inputArray([3, 3]);
> [2, 2]