Mojentic.Realtime.Codec (Mojentic v1.5.0)

Copy Markdown View Source

Audio codec helpers for the realtime subsystem.

Realtime sends and receives audio as base64-encoded PCM16 (little-endian 16-bit signed mono, 24 kHz by default). These helpers convert between the wire format and Elixir binaries of raw PCM bytes so consumer code never touches base64.

Summary

Functions

Decode a base64 string into a binary of little-endian 16-bit PCM samples.

Encode raw PCM16 bytes (or a list of int16 samples) into a base64 string.

Functions

decode_base64_pcm16(b64)

Decode a base64 string into a binary of little-endian 16-bit PCM samples.

Returns the raw binary; pattern-match <<sample::little-16-signed, rest::binary>> to consume samples or use :binary.bin_to_list/2 for arrays.

encode_base64_pcm16(samples)

Encode raw PCM16 bytes (or a list of int16 samples) into a base64 string.