Class OpusEncoder

A class that encodes PCM input signal from 16-bit signed integer or floating point input.

Constructors

Properties

Methods

Constructors

  • Create an opus encoder.

    Parameters

    • sampleRate: number

      Sampling rate of input signal (Hz) This must be one of 8000, 12000, 16000, 24000, or 48000.

    • channels: number

      Number of channels (1 or 2) in input signal.

    • application: OpusApplication

      Coding mode.

    Returns OpusEncoder

Properties

bitrate: number

The bitrate of the encode.

Methods

  • Encodes an Opus frame from 16-bit signed integer input.

    Parameters

    • pcm: Buffer

      PCM input signal buffer. Length is frame_size * channels * 2.

    • frameSize: number

      Number of samples per channel in the input signal. This must be an Opus frame size for the encoder's sampling rate.

    Returns Buffer

    The encoded Opus packet of the frame.

  • Encodes an Opus frame from floating point input.

    Parameters

    • pcm: Buffer

      PCM input signal buffer. Length is frame_size * channels * 2.

    • frameSize: number

      Number of samples per channel in the input signal. This must be an Opus frame size for the encoder's sampling rate.

    Returns Buffer

    The encoded Opus packet of the frame.