Class: Magnitude

Magnitude

Compute the magnitude of a vector input.

support standalone usage

Constructor

new Magnitude(options)

Parameters:
Name Type Description
options Object

Override default parameters.

Properties
Name Type Attributes Default Description
normalize Boolean <optional>
true

Normalize output according to the vector size.

power Boolean <optional>
false

If true, returns the squared magnitude (power).

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

const eventIn = new lfo.source.EventIn({ frameSize: 2, frameType: 'vector' });
const magnitude = new lfo.operator.Magnitude();
const logger = new lfo.sink.Logger({ outFrame: true });

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

eventIn.process(null, [1, 1]);
> [1]
eventIn.process(null, [2, 2]);
> [2.82842712475]
eventIn.process(null, [3, 3]);
> [4.24264068712]

Methods

inputVector(values) → {Number}

Use the Magnitude operator in standalone mode (i.e. outside of a graph).

Parameters:
Name Type Description
values Array | Float32Array

Values to process.

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

const magnitude = new lfo.operator.Magnitude({ power: true });
magnitude.initStream({ frameType: 'vector', frameSize: 3 });
magnitude.inputVector([3, 3]);
> 4.24264068712