API Docs for: 2.7.1
Show:

BaseSound Class

Module: Core

Pseudo AudioNode class the encapsulates basic functionality of an Audio Node. To be extended by all other Sound Models

Constructor

BaseSound

(
  • [context]
)

Parameters:

  • [context] AudioContext optional

    AudioContext in which this Sound is defined.

Methods

connect

(
  • destination
  • [output]
  • [input]
)

If the parameter output is an AudioNode, it connects to the releaseGainNode. If the output is a BaseSound, it will connect BaseSound's releaseGainNode to the output's inputNode.

Parameters:

  • destination AudioNode

    AudioNode to connect to.

  • [output] Number optional

    Index describing which output of the AudioNode from which to connect.

  • [input] Number optional

    Index describing which input of the destination AudioNode to connect to.

disconnect

(
  • [outputIndex]
)

Disconnects the Sound from the AudioNode Chain.

Parameters:

  • [outputIndex] Number optional

    Index describing which output of the AudioNode to disconnect.

listParams

(
  • [paramArray]
)

List all SPAudioParams this Sound exposes

Parameters:

  • [paramArray] Array optional

    Array of all the SPAudioParams this Sound exposes.

pause

()

Pause sound. Abstract method. Override this method when a Node is defined.

play

()

Play sound. Abstract method. Override this method when a Node is defined.

release

(
  • [when]
  • [fadeTime]
  • [resetOnRelease]
)

Linearly ramp down the gain of the audio in time (seconds) to 0.

Parameters:

  • [when] Number optional

    Time (in seconds) at which the Envelope will release.

  • [fadeTime] Number optional

    Amount of time (seconds) it takes for linear ramp down to happen.

  • [resetOnRelease] Boolean optional

    Boolean to define if release stops (resets) the playback or just pauses it.

setOutputEffect

(
  • effect
)

Adds an sound effect to the output of this model, and connects the output of the effect to the Audio Destination

Parameters:

  • effect Object

    An Sound Effect of type BaseEffect to be appended to the output of this Sound.

setSources

(
  • sources
  • [onLoadProgress]
  • [onLoadComplete]
)

Reinitializes the model and sets it's sources.

Parameters:

  • sources Array/AudioBuffer/String/File

    Single or Array of either URLs or AudioBuffers or File Objects of the audio sources.

  • [onLoadProgress] Function optional

    Callback when the audio file is being downloaded.

  • [onLoadComplete] Function optional

    Callback when all sources have finished loading.

start

(
  • when
  • [offset]
  • [duration]
  • [attackDuration]
)

Start the AudioNode. Abstract method. Override this method when a Node is defined.

Parameters:

  • when Number

    Time (in seconds) when the sound should start playing.

  • [offset] Number optional

    The starting position of the playhead

  • [duration] Number optional

    Duration of the portion (in seconds) to be played

  • [attackDuration] Number optional

    Duration (in seconds) of attack ramp of the envelope.

stop

(
  • [when]
)

Stop the AudioNode. Abstract method. Override this method when a Node is defined.

Parameters:

  • [when] Number optional

    Time (in seconds) the sound should stop playing

Properties

audioContext

AudioContext

Web Audio API's AudioContext. If the context passed to the constructor is an AudioContext, a new one is created here.

destinations

Array

Set of nodes the output of this sound is currently connected to.

inputNode

Object

The input node that the output node will be connected to.
Set this value to null if no connection can be made on the input node

Default: null

isInitialized

Boolean

If Sound is currently initialized.

Default: false

isPlaying

Boolean

If Sound is currently playing.

Default: false

maxSources

Number

Maximum number of sources that can be given to this Sound

Default: 0

minSources

Number

Minimum number of sources that can be given to this Sound

Default: 0

modelName

String

String name of the model.

Default: "Model"

numberOfInputs

Number

Number of inputs

Default: 0

numberOfOutputs

Number

Number of outputs

Default: 0

onAudioEnd

Function

Callback for the audio is about to stop playing.

Default: null

onAudioStart

Function

Callback for when the audio is about to start playing.

Default: null

onLoadComplete

Function

Callback for when loading of audio files is done and the the model is initalized.

Default: null

onLoadProgress

Function

Callback for handling progress events thrown during loading of audio files.

Default: null

releaseGainNode

GainNode final

Release Gain Node

Default: Internal GainNode