mixer

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 26, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package mixer implements an N-input, M-output linear mixing matrix. A plain N-to-1 mixer and a 1-to-M tee are both special cases of the same matrix (an all-ones row, or an all-ones column, respectively), so one engine serves both.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(inputs, outputs int, weights [][]float64, normalize bool) (node.Filter, error)

New builds a ready-to-wire node.Filter: same as NewEngine, but already wrapped with the given number of input ports ("in0".."in{inputs-1}") and output ports ("out0".."out{outputs-1}").

Types

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

Engine mixes its input ports into its output ports using a fixed weight matrix: out[o] = sum_i weights[o][i] * in[i]. Every port shares the same sample rate, format, bit depth, and channel count — reconciling channel layouts across ports is the existing remix filter's job, not this one's.

Ports advance independently and are aligned by each port's own first received frame, not by absolute PTS: sample k of every port is the k-th sample that port has produced, counting from when it started. A port that ends before the others contributes silence for the remainder, so mixing continues until every port has ended and every buffered sample has been consumed.

func NewEngine

func NewEngine(inputs, outputs int, weights [][]float64, normalize bool) (*Engine, error)

NewEngine builds a mixer for exactly the given number of inputs and outputs. weights[o][i] is the gain applied to input i when producing output o.

weights may be nil only for the two shapes with an unambiguous default: outputs == 1 (every input summed with weight 1) or inputs == 1 (every output an identical copy of the input, i.e. a tee). Any other combination requires an explicit matrix. If normalize is true, each output row with an L1 norm above 1 is scaled down to avoid clipping (see pkg/dsp.ClampL1); rows already within bound are left untouched.

func (*Engine) Close

func (e *Engine) Close() error

func (*Engine) EndInput

func (e *Engine) EndInput(port string) error

func (*Engine) Flush

func (e *Engine) Flush() error

func (*Engine) ReceiveFrame

func (e *Engine) ReceiveFrame() (media.Frame, error)

func (*Engine) ReceiveOutput

func (e *Engine) ReceiveOutput() (string, media.Frame, error)

func (*Engine) SendFrame

func (e *Engine) SendFrame(frame *media.Frame) error

func (*Engine) SendInput

func (e *Engine) SendInput(port string, frame *media.Frame) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL