Description

The Audio Track Provider of the audio from microphone.

Example

// @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): vec3;
    getLoadStatus(): LoadStatus;
    getTypeName(): string;
    isOfType(type): boolean;
    isSame(other): boolean;
    start(): void;
    stop(): void;
}

Hierarchy (view full)

Properties

maxFrameSize: number

Description

The maximum frame size of the audio track asset.

sampleRate: number

Description

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

Methods

  • Parameters

    • audioFrame: Float32Array

    Returns vec3

    Exposes User Data

    Description

    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

    • type: string

    Returns boolean

    Description

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

  • Parameters

    Returns boolean

    Description

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

  • Returns void

    Description

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

  • Returns void

    Description

    Stop processing audio from microphone.

Generated using TypeDoc