Interface AudioTrack
access this type via: io.audio.AudioTrack (provides, requires or uses)
This interface wraps audio samples for playback on an audio output instance. All audio samples must be encoded in signed 32-bit integers. An AudioTrack is a use-once entity for playback; samples are discarded immediately after they have been played.
Functions
AudioTrack(int4 samples[], optional bool loop, int loopToFrame, int loopAtFrame)
void setVolume(int1 volume)
bool append(int4 samples[], optional bool loop, int loopToFrame, int loopAtFrame)
void finish()
int getFrameIndex()
void setFrameIndex(int index)
AudioTrack(int4 samples[], optional bool loop, int loopToFrame, int loopAtFrame)
Instantiate a new audio track, with initial samples. If loop is set to true, the sample set will be looped in playback until either append() or finish() is called. If loop is set to true, the parameters loopToFrame and loopAtFrame can optionally be used to specify the looped region of the sample set using frame indices, otherwise the sample will be looped after its last frame back to its first frame.
void setVolume(int1 volume)
Set the volume of this track, in the range 0-100. Values higher than 100 are clipped to 100.
bool append(int4 samples[], optional bool loop, int loopToFrame, int loopAtFrame)
Append a further set of audio samples, to be played immediately after the prior set of samples has completed playback. If loop is set to true, this sample set is looped until append() or finish() is called. Note that, once this newly-appended sample begins playing, any prior sample is removed and cleaned up.
returns: True if the audio track is still playing (and will therefore play these samples), or false if the audio track is not currently playing.
void finish()
If the most recently added set of samples has been set to loop, this will end playback after the end of the current loop of that sample set. The loop status of the sample is still set to 'true' after this operation, such that the audio will loop again if/when it is played again via an audio device.
int getFrameIndex()
Get the current playback frame index (how many frames in total have been played).
void setFrameIndex(int index)
Set the current playback frame index, relative to the start of the most recently added sample set.