The Audio Track Provider of the audio from microphone.

// @input Asset.AudioTrackAsset audioTrack 
// @input int sampleRate = 44100

var control = script.audioTrack.control;
if (control.isOfType("Provider.MicrophoneAudioProvider")) {
control.start();
}

control.sampleRate = script.sampleRate;
var audioFrame = new Float32Array(control.maxFrameSize);

script.createEvent("UpdateEvent").bind(function (eventData) {
var audioFrameShape = control.getAudioFrame(audioFrame);
if (audioFrameShape.x == 0) {
return;
}
// do something with data
})
interface MicrophoneAudioProvider {
    maxFrameSize: number;
    sampleRate: number;
    getAudioFrame(audioFrame: Float32Array): vec3;
    getLoadStatus(): LoadStatus;
    getTypeName(): string;
    isOfType(type: string): boolean;
    isSame(other: ScriptObject): boolean;
    start(): void;
    stop(): void;
}

Hierarchy (view full)

Properties

maxFrameSize: number

The maximum frame size of the audio track asset.

sampleRate: number

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

Methods

  • Exposes User Data

    Writes current frame audio data to the passed in Float32Array and returns its shape. The length of the array can't be more than maxFrameSize.

    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

  • Start processing audio from microphone. Useful to avoid redundant processing.

    Returns void

  • Stop processing audio from microphone.

    Returns void