Module mixer

Source
Expand description

Audio mixer: sums every audible audio clip at timeline time t into interleaved stereo f32. Used by playback (real-time, block by block) and export (offline to WAV). Handles speed/reverse (linear resampling), freeze (silence), volume/pan/fades (gains lerped across each block), transitions (gain crossfades with virtual clip extension — on video tracks too, so a transition between Sequence clips crossfades their audio with the picture) and Sequence clips on video tracks (their timeline mixed recursively, depth ≤ 8).

Routing: when the project has buses, every top-level clip’s contribution lands in Project::bus_of(track, clip) instead of straight in the output, then BusGraph flushes the buses leaves-first (filters → gain/pan/mono → sum into the output bus) with Main summing into out. Bus mute/solo mirrors track mute/solo — any solo among the buses silences the un-soloed ones, except Main, which is the master everything sums through. Projects with no buses (the default) skip all of that and mix straight into out.

Structs§

Mixer
Scratch 🔒
Buffer pool, two per recursion depth: [2d] = source-read/resample buffer, [2d+1] = sequence sub-mix buffer. Grown once per size increase, never freed.

Enums§

Dest 🔒
Where a clip’s samples go: a plain buffer (no buses / a nested sequence sub-mix) or the bus graph.

Constants§

MAX_DEPTH 🔒

Functions§

active_in 🔒
Mute/solo resolution over an arbitrary track list (same rule as Project::active, which only knows the top-level tracks).
clip_transitions 🔒
The (still valid) transitions whose window this clip plays in (windows clamped to the cut’s clips, so an over-long transition cannot drag a clip past its neighbours — same rule as the compositor).
gains 🔒
(left, right) gains at absolute time tt: volume × fade in/out × transition crossfade, panned. Clip-local time is clamped into the clip for volume/pan/fades so virtual extensions hold the edge value.
mix_audio_clip 🔒
One audio clip: read ceil(n*speed)+1 source frames at the clip’s source time, linearly resample into out (n frames) and add with per-channel gains lerped from the block start to the block end.
mix_seq_clip 🔒
One Sequence clip on a video track: recursively mix its sequence’s tracks at source rate into a scratch buffer, then treat that buffer exactly like clip source audio (resample + gains). Nested tracks keep their own mute/solo but not their own buses — the whole sub-mix goes to the bus of the Sequence clip that hosts it.
mix_tracks 🔒
Accumulate (no zeroing, no clamping) the audio of tracks over [t, t + dest.frames() frames).
play_range 🔒
The clip’s audible timeline range: its own extent, virtually extended into transition windows.
read_block 🔒
Fill buf from src starting at source time s0; time before 0 is silence.
resample_add 🔒
Linearly resample buf (m source frames read at the clip’s source time for t0) into out (n frames) and add with gains lerped across the block. ponytail: gains (volume keys, fades, transition ease) are sampled at the block ends and lerped — exact for linear ramps, ≤ one block of shape error otherwise; split at kinks if it matters. Both callers use 1024-frame blocks (≈21 ms: playback::BLOCK and export::MIX_BLOCK), so playback and export shape a fade identically.

Type Aliases§

Ext 🔒
Transition windows touching a clip: (cut time, clamped half-window, transition, clip is the right side). At most one per clip edge.