UNPKG

@4players/odin

Version:

A cross-platform SDK enabling developers to integrate real-time VoIP chat technology into their projects

101 lines (100 loc) 4.37 kB
import { Backend } from '@4players/odin-common'; import { OdinEventTarget } from '../../utils/odin-event-target'; import { AudioActivityPayload, MediaEvents } from '../room/types'; import { InputSettings } from '../../types'; import AudioCapture = Backend.AudioCapture; import CaptureVolume = Backend.CaptureVolume; import DeviceParameters = Backend.DeviceParameters; export declare class AudioInput extends OdinEventTarget<MediaEvents> { #private; readonly kind = "audio-input"; /** * A callback function invoked when audio activity occurs and voice activity detection (VAD) was set to true. * * @param {AudioActivityPayload} payload - An object containing the AudioMedia. */ onAudioActivity?: (payload: AudioActivityPayload) => 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. * * @param {AudioActivityPayload} payload - An object containing the AudioMedia. */ onPowerLevel?: (payload: AudioActivityPayload) => void; constructor(settings: InputSettings, capture: AudioCapture); /** * The AudioCapture that is provided by the underling plugin. * * @return {AudioCapture} The AudioCapture of the underling plugin. */ get capture(): AudioCapture; /** * Retrieves the current volume. Is the Volume 'muted', the associated Device * was stopped. * * @return {CaptureVolume} The current volume level. */ get volume(): CaptureVolume; /** * Retrieves the customType that was set when the AudioInput was created. * Remote peers can use this to identify the purpose of the stream. */ get customType(): string | undefined; /** * 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. * * @param {CaptureVolume} value - The desired volume level to be set. It must be a valid `Volume` instance or a value supported by the underlying `_capture` object. * @return {Promise<void>} A Promise that resolves when the volume has been successfully set. */ setVolume(value: CaptureVolume): Promise<void>; /** * Whether the AudioInput is currently active or not. * Only works when voice activity detection was enabled. * * @return {boolean} True if the instance is active, false otherwise. */ get isActive(): boolean; /** * Sets the device configuration for the capture process. * * @param {DeviceParameters} device - The parameters for the device to be set. * @return {Promise<void>} A promise that resolves when the device has been successfully set. */ setDevice(device: DeviceParameters): Promise<void>; /** * 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. * * @return {number} The RMS value expressed in dBFS. */ get powerLevel(): number; /** * Updates the input settings for the current instance and applies necessary changes. * * @param {InputSettings} settings - 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. * @return {Promise<void>} A promise that resolves once all updates and configurations have been processed. */ setInputSettings(settings: InputSettings): Promise<void>; /** * Initiates and starts the loopback device. This can be useful to play back * the voice after processing vad. * * @return {Promise<void>} A promise that resolves when the loopback process has successfully started. */ startLoopback(): Promise<void>; /** * Stops the loopback operation. * * @return {Promise<void>} A promise that resolves when the loopback operation is successfully stopped. */ stopLoopback(): Promise<void>; /** * Closes the AudioInput. */ close(): void; }