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
inputRateuintThe sample rate of the input audio data (in Hz).
outputRateuintThe desired sample rate of the output audio data (in Hz).
numChannelsuintThe number of audio channels (default 1).
qualitySoxQualityRecipeThe quality setting for the resampler (default Medium).
Properties
InputRate
Gets the input sample rate.
public uint InputRate { get; }
Property Value
NumChannels
Gets the number of channels.
public uint NumChannels { get; }
Property Value
OutputRate
Gets the output sample rate.
public uint OutputRate { get; }
Property Value
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
frameAudioFrameThe 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
databyte[]The raw audio data in int16le format.
Returns
- List<AudioFrame>
A list of resampled audio frames.