Audio Class

Extends Resource
Module: Resources

Audio class is used to store audio data as a arraybuffer to be later used by objects with the WebAudio API.

Constructor

Audio

(
  • url
  • encoding
)

Parameters:

  • url ArrayBuffer, String

    URL to Audio file or ArrayBuffer data.

  • encoding String

    Audio encoding (mp3, wav, etc).

Item Index

Methods

fileIsAudio

(
  • file
)
Boolean static

Check if a file name refers to a supported audio file.

Parameters:

  • file File

Returns:

Boolean:

True if the file refers to a supported audio format.

getAudioBuffer

(
  • context
  • callback
)

Get an WebAudio buffer to play the audio stored in this resources.

This method is asyncronous and the value is returned using a callback function.

Parameters:

  • context AudioContext

    WebAudio context used to decode the audio data.

  • callback Function

    Callback funtion that receives an audio buffer as argument.

toJSON

(
  • meta
)
Object

Serialize audio data as json.

Audio data is serialized in Base64.

Parameters:

  • meta Meta

Returns:

Object:

data