tiny-server-essentials
Version:
A good utility toolkit to unify Express v5 and Socket.IO v4 into a seamless development experience with modular helpers, server wrappers, and WebSocket tools.
49 lines • 1.59 kB
text/typescript
export default VolumeMeter;
/**
* VolumeMeter provides an interface to connect to a MediaStream (e.g., microphone or screen capture)
* and calculate the real-time volume level using a custom AudioWorkletProcessor.
*
* It supports:
* - Volume measurement via a separate AudioWorklet processor ('volume-processor')
* - Optional playback of the audio (hearVoice)
* - Dynamic module path configuration for the processor script
* - Stream cleanup and graceful disconnection of audio nodes
*
* Use this class to get the volume level of an audio stream for purposes like visual metering
* or silence detection.
*
* @class
* @beta
*/
declare class VolumeMeter {
/** @type {AudioContext} */
context: AudioContext;
/** @type {number} */
volume: number;
/**
* @param {string} newPath New module file path
*/
setModulePath(newPath: string): void;
/**
* @param {MediaStream} stream
* @param {boolean} [hearVoice=true]
* @returns {Promise<void>}
*/
connectToSource(stream: MediaStream, hearVoice?: boolean): Promise<void>;
stream: MediaStream | undefined;
source: MediaStreamAudioSourceNode | undefined;
gainNode: GainNode | undefined;
volumeNode: AudioWorkletNode | undefined;
/**
* @param {number|string} value
* @returns {void}
*/
setVolume(value: number | string): void;
/**
* @returns {Promise<boolean>}
* @throws {Error} If any part of the disconnection or stopping fails
*/
stop(): Promise<boolean>;
#private;
}
//# sourceMappingURL=VolumeMeter.d.mts.map