Repository Public
1<!--2ORIX Sonata3File: Documentation/manual/mixing.md4Author: Simon-Pierre Boucher5Contact: contact@spboucher.ai6-->7# Mixing89A composition is mixed through **strips**: one per track, one per bus, and the master.1011## Track settings1213```sonata14composition "Track Settings" {15 tempo 100bpm16 instrument piano: GrandPiano {17 gain -6dB // fader, in decibels18 pan -0.3 // -1 is left, 0 centre, 1 right19 chord [C3, G3, E4] duration 1/120 }21 instrument flute: Flute {22 gain -9dB23 pan 0.424 play G5 duration 1/125 }26 instrument bass: FingerBass {27 mute // silent, but still part of the piece28 play C2 duration 1/129 }30}31```3233* `gain` goes from −120 dB to +24 dB; 0 dB leaves the level unchanged.34* `pan` uses a constant-power law: a centred signal is 3 dB lower in each channel than a35 signal panned fully to one side, so loudness stays even as a sound moves.36* `mute` silences a strip, its sends included. `solo` silences every track that is not37 soloed.3839## Buses and sends4041A bus is a strip that receives the signal of other strips. Two uses:4243* **A group.** `output drums` sends a track to the bus *instead of* the master, so one44 compressor and one fader control the whole kit.45* **A shared effect.** `send hall -8dB` sends a copy of the track to the bus *as well as* its46 normal output; the bus holds a reverb at 100 % wet.4748```sonata49composition "Buses" {50 tempo 104bpm5152 bus drums {53 gain -2dB54 effects {55 compressor drums56 }57 }5859 bus hall {60 gain -8dB61 effects {62 reverb hall(mix: 100%)63 }64 }6566 instrument kick: Kick {67 output drums68 repeat 4 {69 play C2 duration 1/470 }71 }7273 instrument snare: Snare {74 output drums75 send hall -12dB76 repeat 2 {77 rest 1/478 play D2 duration 1/479 }80 }8182 instrument keys: ElectricPiano {83 gain -8dB84 send hall -6dB85 chord [A2, E3, C4, G4] duration 1/186 }87}88```8990`send BUS GAIN` takes the signal after the track's fader, so turning the track down turns its91reverb down too. `send BUS GAIN pre` takes it before the fader. Buses can send to other buses92and choose their own `output`; routing in a circle is an error (G5001).9394When paths of different latency meet — a track with a look-ahead limiter and one without —95the compiler adds exactly the delay needed so that everything arrives aligned.9697## Automation9899`automate TARGET { }` draws a curve for a parameter: a list of *position: value* points.100101| Target | What moves |102|---|---|103| `gain`, `pan` | the strip's fader and position |104| `instrument.PARAM` | a parameter of the track's instrument |105| `EFFECT.PARAM` | a parameter of an effect declared above (`reverb.mix`, `delay.feedback`) |106107```sonata108composition "Automation" {109 tempo 120bpm110 instrument pad: SynthPad {111 gain -10dB112 automate gain {113 0bars: -40dB114 2bars: -10dB exp115 4bars: -10dB116 }117 automate pan {118 0bars: -0.8119 4bars: 0.8120 }121 chord [D3, A3, F4, C5] duration 4bars122 effects {123 delay(time: note_value(1/4), feedback: 0.2, mix: 0.2)124 }125 automate delay.feedback {126 0bars: 0.2127 4bars: 0.7128 }129 }130}131```132133* Positions are durations counted **from the cursor** at the place of the statement. Written134 at the top of a track they are positions in the piece.135* Each point can name the shape of the segment that ends at it: `linear` (the default), `exp`136 (even to the ear for levels and frequencies) or `step` (hold the previous value, then jump).137* Values use the unit and the range of the parameter.138* Only parameters marked *automatable* in the reference can be automated (T3014 otherwise).139* The statement does not move the cursor.140141The second effect of the same kind in a chain is addressed as `delay[1].feedback`.142143## The master144145```sonata146composition "Master" {147 instrument piano: GrandPiano {148 chord [C2, C3, G3, E4] duration 1/1 velocity 1149 }150 master {151 sample_rate 48000Hz152 gain -2dB153 peak_limit -1dB154 effects {155 eq(low_cut: 30Hz)156 compressor glue157 }158 }159}160```161162* `sample_rate` is the rate of the project: 44 100, 48 000, 88 200, 96 000, 176 400 or163 192 000 Hz (48 000 when left out). A render can choose another rate.164* `peak_limit` is the ceiling of a safety limiter at the very end of the chain, −1 dBFS when165 left out. It is there so that a mistake never becomes a dangerously loud sound.166* `peak_limit off` removes the limiter, for measurements and for exports that must be exactly167 what the code produces:168169```sonata170composition "No Limiter" {171 instrument tone: FluteOrgan {172 gain -12dB173 play A4 duration 1/1174 }175 master {176 peak_limit off177 }178}179```180181Nothing is normalised implicitly. A render has the level the code and the mixer give it,182unless you ask for normalisation when exporting ([Exports](exports.md)).183184## Levels and loudness185186The mixer's meters show, for every strip, the **peak** (the largest sample) and the **RMS**187level over 300 ms. The master panel adds loudness measured on what was actually played,188according to ITU-R BS.1770-4:189190| Reading | Meaning |191|---|---|192| Momentary | loudness over the last 400 ms |193| Short-term | loudness over the last 3 s |194| Integrated | loudness since playback started (gated) |195| True peak | the highest peak between samples, in dBTP |196197The loudness meter is validated against the standard's reference: a 1 kHz stereo sine at198−23 dBFS reads −23.0 LUFS within 0.1. `sonata render` prints the peak, true peak and199integrated loudness of every file it writes.200201A practical habit: keep peaks of single tracks around −12 dBFS and let the master land between202−20 and −14 LUFS; the limiter then has nothing to do.203204## The order of things205206For each sample rate the compiler builds the mixing graph:207208* a track: instrument → effects → fader and pan → its output; sends leave before the fader209 (`pre`) or after it;210* a bus: the sum of what it receives → effects → fader and pan → its output;211* the master: the sum → effects → fader → limiter → output.212213The **Compiler** space ([Compiler](compiler.md)) draws this graph with the latency of every214node.215