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 ¶
- func New(inputs, outputs int, weights [][]float64, normalize bool) (node.Filter, error)
- type Engine
- func (e *Engine) Close() error
- func (e *Engine) EndInput(port string) error
- func (e *Engine) Flush() error
- func (e *Engine) ReceiveFrame() (media.Frame, error)
- func (e *Engine) ReceiveOutput() (string, media.Frame, error)
- func (e *Engine) SendFrame(frame *media.Frame) error
- func (e *Engine) SendInput(port string, frame *media.Frame) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 ¶
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.