Provider for file based Audio Tracks.

// @input Asset.AudioTrackAsset audioTrack 

var control = script.audioTrack.control;

if (control.isOfType("Provider.FileAudioTrackProvider")) {
control.loops = -1; //set to loop forever
}
var audioFrameArray = new Float32Array(control.maxFrameSize)

script.script.createEvent("UpdateEvent").bind(function(eventData){
var frameShape = control.getAudioFrame(audioFrameArray);
print(frameShape.x + " samples were read on this update")
print(control.position + " current audio track position");
});
interface FileAudioTrackProvider {
    duration: number;
    loops: number;
    maxFrameSize: number;
    position: number;
    sampleRate: number;
    getAudioBuffer(audioBuffer: Float32Array, readSize: number): vec3;
    getAudioFrame(audioFrame: Float32Array): vec3;
    getLoadStatus(): LoadStatus;
    getTypeName(): string;
    isOfType(type: string): boolean;
    isSame(other: ScriptObject): boolean;
}

Hierarchy (view full)

Properties

duration: number

The duration of the AudioTrackAsset in seconds.

loops: number

Loop count, if -1 is provided, the audio track will loop forever.

maxFrameSize: number

The maximum frame size of the audio track asset.

position: number

The current position of the AudioTrackAsset in seconds.

sampleRate: number

Sample rate (samples per second) of the audio track asset.

Methods

  • Writes readSize samples into the passed in audioBuffer Float32Array.

    Parameters

    • audioBuffer: Float32Array
    • readSize: number

    Returns vec3

  • Writes current audio frame to the passed in Float32Array and returns the frame shape.

    Parameters

    • audioFrame: Float32Array

    Returns vec3

  • Returns true if the object matches or derives from the passed in type.

    Parameters

    • type: string

    Returns boolean

  • Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

    Parameters

    Returns boolean