Table of Contents

Class AudioResampler

Namespace
LiveKit.Rtc
Assembly
LivekitRtc.dll

A class for resampling audio data from one sample rate to another. Uses the Sox resampling library under the hood.

public class AudioResampler : IDisposable
Inheritance
AudioResampler
Implements
Inherited Members

Constructors

AudioResampler(uint, uint, uint, SoxQualityRecipe)

Initializes a new AudioResampler instance.

public AudioResampler(uint inputRate, uint outputRate, uint numChannels = 1, SoxQualityRecipe quality = SoxQualityRecipe.SoxrQualityMedium)

Parameters

inputRate uint

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

outputRate uint

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

numChannels uint

The number of audio channels (default 1).

quality SoxQualityRecipe

The quality setting for the resampler (default Medium).

Properties

InputRate

Gets the input sample rate.

public uint InputRate { get; }

Property Value

uint

NumChannels

Gets the number of channels.

public uint NumChannels { get; }

Property Value

uint

OutputRate

Gets the output sample rate.

public uint OutputRate { get; }

Property Value

uint

Methods

Dispose()

Releases the native resampler. Call Flush() first to get the audio it still buffers.

public void Dispose()

Flush()

Flush any remaining audio data through the resampler. Call this when no more input data will be provided.

public List<AudioFrame> Flush()

Returns

List<AudioFrame>

A list of remaining resampled audio frames.

Push(AudioFrame)

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

public List<AudioFrame> Push(AudioFrame frame)

Parameters

frame AudioFrame

The audio frame to resample.

Returns

List<AudioFrame>

A list of resampled audio frames.

Push(byte[])

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

public List<AudioFrame> Push(byte[] data)

Parameters

data byte[]

The raw audio data in int16le format.

Returns

List<AudioFrame>

A list of resampled audio frames.