The common, metadata-carrying PCM representation used by file APIs.
data is always interleaved little-endian IEEE-754 f32. The legacy helper
functions in this module continue to operate on bare PCM binaries so raw
Opus packet APIs remain source compatible.
Summary
Functions
Deinterleaves a stereo PCM binary into {left, right} mono binaries.
Number of interleaved frames in a metadata-carrying PCM value.
Builds a PCM binary from a list of float samples.
Interleaves two mono PCM binaries into one stereo PCM binary.
Constructs and validates a metadata-carrying PCM value.
Number of f32 samples in a bare PCM binary.
Decodes a PCM binary into a list of float samples.
Validates a %RustyOpus.PCM{} supplied by a caller or another decoder.
Types
@type t() :: %RustyOpus.PCM{ channels: 1 | 2, data: binary(), sample_rate: pos_integer() }
Functions
@spec deinterleave(binary()) :: {:ok, {binary(), binary()}} | {:error, RustyOpus.Error.t()}
Deinterleaves a stereo PCM binary into {left, right} mono binaries.
@spec frame_count(t()) :: non_neg_integer()
Number of interleaved frames in a metadata-carrying PCM value.
Builds a PCM binary from a list of float samples.
@spec interleave(binary(), binary()) :: {:ok, binary()} | {:error, RustyOpus.Error.t()}
Interleaves two mono PCM binaries into one stereo PCM binary.
@spec new(binary(), pos_integer(), 1 | 2) :: {:ok, t()} | {:error, RustyOpus.Error.t()}
Constructs and validates a metadata-carrying PCM value.
@spec sample_count(binary()) :: non_neg_integer()
Number of f32 samples in a bare PCM binary.
Decodes a PCM binary into a list of float samples.
@spec validate(t()) :: :ok | {:error, RustyOpus.Error.t()}
Validates a %RustyOpus.PCM{} supplied by a caller or another decoder.