Mixer
The mixer is the part of RenderCore that turns four deck signals into a master bus and a cue bus. It is not a separate object: it is the body of RenderCore.renderChunk, executed for every chunk of at most 64 frames (see audio-engine.md for the chunking). This document describes the signal order, every filter and curve with its constants, routing, the limiter and the meters.
Sources:
RenderCore.swift(ChannelStrip,renderChunk,updateFilters,crossfaderGains,render)Primitives.swift(BiquadCoefficients,StereoBiquad,LinearRamp,dbToLinear)Dynamics.swift(LimiterEffect)- Parameter ranges:
Schema.swift - UI:
MixerView.swift,AudioSettingsTab.swift - Tests:
PlaybackTestsandDeckFeatureTestsinEngineAudioTests.swift
Routing
flowchart TD
V["DeckVoice output (per deck, x4)"] --> T["Trim (gain ramp)"]
T --> EQ["EQ: low shelf, mid peak, high shelf (plus low-mid in 4-band mode)"]
EQ --> HP["High-pass (if active)"]
HP --> LP["Low-pass (if active)"]
LP --> RK["Channel effects rack (8 slots)"]
RK --> PFL{"cue switch"}
PFL -->|on| CB["Cue bus sum"]
RK --> FD["Channel fader (volume ramp)"]
FD --> MT["Channel meter (post-fader)"]
MT --> XF["Crossfader gain: side A, side B, or through"]
XF --> SUM["Master sum"]
SUM --> MR["Master effects rack (8 slots)"]
MR --> MV["Master volume"]
MV --> LIM["Limiter (if on)"]
LIM --> MM["Master meters, clip counter"]
MM --> REC["Recording tap"]
MM --> OUTM["Master output pair"]
MM --> BL["Cue blend: cue x (1 - mix) + master x mix, then cue volume"]
CB --> BL
BL --> OUTC["Cue output pair, or right channel in split cue"]
Channel strip
Order of processing for each deck, exactly as in renderChunk:
| Step | Parameter (script address) | Range and default | Implementation |
|---|---|---|---|
| 1. Trim | deck.X.gain |
−24…+12 dB, 0 | LinearRamp on the linear gain, applied with vDSP_vrampmul2 |
| 2. EQ | deck.X.eq.low, eq.mid, eq.high (and eq.lowMid) |
−26…+6 dB, 0 | cascaded StereoBiquad, skipped entirely when every band is at 0 dB |
| 3. High-pass | deck.X.filter.highpass, deck.X.filter |
20…20 000 Hz, 20 (off) | RBJ high-pass biquad, 12 dB/octave |
| 4. Low-pass | deck.X.filter.lowpass, deck.X.filter |
20…20 000 Hz, 20 000 (off) | RBJ low-pass biquad, 12 dB/octave |
| 5. Effects rack | deck.X.fx.<effect>.… |
8 slots | see dsp.md |
| 6. Pre-fader listen | deck.X.cue |
off | adds the signal to the cue bus |
| 7. Fader | deck.X.volume |
−60…0 dB, 0 | LinearRamp, vDSP_vrampmul2 |
| 8. Meter | post-fader peak and RMS | ||
| 9. Crossfader | mixer.crossfader, assign |
per-side gain, ramped across the chunk |
All gains pass through dbToLinear, where −60 dB (silenceFloorDB) and below map to exactly zero. silenceAtFloor checks that a fader at −60 dB gives a peak of 0.
Every parameter change is ramped over at least 4 ms (rampSamples); callers can ask for a longer ramp. Gains are interpolated linearly within each chunk. faderTrimAndMasterGainsAreAccurate checks that fader, trim and master gains add up to the expected level within 0.02 dB.
A channel that is not playing, has no active effect and whose meter has decayed below 1e-5 takes a shortcut: its ramps and filters are still advanced and its rack still sees the (silent) signal, but nothing is summed.
EQ
Coefficients come from the RBJ Audio EQ Cookbook formulas in BiquadCoefficients; filters run in transposed direct form II. Two layouts exist, switched globally by the eqBands mixer parameter (the "four-band EQ" application setting):
| Band | Three-band (default) | Four-band |
|---|---|---|
| Low | low shelf at 200 Hz | low shelf at 100 Hz |
| Low-mid | not present | peaking at 400 Hz, Q 0.9 |
| Mid (labelled Hi-Mid in four-band mode) | peaking at 1000 Hz, Q 0.7 | peaking at 2000 Hz, Q 0.9 |
| High | high shelf at 3000 Hz | high shelf at 8000 Hz |
Shelves use slope 1. Each band ranges from −26 dB to +6 dB. At the bottom of the range the band becomes a kill: eqGain replaces any value at or below −25.9 dB by −80 dB for the shelves, and the peaking bands are set to −40 dB.
Tested by eqBandsAndKill in three-band mode: +6 dB and −12 dB are reached in band within 0.5 to 1 dB, the far bands move by less than 0.3 dB, and a full kill leaves less than −50 dB at 40 Hz (low) and at 12 kHz (high). The four-band layout has no dedicated audio test.
Channel filters and the filter knob
Each strip has one high-pass and one low-pass biquad sharing deck.X.filter.resonance (Q, 0.5…10, default 0.9). They can be set explicitly in hertz, or through the bipolar knob deck.X.filter (−1…+1), which updateFilters maps as follows:
Knob position k |
Effect | Formula |
|---|---|---|
k > 0.02 |
high-pass sweeping up | f = 20 * 500^k Hz: 20 Hz at 0, about 447 Hz at 0.5, 10 kHz at 1 |
-0.02 ≤ k ≤ 0.02 |
off | dead zone |
k < -0.02 |
low-pass sweeping down | f = 20000 * (1/200)^(-k) Hz: 20 kHz at 0, about 1414 Hz at −0.5, 100 Hz at −1 |
The knob and the explicit corner combine by taking the more restrictive value (max for the high-pass, min for the low-pass). A filter is active only when its corner is above 20.5 Hz (high-pass) or below 19 900 Hz (low-pass); when it switches off its state is reset.
While a filter or EQ parameter ramps, coefficients are recomputed once per chunk (at most every 64 frames), not per sample. The smoothed state-variable filter used by the filter effects in the rack is a different implementation (see dsp.md).
Tested by channelFilters with Q 0.707: −3.01 dB at the corner within 0.2 dB, −40 dB a decade below a 1 kHz high-pass within 1 dB, more than 40 dB of attenuation a decade above a 1 kHz low-pass, more than 30 dB of attenuation at the far end for knob positions ±0.8, and a transparent centre within 0.01 dB.
Crossfader
Each strip has an assign value: 0 for side A, 1 for side B, 2 for through (not affected by the crossfader). The defaults are A, B, A, B for decks A to D. The channel strips in the interface show this as an A / – / B selector.
The crossfader position x runs from 0 (side A) to 1 (side B). crossfaderGains returns the gains of the two sides for the three curves named in ScriptSchema.crossfaderCurves:
| Curve | Gain of side A | Gain of side B | At the centre |
|---|---|---|---|
smooth (default) |
cos(x * π / 2) |
sin(x * π / 2) |
−3.01 dB each (constant power) |
linear |
min(1, 2 * (1 - x)) |
min(1, 2 * x) |
both at unity |
cut |
1 for x < 0.95, else (1 - x) / 0.05 |
1 for x > 0.05, else x / 0.05 |
both at unity; each side falls only in its last 5 % of travel |
The gains are evaluated at the start and the end of each chunk and interpolated in between (vDSP_vrampmuladd), so a crossfader movement does not step.
Tested by crossfaderCurves: smooth gives −3.01 dB on both sides at 0.5 within 0.05 dB and below −100 dB on the closed side; linear gives unity on both sides at 0.5 and −6.02 dB for side A at 0.75; cut is still at unity on both sides at 0.9 and below −100 dB for A at 1.
Master section
After the sum: master effects rack, then mixer.master.volume (−60…+6 dB, default 0), then the limiter, then metering, the recording tap (recording.md) and routing.
Limiter
The master limiter is a LimiterEffect instance owned by RenderCore, fully wet, with the catalogue defaults: ceiling −1 dBFS, release 100 ms, look-ahead 5 ms (240 samples at 48 kHz). Its algorithm is described in dsp.md. It is on by default (mixer.master.limiter); its ceiling and release are not exposed for the master instance.
Points that follow from the code:
- The limiter delays the master by its look-ahead, 5 ms. The unit's own comment states that this latency is not compensated. It is not included in the output latency the application displays (performance.md), and the cue bus sum is not delayed, so with the limiter on, the master part of the headphone blend is 5 ms behind the cue part.
- Switching it on or off goes through the 12 ms enable cross-fade of
EffectUnit, between the delayed limited signal and the undelayed dry signal. - The limiter is primed with silence at construction so that the ceiling holds from the first block.
- With the limiter off, nothing prevents the master from exceeding full scale; the clip counter then increments.
Tested by limiterAndClipIndicator: three decks of sines at amplitude 0.9 summed through give a peak above 1.5 and clipped blocks without the limiter; with it, the peak stays at or below 0.8913 × 1.012, no block is clipped and the reported reduction is below −3 dB.
Cue bus and headphones
The cue bus receives every channel whose cue switch is on, taken after the channel rack and before the fader. It is then blended with the master, per sample:
cue = (cue * (1 - mix) + master * mix) * volumemixer.cue.mix runs from 0 (cue only) to 1 (master only), default 0; mixer.cue.volume runs from −60 to +6 dB. The master part of the blend is the final master signal, after master volume and limiter.
Output routing
render clears every device channel and then writes:
- Master to channels
masterLeftandmasterRight(defaults 0 and 1). If both indices are equal the two channels are summed into one. - Cue to channels
cueLeftandcueRightwhen they are set (default −1, disabled) and do not coincide with a master channel. A cue channel equal to a master channel is skipped, so the cue is never mixed into the master output. The settings screen shows a warning in that configuration whose wording says the cue would be heard in the room; by the code it is simply not output. - Split cue, for stereo-only devices: when
splitCueis on and no dedicated cue output is set, the left channel carries the mono master0.5 * (L + R)and the right channel the mono cue.
The settings screen offers channel pairs (Channels 1–2, 3–4, …) for master and cue, and offers split cue only when the device has exactly two channels.
Tested by routingCueBusAndSplitCue, rendering four channels offline: the master pair carries deck A, the cue pair carries deck B pre-fader at full level (within 0.05 dB) although its fader is at −60 dB; with cue mix at 1 the cue pair carries the master; in split cue the left channel carries the master and the right the cue. No multi-channel audio interface was available, so four-channel routing has only been verified by this offline render.
Metering
| Value | Where | How it is computed |
|---|---|---|
| Channel peak | DeckRenderState.peak |
per chunk, maximum magnitude of both channels after the fader, with a fall of 24 dB per second (peakFall, applied once per chunk) |
| Channel RMS | DeckRenderState.rms |
one-pole average (0.9 / 0.1 per chunk) of the left channel's RMS |
| Master peak L / R | masterPeakL, masterPeakR |
per channel, after the limiter, same fall |
| Master RMS | masterRMS |
same average, left channel only |
| Cue peak | cuePeak |
left cue channel only |
| Limiter gain reduction | limiterReductionDB |
smallest gain the limiter applied in the chunk, in dB, held with a 0.97 per-chunk decay |
| Clipped blocks | clippedBlocks |
number of chunks in which the master exceeded 1.0 after the limiter |
Notes: the RMS values and the cue peak look at the left channel only. The fall and hold constants are applied per chunk, and chunks are shorter than 64 frames around timed events, so meters fall slightly faster while automation is dense. "Clipped blocks" counts chunks, not device buffers. These are sample-peak meters; there is no true-peak or loudness metering in the mixer (loudness of tracks is measured by the analyser, see analysis.md).
The interface reads these values 30 times per second: channel and master level meters, the GR read-out and the CLIP / OK indicator in MixerView.swift, and the counters in Settings → Audio.
One parameter space
The mixer has no API of its own. The interface, MIDI mappings and ORIX Script all write the same addresses through DJEngine.set(_:_:at:rampSeconds:tracked:), which clamps the value to the range in ScriptSchema, stores it in the model and pushes one event. The script-side view of these parameters is documented in mixer-api.md and deck-api.md; timing of scripted changes in automation.md.