Object containing all track-specific WebAudioAPI functionality.
Members
-
name
-
Name of the Track.
Methods
-
async applyEffect(effectName, effectType)
-
Applies a new track effect at the specified time.
Calling this function affects the sequential ordering in which effects will be processed, with each new call appending the corresponding effect to the end of the processing sequence.
If an effect with the specified
effectNamehas already been applied , then calling this function will simply re-order the effect to move it to the very end of the effect processing sequence, without changing its parameter values.Parameters:
Name Type Description effectNamestring User-defined name to associate with the track effect
effectTypenumber Track EffectType to apply
- See:
-
clearTrack()
-
Cancels any current or scheduled audio from playing on the current track.
-
async connectToAudioInputDevice(audioDeviceID)
-
Connects the current track to the specified audio input device so that any incoming audio will be automatically played in real-time.
Parameters:
Name Type Description audioDeviceIDstring ID of the audio input device to which to connect the current track
-
connectToMidiDevice(midiInput)
-
Connects the current track to the specified MIDI device so that any incoming events will be automatically played in real-time.
Parameters:
Name Type Description midiInputMIDIInput MIDI device to which to connect the current track
- See:
-
deleteTrack()
-
Deletes the current track and cancels any scheduled audio from playing or from starting to play in the future.
-
disconnectFromAudioInputDevice()
-
Disconnects the current track from the specified audio input device so that no further audio events will be received.
-
disconnectFromMidiDevice()
-
Disconnects the current track from the specified MIDI device so that no further MIDI events will be received.
-
getAnalysisBuffer(analysisType) → {Uint8Array}
-
Returns a buffer containing the realtime frequency content of the audio being produced by the current track.
Parameters:
Name Type Description analysisTypenumber Audio AnalysisType for which the buffer will be used
Returns:
Uint8Array -Array containing time or frequency content of the track's current audio output
-
getCurrentEffectParameters(effectName) → {Object}
-
Returns the current parameter settings for the specified track effect.
Parameters:
Name Type Description effectNamestring Name of the track effect for which to retrieve current settings
Returns:
Object -Effect-specific parameter values with keys as returned by getAvailableEffectParameters()
-
playChord(}, startTime, modifications, areDrumNotes) → {number}
-
Schedules a chord of notes to be played on the current track.
Note that the
chordparameter should be an array of[note, duration, mods]tuples, where thenoteparameter should correspond to a valid MIDI note number, thedurationparameter should correspond to the beat scaling factor associated with one of the note durations from getAvailableNoteDurations(), andmodsmay either be a single modification to the chord, a list of modifications, or omitted completely.The
modificationsparameter may either be a single ModificationDetails structure or a list of such structures.Parameters:
Name Type Description }Array.<Array> chord - Array of
[note, duration, mods]corresponding to the chord to be playedstartTimenumber Global API time at which to start playing the chord
modificationsArray.<ModificationDetails> One or more Modifications to apply to the chord
areDrumNotesboolean Whether this chord contains only drum notes (i.e., not affected by key or duration)
Returns:
number -Duration (in seconds) of the chord being played
-
async playClip(audioClip, startTime, opt duration) → {Promise.<number>}
-
Schedules an audio clip to be played on the current track for some duration of time.
If the
durationparameter is not specified or is set tonull, the audio clip will play to completion.Parameters:
Name Type Attributes Description audioClipArrayBuffer | AudioBuffer | Blob | MidiClip | AudioClip Object containing audio data to play
startTimenumber Global API time at which to start playing the clip
durationnumber <optional>
Number of seconds for which to continue playing the clip
Returns:
Promise.<number> -Duration (in seconds) of the clip being played
- See:
-
async playFile(fileURL, startTime, opt duration) → {Promise.<number>}
-
Schedules an audio file to be played on the current track for some duration of time.
If the
durationparameter is not specified or is set tonull, the audio file will play to completion.Parameters:
Name Type Attributes Description fileURLstring URL location pointing to an audio file
startTimenumber Global API time at which to start playing the file
durationnumber <optional>
Number of seconds for which to continue playing the file
Returns:
Promise.<number> -Duration (in seconds) of the file being played
-
playNote(note, startTime, duration, modifications, isDrumNote, opt fromChord) → {number}
-
Schedules a note to be played on the current track for some duration of time.
Note that the
durationparameter should correspond to the beat scaling factor associated with one of the note durations from getAvailableNoteDurations(). Likewise, thenoteparameter should correspond to a valid MIDI note number.The
modificationsparameter may either be a single ModificationDetails structure or a list of such structures.Parameters:
Name Type Attributes Default Description notenumber MIDI Note number to be played
startTimenumber Global API time at which to start playing the note
durationnumber Duration for which to continue playing the note
modificationsArray.<ModificationDetails> One or more Modifications to apply to the note
isDrumNoteboolean Whether this note is a drum note (i.e., not affected by key or duration)
fromChordboolean <optional>
false Whether this note is being played from the playChord() function
Returns:
number -Duration (in seconds) of the note being played
-
playNoteAsync(note, velocity) → {Object}
-
Immediately begins playing a note on the current track. Playback continues until the note is explicitly stopped using the stopNoteAsync() function.
Note that the
noteparameter should correspond to a valid MIDI note number.Parameters:
Name Type Description notenumber MIDI Note number to be played
velocitynumber Intensity of the note to play between [0.0, 1.0]
Returns:
Object -Reference to the newly scheduled note
-
playSequence(sequence, startTime, modifications, areDrumNotes) → {number}
-
Schedules a musical sequence to be played on the current track.
Note that the
sequenceparameter should be an array containing either chords (as defined in the playChord() function) or[note, duration, mods]tuples, where thenoteparameter should correspond to a valid MIDI note number, thedurationparameter should correspond to the beat scaling factor associated with one of the note durations from getAvailableNoteDurations(), andmodsmay either be a single modification that affects the whole sequence, a list of modifications, or omitted completely.The
modificationsparameter may either be a single ModificationDetails structure or a list of such structures.Parameters:
Name Type Description sequenceArray.<(Array|Array.<Array>)> Array of
[note, duration, mods]and/or chords corresponding to the sequence to be playedstartTimenumber Global API time at which to start playing the sequence
modificationsArray.<ModificationDetails> One or more Modifications to apply to the sequence
areDrumNotesboolean Whether this sequence contains only drum notes (i.e., not affected by key or duration)
Returns:
number -Duration (in seconds) of the sequence being played
-
recordAudioClip(startTime, opt duration) → {AudioClip}
-
Schedules an audio clip to be recorded on the current track for some duration of time.
If the
durationparameter is not specified or is set tonull, the audio clip will continue to record until manually stopped by the finalize() function on the returned AudioClip object.Note that the recorded audio clip will not include any effects that might exist on the track. This is so that recording and then immediately playing back on the same track will not cause any underlying effects to be doubled.
Parameters:
Name Type Attributes Description startTimenumber Global API time at which to start recording the audio clip
durationnumber <optional>
Number of seconds for which to continue recording the audio clip
- See:
-
recordMidiClip(startTime, opt duration) → {MidiClip}
-
Schedules a MIDI clip to be recorded on the current track for some duration of time.
If the
durationparameter is not specified or is set tonull, the MIDI clip will continue to record until manually stopped by the finalize() function on the returned MidiClip object.Note that the recorded MIDI clip will not include any effects that might exist on the track. This is so that recording and then immediately playing back on the same track will not cause any underlying effects to be doubled.
Parameters:
Name Type Attributes Description startTimenumber Global API time at which to start recording the MIDI clip
durationnumber <optional>
Number of seconds for which to continue recording the MIDI clip
- See:
-
recordOutput(startTime, opt duration) → {AudioRecording}
-
Schedules an audio recording to be executed on the cumulative output of the current track for some duration of time.
If the
durationparameter is not specified or is set tonull, the audio recording will continue until manually stopped by the finalize() function on the returned AudioRecording object.Note that the recorded audio will include all effects that exist on the track.
Parameters:
Name Type Attributes Description startTimenumber Global API time at which to start recording the audio output
durationnumber <optional>
Number of seconds for which to continue recording the audio output
- See:
-
async removeEffect(effectName) → {Effect|null}
-
Removes the specified track effect from being applied.
Parameters:
Name Type Description effectNamestring Name of the track effect to be removed
-
removeInstrument()
-
Removes the instrument used to play back audio on the current track.
-
stopNoteAsync(noteObject)
-
Immediately stop playing a note on the current track. The note to be stopped must be a reference to an actively playing note that was previously returned from the playNoteAsync() function.
Parameters:
Name Type Description noteObjectObject Reference to an active note that was started using playNoteAsync()
-
async updateEffect(effectName, effectOptions, updateTime, timeConstant)
-
Updates the parameters of a track effect at the specified time.
Calling this function will not affect the sequential processing order of any applied effects.
Note that the
updateTimeparameter can be omitted to immediately cause the requested changes to take effect.Parameters:
Name Type Description effectNamestring Name of the track effect to be updated
effectOptionsObject Effect-specific options as returned by getAvailableEffectParameters()
updateTimenumber Global API time at which to update the effect
timeConstantnumber Time constant defining an exponential approach to the target
-
updateInstrument(instrumentData)
-
Updates the instrument used to play back audio on the current track.
Parameters:
Name Type Description instrumentDataInstrument Instrument object to use when generating audio on the current track