lanczos-resampler
    Preparing search index...

    Class ChunkedInterleavedResampler

    A resampler that processes audio input in chunks; the channels are interleaved with each other.

    Use it to process audio streams.

    This resampler uses default parameters: N = 16, A = 3.

    ChunkedInterleavedResampler produces slightly different output compared to processing the whole input at once. If this is undesired, consider using WholeResampler.

    Index

    Constructors

    • Creates new instance of resampler with the specified input and output sample rates and the number of channels.

      Parameters

      • inputSampleRate: number

        input sample rate in Hz

      • outputSampleRate: number

        output sample rate in Hz

      • numChannels: number

        number of channels

      Returns ChunkedInterleavedResampler

    Accessors

    • get inputSampleRate(): number

      Get input sample rate in Hz.

      Returns number

    • get numChannels(): number

      Get the number of channels.

      Returns number

    • get outputSampleRate(): number

      Get/set output sample rate in Hz.

      After changing the sample rate you should consider updating buffer size to ChunkedInterleavedResampler.maxNumOutputFrames.

      Returns number

    • set outputSampleRate(value: number): void

      Parameters

      • value: number

        new sample rate in Hz

      Returns void

    Methods

    • Get maximum output chunk length given the input chunk length.

      Returns the same value as numOutputFrames plus one. This additional sample is used to compensate for unevenly divisible sample rates.

      You should consider updating buffer size every time you change output sample rate via ChunkedInterleavedResampler.outputSampleRate.

      Parameters

      • numInputFrames: number

      Returns number

    • Resamples input signal chunk from the source to the target sample rate and appends the resulting signal to the output.

      Returns the number of processed input samples and the number of produced output samples. The output is clamped to [-1; 1].

      For each ChunkedInterleavedResampler.inputSampleRate input samples this method produces exactly ChunkedInterleavedResampler.outputSampleRate output samples even if it is called multiple times with a smaller amount of input samples; the only exception is when the output sample rate was changed in the process.

      Returns 0 when either the number of input or output frames is less than max(2, A-1), adjusted in accordance with sample rate ratio.

      The output depends on the chunk size, hence resampling the same audio track all at once and in chunks will produce slightly different results. This a consequence of the fact that Lanczos kernel isn't an interpolation function, but a filter. To minimize such discrepancies chunk size should be much larger than 2⋅A + 1.

      Parameters

      • chunk: Float32Array
      • output: Float32Array

      Returns ResampleOutcome

    • Resets internal state.

      Erases any information about the previous chunk.

      Use this method when you want to reuse resampler for another audio stream.

      Returns void