API Docs for: 2.7.1
Show:

Looper Class

Extends BaseSound
Module: Models

A model which loads one or more sources and allows them to be looped continuously at variable speed.

Constructor

Looper

(
  • [context]
  • [sources]
  • [onLoadProgress]
  • [onLoadComplete]
  • [onAudioStart]
  • [onAudioEnd]
  • [onTrackEnd]
)

Parameters:

  • [context] AudioContext optional

    AudioContext to be used.

  • [sources] Array/String/AudioBuffer/SPAudioBuffer/File optional

    Single or Array of either URLs or AudioBuffers or File Object of the audio source.

  • [onLoadProgress] Function optional

    Callback when the audio file is being downloaded.

  • [onLoadComplete] Function optional

    Callback when all sources have finished loading.

  • [onAudioStart] Function optional

    Callback when the audio is about to start playing.

  • [onAudioEnd] Function optional

    Callback when the audio has finished playing.

  • [onTrackEnd] Function optional

    Callback when an individual track has finished playing.

Methods

connect

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

Inherited from BaseSound:

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]
)

Inherited from BaseSound:

Disconnects the Sound from the AudioNode Chain.

Parameters:

  • [outputIndex] Number optional

    Index describing which output of the AudioNode to disconnect.

listParams

(
  • [paramArray]
)

Inherited from BaseSound:

List all SPAudioParams this Sound exposes

Parameters:

  • [paramArray] Array optional

    Array of all the SPAudioParams this Sound exposes.

pause

()

Inherited from BaseSound

Pause the currently playing model at the current position.

play

()

Inherited from BaseSound

Plays the model immediately. If the model is paused, the model will be played back from the same position as it was paused at.

release

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

Inherited from BaseSound

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 resets (stops) the playback or just pauses it.

setOutputEffect

(
  • effect
)

Inherited from BaseSound:

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]
)

Inherited from BaseSound

Reinitializes a Looper and sets it's sources.

Parameters:

  • sources Array/AudioBuffer/String/File

    Single or Array of either URLs or AudioBuffers of 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]
)

Inherited from BaseSound

Start playing after specific time and from a specific offset.

Parameters:

  • when Number

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

  • [offset] Number optional

    The starting position of the playhead in seconds

  • [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
)

Inherited from BaseSound

Stops the model and resets play head to 0.

Parameters:

  • when Number

    Time offset to stop

Properties

audioContext

AudioContext

Inherited from BaseSound:

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

destinations

Array

Inherited from BaseSound:

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

easeIn

SPAudioParam

Rate of increase of Play Speed. It is the time-constant value of first-order filter (exponential) which approaches the target speed set by the playSpeed property.

Default: 0.05

easeOut

SPAudioParam

Rate of decrease of Play Speed. It is the time-constant value of first-order filter (exponential) which approaches the target speed set by the playSpeed property.

Default: 0.05

inputNode

Object

Inherited from BaseSound:

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

Inherited from BaseSound:

If Sound is currently initialized.

Default: false

isPlaying

Boolean

Inherited from BaseSound:

If Sound is currently playing.

Default: false

maxLoops

SPAudioParam

The maximum number time the source will be looped before stopping. Currently only supports -1 (loop indefinitely), and 1 (only play the track once, ie. no looping).

Default: -1 (Infinite)

maxSources

Number

Inherited from BaseSound:

Maximum number of sources that can be given to this Sound

Default: 0

minSources

Number

Inherited from BaseSound:

Minimum number of sources that can be given to this Sound

Default: 0

modelName

String

Inherited from BaseSound:

String name of the model.

Default: "Model"

multiTrackGain

Array of SPAudioParams

The volume (loudness) for each individual track if multiple sources are used. Works even if a single source is used.

Default: 1.0

numberOfInputs

Number

Inherited from BaseSound:

Number of inputs

Default: 0

numberOfOutputs

Number

Inherited from BaseSound:

Number of outputs

Default: 0

onAudioEnd

Function

Inherited from BaseSound:

Callback for the audio is about to stop playing.

Default: null

onAudioStart

Function

Inherited from BaseSound:

Callback for when the audio is about to start playing.

Default: null

onLoadComplete

Function

Inherited from BaseSound:

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

Default: null

onLoadProgress

Function

Inherited from BaseSound:

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

Default: null

onTrackEnd

Function

Event Handler or Callback for ending of a individual track.

Default: null

playSpeed

SPAudioParam

Speed of playback of the source. Affects both pitch and tempo.

Default: 1.0

releaseGainNode

GainNode final

Inherited from BaseSound:

Release Gain Node

Default: Internal GainNode