Function analyserBasic

Basic audio analyser. Returns back waveform and FFT analysis. Use analyserPeakLevel if you want sound level, or analyserFrequency if you just want FFT results.

const onData = (freq, wave, analyser) => {
// Demo: Get FFT results just for 100Hz-1KHz.
const freqSlice = analyser.sliceByFrequency(100,1000,freq);

// Demo: Get FFT value for a particular frequency (1KHz)
const amt = freq[analyser.getIndexForFrequency(1000)];
}
analyserBasic(onData, {fftSize: 512});

An Analyser instance is returned and can be controlled:

const analyser = analyserBasic(onData);
analyser.paused = true;

Note: Browers won't allow microphone access unless the call has come from a user-interaction, eg pointerup event handler.

  • Parameters

    • onData: ((freq: Float32Array, wave: Float32Array, analyser: AudioAnalyser) => void)

      Handler for data

        • (freq, wave, analyser): void
        • Parameters

          Returns void

    • opts: Io.Audio.Opts = {}

      Options

    Returns AudioAnalyser

    Analyser instance