Module mixer

Module mixer 

Source
Expand description

The audio mixer: sums the board’s audio sources (socket 9) into one stereo stream (mixer.py).

A source answers take_samples(mclk) with the stereo samples it produced since the last call, one per 1/rate_hz second (zeros when silent, so the mixer keeps its place). The mixer keeps one queue per source, turns each source’s stream into the output rate, applies gain (unless the source applies its own: applies_gain), sums sample for sample and clips to 16 bits. It emits only as many samples as every source has produced, so the sources need not agree on how many each call returns.

A source at another rate is held (zero-order) up to the output rate: no filter, no interpolation. The reference for a source is its own stream at its own rate; this is a host-side convenience (docs/psg.md says the same of the PSG).

Differences forced by Rust: the sources are handed to take (the reference’s mixer holds the board’s list itself); the arithmetic is the reference’s, in f64, in the same order (the sources in list order, left * gain added to a sum that starts at 0.0, round to even, then the clip).

Structs§

Lane
One source’s samples at the output rate, waiting for the others.
Mixer

Constants§

OUTPUT_HZ