Octoroom.Agent.Audio.Mixer (octoroom_agents v0.1.0)

Copy Markdown View Source

Mixes several inputs of s16le mono PCM into one stream, a chunk at a time, for a model that has one audio input (Gemini Live).

Inputs arrive in real time but not in step, so the caller pulls a chunk on its own clock (pull/1 every chunk_ms) and each input gives what it has. An input starts being mixed once it has two chunks buffered, which rides out a frame arriving just after the pull instead of mixing in a gap of silence. It stops when it runs dry, and buffers at most max_ms (the oldest is dropped), so a burst doesn't add latency for good.

Summary

Functions

Options: :rate (default 16 kHz), :chunk_ms (20), :max_ms (200).

One chunk of the inputs mixed, or nil when none is being mixed.

Types

t()

@type t() :: %Octoroom.Agent.Audio.Mixer{chunk: term(), inputs: term(), max: term()}

Functions

drop(mixer, input)

new(opts \\ [])

Options: :rate (default 16 kHz), :chunk_ms (20), :max_ms (200).

pull(mixer)

One chunk of the inputs mixed, or nil when none is being mixed.

push(mixer, input, pcm)