Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface AudioAnalyser

Create a AudioAnalyser object, which uses an AnalyserNode to analyse audio data.

This uses the Web Audio API See the ngx3js docs page for details.

Examples

webaudio / sandbox | webaudio / visualizer

Code Example

//  create an AudioListener and add it to the camera
const listener = new THREE.AudioListener();
camera.add( listener );
// create an Audio source
const sound = new THREE.Audio( listener );
// load a sound and set it as the Audio object's buffer
const audioLoader = new THREE.AudioLoader();
audioLoader.load(
'sounds/ambient.ogg',
function( buffer ) {
sound.setBuffer( buffer );
sound.setLoop(true);
sound.setVolume(0.5);
sound.play();
}
);
// create an AudioAnalyser, passing in the sound and desired fftSize
const analyser = new THREE.AudioAnalyser( sound, 32 );
// get the average frequency of the sound
const data = analyser.getAverageFrequency();

Ngx3Js Code Example

<ngx3js-camera>
<ngx3js-listener></ngx3js-listener>
</ngx3js-camera>
<ngx3js-audio [url]="'sounds/ambient.ogg'" [volume]="0.5" [loop]="true" [play]="true"></ngx3js-audio>

Hierarchy

  • AudioAnalyser

Index

Constructors

constructor

Properties

analyser

analyser: AnalyserNode

An AnalyserNode used to analyze audio.

data

data: Uint8Array

A Uint8Array with size determined by analyser.frequencyBinCount used to hold analysis data.

fftSize

fftSize: number

A non-zero power of two up to 2048, representing the size of the FFT (Fast Fourier Transform) to be used to determine the frequency domain. See this page for details.

Methods

getAverageFrequency

  • getAverageFrequency(): number

getFrequencyData

  • getFrequencyData(): Uint8Array

Generated using TypeDoc