import { Buffer } from 'buffer'; import type { AUDIO_FORMATS, AUDIO_SOURCES, CHANNEL_CONFIGS, ErrorListener } from './constants.js'; type ChunkListener = (chunk: Buffer, chunkId: number) => void; /** * Configures audio system (input & output devices). * * Currently, it does nothing on Android; on iOS it re-configures audio session * in the best way for audio playback and recording. * @return {Promise<>} */ export declare function configAudioSystem(): Promise; export declare class InputAudioStream { readonly audioSource: AUDIO_SOURCES; readonly sampleRate: number; readonly channelConfig: CHANNEL_CONFIGS; readonly audioFormat: AUDIO_FORMATS; readonly samplingSize: number; readonly stopInBackground: boolean; private _appStateSub?; private _active; private _muted; private sem; private streamId; /** * `true` when this stream is active; `false` otherwise. Note, a muted stream * is still "active" - it holds native resources, and keeps listening the mic, * it just does not send captured data to JS layer, silently discarding them. * At the same time, a started stream, when it is automatically stopped in * background by "stopinBackground" option, is considered non-active, as it * releases native resources and stops listening the mic, and re-inits on * native side when the app returns to the foreground. */ get active(): boolean; get muted(): boolean; /** * Creates a new InputAudioStream. * @param audioSource Stream source. * @param sampleRate Sample rate [Hz]. 44100 Hz is recommended as it is * currently the only rate that is guaranteed to work on all Android devices. * @param channelConfig MONO or STEREO. * @param audioFormat Audio format. * @param samplingSize Sampling (data chunk) size, expressed as a number of * samples per channel in the chunk. * @param {boolean} [stopInBackground=true] If set `true` (default) the stream * will automatically stop when the app leaves foreground, and resume when * the app returns to the foreground. */ constructor(audioSource: AUDIO_SOURCES, sampleRate: number, channelConfig: CHANNEL_CONFIGS, audioFormat: AUDIO_FORMATS, samplingSize: number, stopInBackground?: boolean); /** * Adds a new chunk listener. * @param listener */ addChunkListener(listener: ChunkListener): void; addErrorListener(listener: ErrorListener): void; private _handleAppStateChange; private _configAppStateHandling; /** * Internal. Stops the audio input, if active, but keeps its listeners. */ private _stop; stop(): Promise; destroy(): Promise; mute(): Promise; removeChunkListener(listener: ChunkListener): void; removeErrorListener(listener: ErrorListener): void; /** * Attempts to start the input audio stream. In case the stream is already * active, it just reports the active state. If the stream is pending to start * it waits and returns the result, without doing a new attempt in case of * failure. * @return Resolves "true" if the stream is active upon the call exit; * otherwise resolves "false". */ start(): Promise; unmute(): Promise; } export {}; //# sourceMappingURL=InputAudioStream.d.ts.map