Class: SpectrumDisplay

SpectrumDisplay

Display the spectrum of the incomming signal input.

Constructor

new SpectrumDisplay(options)

Parameters:
Name Type Description
options Object

Override default parameters.

Properties
Name Type Attributes Default Description
scale Number <optional>
1

Scale display of the spectrogram.

color String <optional>
null

Color of the spectrogram.

min Number <optional>
-80

Minimum displayed value (in dB).

max Number <optional>
6

Maximum displayed value (in dB).

width Number <optional>
300

Width of the canvas. dynamic parameter

height Number <optional>
150

Height of the canvas. dynamic parameter

container Element | CSSSelector <optional>
null

Container element in which to insert the canvas. constant parameter

canvas Element | CSSSelector <optional>
null

Canvas element in which to draw. constant parameter

Source:
To Do:
  • - expose more `fft` config options
Example
import * as lfo from 'waves-lfo/client';

const audioContext = new AudioContext();

navigator.mediaDevices
  .getUserMedia({ audio: true })
  .then(init)
  .catch((err) => console.error(err.stack));

function init(stream) {
  const source = audioContext.createMediaStreamSource(stream);

  const audioInNode = new lfo.source.AudioInNode({
    audioContext: audioContext,
    sourceNode: source,
  });

  const spectrum = new lfo.sink.SpectrumDisplay({
    canvas: '#spectrum',
  });

  audioInNode.connect(spectrum);
  audioInNode.start();
}