Skip to main content

Module output

Module output 

Source
Expand description

cpal audio output: device enumeration, stream creation, synthesis.

The audio callback runs on a dedicated real-time thread. It receives AudioEvents over an mpsc channel and synthesises every active MathAudioSource sample by sample.

What a source is now: an oscillator whose pitch comes from its MathFunction through a logarithmic range, detuned, with a pitch envelope that can fall from a multiple of the note down to it (the shape of every drum and impact there is), an optional second partial, a share of white noise, up to two biquad filters or a comb, soft drive, and the fade-in and fade-out the source asked for. Before this the thread ignored all of it: every sound in the world had the same fixed envelope and no filter, which is why a sword and a menu blip were the same click at different pitches.

What the bus does now: sound effects and music are summed separately, music ducks under effects, a share of everything goes to one reverb, and a soft limiter keeps the sum from clipping.

Structsยง

AudioOutput
Opaque audio output handle. Keeps the cpal stream alive.