jecho - An easy-to-use js audio library

API Docs for: 0.0.1
Module jecho

Class Audio

The base class of all audio types

Constructor

void

Audio

(
  • driver: String
)

Parameters

  • driver String

    The driver to use for manipulating audio

    • jecho.drivers.BUFFERED [ default ]
    • jecho.drivers.UNBUFFERED

Properties

Float

duration

The audio duration in seconds.

Integer

fftSize

Get / set the size of the fft to use for both the spectrum and waveform.

Boolean

isPlaying

Is the audio currently playing ?

Boolean

loop

Get / set the looping status

Float

pan

Get / set the sound panning between -1 and +1 where:

-1is fully on the left
0is on the center (default)
+1is fully on the right
Float

pitch

Get / set the sound pitch within [0,~]

Float

position

Get / set the audio playing position from 0 to 1.

Array

spectrum

Get the current sound spectrum

Float

volume

Get / set the sound volume between 0 and 1.

Array

waveform

Get the signal waveform

Method summary

void

addFilter

(
  • filter: AudioFilter
)
chainable

Add a filter to make some effects on the sound

Promise

load

(
  • src: String
)

Load a sound from source filename

static Promise

load

( )

Load an audio file.

Audio

on

(
  • type: String
  • callback: Function
)
chainable
void

pause

( )

Stop the sound and save the position

void

play

( )

Play the audio

void

removeFilter

(
  • filter: jecho.AudioFilter
)
chainable

Remove an audio filter

void

stop

( )

Stop the sound and reset the position

Methods

void

addFilter

(
  • filter: AudioFilter
)
chainable

Add a filter to make some effects on the sound

Parameters

Promise

load

(
  • src: String
)

Load a sound from source filename

Parameters

  • src String

Returns

Promise:

Example

var audio = new jecho.Audio();
audio.load('my/super/music').then(
    // on success
    function(audio){
        audio.pitch = 1.2;
        audio.play();
    },
    // on error
    function (error){

    }
);
static Promise

load

( )

Load an audio file.

Returns

Promise:
Audio

on

(
  • type: String
  • callback: Function
)
chainable

Parameters

  • type String

    Event type

  • callback Function

    The callback function

Returns

void

pause

( )

Stop the sound and save the position

void

play

( )

Play the audio

void

removeFilter

(
  • filter: jecho.AudioFilter
)
chainable

Remove an audio filter

Parameters

  • filter jecho.AudioFilter

    The filter to be removed

void

stop

( )

Stop the sound and reset the position