UNPKG

@4players/odin

Version:

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

47 lines (46 loc) 2.66 kB
import { Backend } from '@4players/odin-common'; import { InputSettings } from '../types'; import DeviceParameters = Backend.DeviceParameters; import CreateAudioCaptureParameters = Backend.CreateAudioCaptureParameters; import VadConfig = Backend.VadConfig; import ApmConfig = Backend.ApmConfig; import PlaybackVolume = Backend.PlaybackVolume; export declare class OdinError extends Error { message: string; readonly name = "OdinError"; constructor(message?: string); } /** * Updates the voice activity sensitivity range based on the input level. * * @param {number} lvl - The input level that defines the current sensitivity adjustment. It is clamped between 0 and 1 if outside of this range. * @return {Backend.SensitivityRange} An object containing the calculated `releaseThreshold` and `attackThreshold`, both of which are adjusted based on the level. */ export declare function updateVoiceActivity(lvl: number): Backend.SensitivityRange; /** * Updates the volume gate sensitivity range based on the provided active threshold. * * @param {number} goingActive - The desired threshold for activating the volume gate. * @param {number} [offset=10] - The offset value used to calculate the release threshold. Defaults to 10. * @return {Backend.SensitivityRange} An object representing the updated sensitivity range with `attackThreshold` and `releaseThreshold`. */ export declare function updateVolumeGate(goingActive: number, offset?: number): Backend.SensitivityRange; /** * Determines whether the current platform is capable of supporting audio functionality * by checking the availability of `AudioContext` and `Worker`. * * @return {boolean} Returns true if the platform supports audio functionality; otherwise, false. */ export declare function isAudioCapable(): boolean; export declare function generateCaptureParameters(device?: DeviceParameters, settings?: InputSettings): CreateAudioCaptureParameters; export declare function generateVadConfig(settings?: InputSettings): VadConfig; export declare function generateApmConfig(settings?: InputSettings): ApmConfig; /** * Calculates the playback volume by combining an array of volumes. * * @param {PlaybackVolume[]} volumes - An array of volume values. Each value can be a number or the string 'muted'. * A 'muted' value is treated as 0 during calculation. * @return {number} The resulting playback volume after combining all provided volumes. */ export declare function calcPlaybackVolume(volumes: PlaybackVolume[]): PlaybackVolume; export declare function calculateBytesPerSeconds(currentBytes: number, lastBytes: number, ms: number): number;