Home Reference Source
public class | source

Vizualizer

Small library to simplify the creation of audio visualisation

Static Method Summary

Static Public Methods
public static

withArrayBuffer(arrayBuffer: ArrayBuffer, bufferLength: number): Vizualizer

Create a new Vizualizer with the specified array buffer

public static

withContextSource(context: AudioContext, source: AudioSourceNode, bufferLength: number): Vizualizer

Create a new Vizualizer with the specified audio context and source

public static

withElement(element: Element, bufferLength: number): Vizualizer

Create a new Vizualizer with the specified audio element

public static

withMedia(mediaUrl: String, bufferLength: number): Vizualizer

Create a new Vizualizer with the specified url of a media

Constructor Summary

Public Constructor
public

Default constructor with null members

Member Summary

Public Members
public

audioAnalyser: AnalyserNode

Audio Analyser

public

Audio Context

public

Audio Element

public

audioSource: AudioSourceNode

Audio Source

public

Array of data of the audio

public

Array of effects

public

The ID value returned by the call to window.requestAnimationFrame()

Method Summary

Public Methods
public

Add an effect at the end of the array

public

changeEffect(effectVizualizer: EffectVizualizer, i: number)

Change the effect of the vizualizer

public

Initialize the visibilty change event to stop the visualisation when the page is not visible.

public

Load the vizualizer with the specified array buffer

public

Change the audio context

public

loadDataUrl(dataUrl: string)

Load the vizualizer with the specified data url

public

loadElement(element: Element)

Change the audio element

public

Remove the last effect added

public

Remove the effect specified by the index

public

start()

Start the visualisation

public

Render every effect in the array effects

public

stop()

Stop the visualisation

Static Public Methods

public static withArrayBuffer(arrayBuffer: ArrayBuffer, bufferLength: number): Vizualizer source

Create a new Vizualizer with the specified array buffer

Params:

NameTypeAttributeDescription
arrayBuffer ArrayBuffer

Array buffer

bufferLength number
  • optional
  • default: 1024

The length of the buffer

Return:

Vizualizer

Return a new Vizualizer

Throw:

Error

Web Audio not supported by the browser

public static withContextSource(context: AudioContext, source: AudioSourceNode, bufferLength: number): Vizualizer source

Create a new Vizualizer with the specified audio context and source

Params:

NameTypeAttributeDescription
context AudioContext

Audio context

source AudioSourceNode

Source

bufferLength number
  • optional
  • default: 1024

The length of the buffer

Return:

Vizualizer

Return a new Vizualizer

public static withElement(element: Element, bufferLength: number): Vizualizer source

Create a new Vizualizer with the specified audio element

Params:

NameTypeAttributeDescription
element Element

Audio element <audio>

bufferLength number
  • optional
  • default: 1024

The length of the buffer

Return:

Vizualizer

Return a new Vizualizer

Throw:

Error

Web Audio not supported by the browser

public static withMedia(mediaUrl: String, bufferLength: number): Vizualizer source

Create a new Vizualizer with the specified url of a media

Params:

NameTypeAttributeDescription
mediaUrl String

Url of the media

bufferLength number
  • optional
  • default: 1024

The length of the buffer

Return:

Vizualizer

Return a new Vizualizer

Throw:

Error

Web Audio not supported by the browser

Public Constructors

public constructor source

Default constructor with null members

Public Members

public audioAnalyser: AnalyserNode source

Audio Analyser

public audioContext: AudioContext source

Audio Context

public audioElement: Element source

Audio Element

public audioSource: AudioSourceNode source

Audio Source

public dataArray: Uint8Array source

Array of data of the audio

public effects: Array source

Array of effects

public requestId: number source

The ID value returned by the call to window.requestAnimationFrame()

Public Methods

public addEffect(effect: EffectVizualizer) source

Add an effect at the end of the array

Params:

NameTypeAttributeDescription
effect EffectVizualizer

Effect to add

public changeEffect(effectVizualizer: EffectVizualizer, i: number) source

Change the effect of the vizualizer

Params:

NameTypeAttributeDescription
effectVizualizer EffectVizualizer

Effect

i number
  • optional
  • default: 0

Index of the effect to change

public initializeVisibilityEvent() source

Initialize the visibilty change event to stop the visualisation when the page is not visible.

public loadArrayBuffer(arraybuffer: ArrayBuffer) source

Load the vizualizer with the specified array buffer

Params:

NameTypeAttributeDescription
arraybuffer ArrayBuffer

Array buffer to load

public loadAudioContext(context: AudioContext) source

Change the audio context

Params:

NameTypeAttributeDescription
context AudioContext

AudioContext

public loadDataUrl(dataUrl: string) source

Load the vizualizer with the specified data url

Params:

NameTypeAttributeDescription
dataUrl string

Url of the data

public loadElement(element: Element) source

Change the audio element

Params:

NameTypeAttributeDescription
element Element

Element

public popEffect() source

Remove the last effect added

public removeEffect(index: number) source

Remove the effect specified by the index

Params:

NameTypeAttributeDescription
index number

Index of the element that should be remove from the effects array

public start() source

Start the visualisation

public startRender() source

Render every effect in the array effects

public stop() source

Stop the visualisation