uses AudioFormat
/* {"description" : "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."} */
interface AudioTrack {
/* {"@description" : "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."} */
AudioTrack(store AudioFormat format, int4 samples[], opt bool loop, opt int loopToFrame, opt int loopAtFrame)
/* {"@description" : "Set the volume of this track, in the range 0-100. Values higher than 100 are clipped to 100."} */
void setVolume(int1 volume)
/* {"@description" : "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.",
"@return" : "True if the audio track is still playing (and will therefore play these samples), or false if the audio track is not currently playing."} */
bool append(int4 samples[], opt bool loop, opt int loopToFrame, opt int loopAtFrame)
/* {"@description" : "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."} */
void finish()
/* {"@description" : "Get the playback frame index of the currently-playing sample set (how many frames have been played)."} */
int getFrameIndex()
/* {"@description" : "Set the playback frame index, relative to the start of the currently playing sample set."} */
void setFrameIndex(int index)
/* {"@description" : "Get the current frame index as a cumulative value relative to the start of the first sample set played. There is not 'set' version of this function because prior sample sets are removed and cleaned up; a track cannot therefore seek to points that are earlier than the current sample set."} */
int getTotalFrameIndex()
}To propose a new revision to this entity, use dana source put -ut your/new/version.dn -n io.audio.AudioTrack -m "reason for update" -u yourUsername
Version 4 (this version) by barry
Notes for this version: Adds a missing format parameter, adds a getTotalFrameIndex function to report the cumulative number of frames played.