Lens Scripting API

    Class MicrophoneAudioProvider

    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
    })

    Hierarchy (View Summary, Expand)

    Index

    Constructors

    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

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

      Returns void

    • Stop processing audio from microphone.

      Returns void

    MMNEPVFCICPMFPCPTTAAATR