@livekit/rtc-node
    Preparing search index...

    Class AudioResampler

    AudioResampler provides functionality to resample audio data from an input sample rate to an output sample rate using the Sox resampling library. It supports multiple channels and configurable resampling quality.

    Index

    Constructors

    Accessors

    Methods

    Constructors

    • Initializes a new AudioResampler.

      Parameters

      • inputRate: number

        The sample rate of the input audio data (in Hz).

      • outputRate: number

        The desired sample rate of the output audio data (in Hz).

      • channels: number = 1

        The number of audio channels (e.g., 1 for mono, 2 for stereo). Defaults to 1.

      • quality: AudioResamplerQuality = AudioResamplerQuality.MEDIUM

        The quality setting for the resampler. Defaults to AudioResamplerQuality.MEDIUM.

      Returns AudioResampler

    Accessors

    Methods

    • Flush any remaining audio data through the resampler and retrieve the resampled data.

      Returns AudioFrame[]

      This method should be called when no more input data will be provided to ensure that all internal buffers are processed and all resampled data is output.

    • Push audio data into the resampler and retrieve any available resampled data.

      This method accepts audio data, resamples it according to the configured input and output rates, and returns any resampled data that is available after processing the input.

      Parameters

      Returns AudioFrame[]

      A list of AudioFrame objects containing the resampled audio data. The list may be empty if no output data is available yet.