MicrophoneRecorder class

Records audio from the device microphone to an audio asset that can be analyzed, played back or exported as an output asset of the module run.

Use InputManager.createMicrophoneRecorder() to create an instance of this class.

Signature:

export declare class MicrophoneRecorder extends ExternalObject 

Extends: ExternalObject

Methods

MethodModifiersDescription
isAvailable()Checks if the module is allowed to record microphone audio.
pause()Pauses the recording.
resume()Resumes a paused recording.
setRecordingVolume(volume)Set the volume of the recording audio input in real time.
startRecording()Starts recording audio from the microphone.
stopRecording(delay)Finishes recording and returns the created audio asset.

MicrophoneRecorder.isAvailable() method

Checks if the module is allowed to record microphone audio.

Signature:

isAvailable(): Promise<boolean>;

Returns:

Promise<boolean>

A promise that resolves to true if the module is allowed to record the microphone or false if recording is not allowed.

Remarks

You must check this before starting recording if microphone permission is optional for your module.

MicrophoneRecorder.pause() method

Pauses the recording.

Signature:

pause(): void;

Returns:

void

Remarks

Has no effect if recording is already paused.

MicrophoneRecorder.resume() method

Resumes a paused recording.

Signature:

resume(): void;

Returns:

void

Remarks

Has no effect if recording is not paused.

MicrophoneRecorder.setRecordingVolume() method

Set the volume of the recording audio input in real time.

Signature:

setRecordingVolume(volume: number): void;

Parameters

ParameterTypeDescription
volumenumberThe desired audio input volume, with normal values between 0 and 1. Volume defaults to 1 if this isn't called.

Returns:

void

MicrophoneRecorder.startRecording() method

Starts recording audio from the microphone.

Signature:

startRecording(): void;

Returns:

void

MicrophoneRecorder.stopRecording() method

Finishes recording and returns the created audio asset.

Signature:

stopRecording(delay?: number): Promise<AudioAsset>;

Parameters

ParameterTypeDescription
delaynumber(Optional) Stop the recording after the given delay in seconds, the default value is 0 which stops immediately. Use this if you know the cut off time of your recording so the system recording indicator can alert the user when the recording time is near the end. A subsequent call to stopRecording or pause will causes this pending stop to be cancelled and the promise resolution will fail.

Returns:

Promise<AudioAsset>

A promise that resolves when the recording is finished with a reference to the audio asset.

Remarks

Once the audio asset has been returned you can call MicrophoneRecorder.startRecording() on this instance to start a new recording.

This call can take up to half a second to run, avoid blocking the user interface when calling.