Looper Class
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 optionalAudioContext to be used.
-
[sources]
Array/String/AudioBuffer/SPAudioBuffer/File optionalSingle or Array of either URLs or AudioBuffers or File Object of the audio source.
-
[onLoadProgress]
Function optionalCallback when the audio file is being downloaded.
-
[onLoadComplete]
Function optionalCallback when all sources have finished loading.
-
[onAudioStart]
Function optionalCallback when the audio is about to start playing.
-
[onAudioEnd]
Function optionalCallback when the audio has finished playing.
-
[onTrackEnd]
Function optionalCallback when an individual track has finished playing.
Item Index
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.
disconnect
-
[outputIndex]
Disconnects the Sound from the AudioNode Chain.
Parameters:
-
[outputIndex]
Number optionalIndex describing which output of the AudioNode to disconnect.
listParams
-
[paramArray]
List all SPAudioParams this Sound exposes
Parameters:
-
[paramArray]
Array optionalArray of all the SPAudioParams this Sound exposes.
pause
()
Pause the currently playing model at the current position.
play
()
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]
Linearly ramp down the gain of the audio in time (seconds) to 0.
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
ObjectAn Sound Effect of type BaseEffect to be appended to the output of this Sound.
setSources
-
sources
-
[onLoadProgress]
-
[onLoadComplete]
Reinitializes a Looper and sets it's sources.
start
-
when
-
[offset]
-
[duration]
-
[attackDuration]
Start playing after specific time and from a specific offset.
Parameters:
-
when
NumberTime (in seconds) when the sound should start playing.
-
[offset]
Number optionalThe starting position of the playhead in seconds
-
[duration]
Number optionalDuration of the portion (in seconds) to be played
-
[attackDuration]
Number optionalDuration (in seconds) of attack ramp of the envelope.
stop
-
when
Stops the model and resets play head to 0.
Parameters:
-
when
NumberTime offset to stop
Properties
audioContext
AudioContext
Web Audio API's AudioContext. If the context passed to the constructor is an AudioContext, a new one is created here.
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
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
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)
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
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