Constructor
new MovingAverage(options)
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | Override default parameters. Properties
|
- Source:
- To Do:
-
- - Implement `processSignal` ?
Example
import * as lfo from 'waves-lfo/common';
const eventIn = new lfo.source.EventIn({
frameSize: 2,
frameType: 'vector'
});
const movingAverage = new lfo.operator.MovingAverage({
order: 5,
fill: 0
});
const logger = new lfo.sink.Logger({ data: true });
eventIn.connect(movingAverage);
movingAverage.connect(logger);
eventIn.start();
eventIn.process(null, [1, 1]);
> [0.2, 0.2]
eventIn.process(null, [1, 1]);
> [0.4, 0.4]
eventIn.process(null, [1, 1]);
> [0.6, 0.6]
eventIn.process(null, [1, 1]);
> [0.8, 0.8]
eventIn.process(null, [1, 1]);
> [1, 1]
Methods
inputScalar(value) → {Number}
Use the MovingAverage
operator in standalone
mode (i.e. outside of a
graph) with a scalar
input.
Parameters:
Name | Type | Description |
---|---|---|
value |
Number | Value to feed the moving average with. |
- Source:
Returns:
- Average value.
- Type
- Number
Example
import * as lfo from 'waves-lfo/client';
const movingAverage = new lfo.operator.MovingAverage({ order: 5 });
movingAverage.initStream({ frameSize: 1, frameType: 'scalar' });
movingAverage.inputScalar(1);
> 0.2
movingAverage.inputScalar(1);
> 0.4
movingAverage.inputScalar(1);
> 0.6
inputVector(values) → {Float32Array}
Use the MovingAverage
operator in standalone
mode (i.e. outside of a
graph) with a vector
input.
Parameters:
Name | Type | Description |
---|---|---|
values |
Array | Values to feed the moving average with. |
- Source:
Returns:
- Average value for each dimension.
- Type
- Float32Array
Example
import * as lfo from 'waves-lfo/client';
const movingAverage = new lfo.operator.MovingAverage({ order: 5 });
movingAverage.initStream({ frameSize: 2, frameType: 'scalar' });
movingAverage.inputArray([1, 1]);
> [0.2, 0.2]
movingAverage.inputArray([1, 1]);
> [0.4, 0.4]
movingAverage.inputArray([1, 1]);
> [0.6, 0.6]