Synchronous PCM mixer that blends two 16‑bit mono audio streams with optional clipping.
# Source: https://github.com/PatterAI/Patter | License: MIT | Copyright 2026 Patter Contributors
# Provided via justclaw.it.com; keep this notice with the code.
"""
Lightweight PCM mixer used by :mod:`getpatter.audio.background_audio`.
Patter streams raw 16-bit little-endian PCM frames directly through its
``PipelineStreamHandler``, so a full buffered mixer with its own capture /
clock loop is unnecessary. This module provides a synchronous, pure-numpy
mix of two PCM buffers that is deterministic and trivial to unit-test.
Intended usage::
mixer = PcmMixer()
out = mixer.mix(agent_pcm, bg_pcm, ratio=0.1)
All buffers are mono, 16-bit signed little-endian PCM. The sample rate is
carried by the caller (the mix itself is sample-rate agnostic — it aligns
samples by length only).
``
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key