Skip to main content

Class: AudioInput

A generic event target class designed for strongly-typed event handling. OdinEventTarget extends the functionality of the standard EventTarget to allow interactions with predefined event types and handlers.

Extends​

Constructors​

new AudioInput()​

new AudioInput(settings, capture): AudioInput

Parameters​

• settings: InputSettings

• capture: AudioCapture

Returns​

AudioInput

Overrides​

OdinEventTarget.constructor

Defined in​

ari/lib/api/media/audio-input.d.ts:25

Properties​

kind​

readonly kind: "audio-input" = "audio-input"

Defined in​

ari/lib/api/media/audio-input.d.ts:10


onAudioActivity()?​

optional onAudioActivity: (payload) => void

A callback function invoked when audio activity occurs and voice activity detection (VAD) was set to true.

Parameters​

• payload: AudioActivityPayload

An object containing the AudioMedia.

Returns​

void

Defined in​

ari/lib/api/media/audio-input.d.ts:16


onPowerLevel()?​

optional onPowerLevel: (payload) => void

A callback function invoked when there is an update to the audio power level in rmsDBFS. This function can be used to handle or process audio activity, such as monitoring sound levels or visualizing audio input.

Parameters​

• payload: AudioActivityPayload

An object containing the AudioMedia.

Returns​

void

Defined in​

ari/lib/api/media/audio-input.d.ts:24

Accessors​

capture​

get capture(): AudioCapture

The AudioCapture that is provided by the underling plugin.

Returns​

AudioCapture

The AudioCapture of the underling plugin.

Defined in​

ari/lib/api/media/audio-input.d.ts:31


customType​

get customType(): string

Retrieves the customType that was set when the AudioInput was created. Remote peers can use this to identify the purpose of the stream.

Returns​

string

Defined in​

ari/lib/api/media/audio-input.d.ts:43


isActive​

get isActive(): boolean

Whether the AudioInput is currently active or not. Only works when voice activity detection was enabled.

Returns​

boolean

True if the instance is active, false otherwise.

Defined in​

ari/lib/api/media/audio-input.d.ts:59


powerLevel​

get powerLevel(): number

Retrieves the Root Mean Square (RMS) in decibels relative to full scale (dBFS) for the captured audio activity. This is a measure of the average power level of the audio signal.

Returns​

number

The RMS value expressed in dBFS.

Defined in​

ari/lib/api/media/audio-input.d.ts:74


volume​

get volume(): InputVolume

Retrieves the current volume. Is the Volume 'muted', the associated Device was stopped.

Returns​

InputVolume

The current volume level.

Defined in​

ari/lib/api/media/audio-input.d.ts:38

Methods​

addEventListener()​

addEventListener<OdinEventType>(eventName, handler, options?): void

Type Parameters​

• OdinEventType extends keyof MediaEvents

Parameters​

• eventName: OdinEventType

• handler: MediaEvents[OdinEventType]

• options?: boolean | AddEventListenerOptions

Returns​

void

Inherited from​

OdinEventTarget.addEventListener

Defined in​

ari/lib/utils/odin-event-target.d.ts:26


close()​

close(): void

Closes the AudioInput.

Returns​

void

Defined in​

ari/lib/api/media/audio-input.d.ts:99


dispatchEvent()​

dispatchEvent<T>(event): void

Type Parameters​

• T extends OdinEvent<any>

Parameters​

• event: T

Returns​

void

Inherited from​

OdinEventTarget.dispatchEvent

Defined in​

ari/lib/utils/odin-event-target.d.ts:27


removeEventListener()​

removeEventListener<OdinEventType>(type, callback): void

Type Parameters​

• OdinEventType extends keyof MediaEvents

Parameters​

• type: string | OdinEventType

• callback: EventListenerOrEventListenerObject | MediaEvents[OdinEventType]

Returns​

void

Inherited from​

OdinEventTarget.removeEventListener

Defined in​

ari/lib/utils/odin-event-target.d.ts:28


setDevice()​

setDevice(device): Promise<void>

Sets the device configuration for the capture process.

Parameters​

• device: DeviceParameters

The parameters for the device to be set.

Returns​

Promise<void>

A promise that resolves when the device has been successfully set.

Defined in​

ari/lib/api/media/audio-input.d.ts:66


setInputSettings()​

setInputSettings(settings): Promise<void>

Updates the input settings for the current instance and applies necessary changes.

Parameters​

• settings: InputSettings

The new input settings to be applied. Each key in the settings object determines a specific input property, such as volume, voice activity detection, or audio processing modules.

Returns​

Promise<void>

A promise that resolves once all updates and configurations have been processed.

Defined in​

ari/lib/api/media/audio-input.d.ts:82


setVolume()​

setVolume(value): Promise<void>

Sets the volume of the AudioInput. By setting the value to 'muted', will stop the Capturing of the MediaStream. The volume value should be between 0 and 2 (inclusive). Values outside this range are clamped.

Parameters​

• value: InputVolume

The desired volume level to be set. It must be a valid Volume instance or a value supported by the underlying _capture object.

Returns​

Promise<void>

A Promise that resolves when the volume has been successfully set.

Defined in​

ari/lib/api/media/audio-input.d.ts:52


startLoopback()​

startLoopback(): Promise<void>

Initiates and starts the loopback device. This can be useful to play back the voice after processing vad.

Returns​

Promise<void>

A promise that resolves when the loopback process has successfully started.

Defined in​

ari/lib/api/media/audio-input.d.ts:89


stopLoopback()​

stopLoopback(): Promise<void>

Stops the loopback operation.

Returns​

Promise<void>

A promise that resolves when the loopback operation is successfully stopped.

Defined in​

ari/lib/api/media/audio-input.d.ts:95