Repository Public
1<!--2ORIX Sonata3File: Documentation/manual/effects.md4Author: Simon-Pierre Boucher5Contact: contact@spboucher.ai6-->7# DSP and effects89Effects process the sound of a track, a bus or the master. Sonata has 18 of them; each is10described with all its parameters in the [effect reference](reference/effects.md).1112## The effect chain1314`effects { }` lists the effects of a strip in the order the signal passes through them.1516```sonata17composition "A Chain" {18 tempo 100bpm19 instrument keys: ElectricPiano {20 chord [D3, A3, F4] duration 1/221 chord [C3, G3, E4] duration 1/222 effects {23 eq(low_cut: 80Hz, high_gain: 2dB)24 chorus lush25 delay(time: 250ms, feedback: 0.3, mix: 0.2)26 reverb hall(mix: 0.2)27 }28 }29}30```3132An effect is written `kind`, optionally a preset, optionally arguments in parentheses:3334| Form | Meaning |35|---|---|36| `chorus` | the effect with its default settings |37| `chorus lush` | a preset |38| `reverb hall(mix: 0.2)` | a preset with some values changed |39| `delay(time: 250ms, feedback: 0.3)` | default settings with some values changed |40| `bypass chorus lush` | present in the chain but switched off |4142Arguments are always named, and checked: `time` wants a time or a musical duration,43`feedback` a ratio, `low_cut` a frequency. An unknown preset or parameter is an error with a44suggestion:4546```sonata,error=S202247composition "Unknown Preset" {48 instrument piano: GrandPiano {49 play C450 effects {51 reverb hal52 }53 }54}55```5657## Dry and wet5859Every effect has a `mix` from 0 (only the original signal) to 1 (only the processed signal);60percentages work too (`mix: 30%`). Each effect has a sensible default: 1 for an equaliser or61a compressor, less for a reverb or a delay.6263The dry signal is delayed by exactly the latency of the effect before the two are mixed, so64the mix never smears the sound. A bypassed effect keeps its latency for the same reason:65switching an effect off never shifts a track in time against the others.6667## The effects6869| Kind | What it does | Presets |70|---|---|---|71| `eq` | low cut, low shelf, three bells, high shelf, high cut | `air` `warm` `clean_lows` `presence` `telephone` |72| `filter` | low-pass, high-pass, band-pass or notch, 12 or 24 dB per octave | `dark` `resonant_sweep` |73| `compressor` | reduces level above a threshold | `gentle` `vocal` `drums` `glue` |74| `limiter` | look-ahead ceiling | `master` `loud` |75| `gate`, `expander` | reduce level below a threshold | `tight` `soft`; `subtle` |76| `delay` | stereo or ping-pong echo with filtered feedback | `slap` `echo` `dub` |77| `chorus`, `flanger`, `phaser` | modulation | `lush` `shimmer`; `jet` `through_zero_like`; `slow_swirl` `vibe` |78| `reverb` | algorithmic reverberation | `room` `chamber` `hall` `plate` `cathedral` |79| `convolution` | convolution with a synthetic room response | `dark_hall` `bright_room` |80| `distortion`, `saturation` | non-linear colour, oversampled | `crunch` `fuzz` `warm`; `tape` `hot` |81| `bitcrusher` | fewer bits and a lower sample rate | `retro` `destroyed` |82| `stereo_width` | narrows or widens, with mono bass | `mono` `wide` |83| `tremolo`, `autopan` | level and position modulation | `vintage` `helicopter`; `slow_drift` |8485The convolution reverb uses room responses generated by the program itself; no recording is86bundled.8788## Tempo-synced times8990A parameter that is a time also accepts a musical duration, converted at the tempo of the91start of the piece:9293```sonata94composition "Synced Delay" {95 tempo 96bpm96 instrument pluck: SynthPluck {97 for n in [D4, A4, F4, A4] {98 play n duration 1/499 }100 effects {101 // A dotted-eighth echo, ping-pong between the channels.102 delay(time: note_value(3/16), feedback: 0.4, mode: ping_pong, mix: 0.3)103 }104 }105}106```107108`note_value(3/16)` makes a duration from a fraction; the constants `quarter`, `eighth` and109`sixteenth` are durations too. In 0.1 the conversion uses the tempo at position 0: an effect110time does not follow later tempo changes.111112A bare number is refused, because the compiler cannot know whether you meant seconds or a113fraction of a note:114115```sonata,error=T3006116composition "No Unit" {117 instrument piano: GrandPiano {118 play C4119 effects {120 delay(time: 0.25)121 }122 }123}124```125126## Dynamics127128```sonata129composition "Dynamics" {130 tempo 110bpm131 instrument kick: Kick {132 repeat 8 {133 play C2 duration 1/4134 }135 effects {136 compressor(threshold: -18dB, ratio: 4, attack: 10ms, release: 120ms, makeup: 3dB)137 saturation tape(mix: 0.5)138 }139 }140 instrument bass: PickBass {141 gain -4dB142 repeat 4 {143 play E2 duration 3/8144 play E2 duration 1/8 staccato145 }146 effects {147 compressor gentle148 gate soft149 }150 }151}152```153154## Colour155156```sonata157composition "Colour" {158 tempo 92bpm159 instrument lead: SynthLead {160 gain -10dB161 for n in [E4, G4, B4, D5, B4, G4] {162 play n duration 1/8163 }164 play E4 duration 1/4165 effects {166 distortion crunch(mix: 0.6)167 filter(mode: lowpass, cutoff: 3500Hz, resonance: 2)168 phaser vibe(mix: 0.4)169 stereo_width wide170 }171 }172}173```174175## Space176177A reverb placed directly on a track belongs to that track. To put several instruments in the178same room, give the room its own bus and send to it; this is described in179[Mixing](mixing.md#buses-and-sends).180181```sonata182composition "Space" {183 tempo 66bpm184 instrument choir: ChoirAahs {185 gain -8dB186 chord [A3, C4, E4] duration 1/1187 effects {188 reverb cathedral(mix: 0.4, predelay: 30ms)189 }190 }191}192```193194## Effects that change over time195196Parameters marked *automatable* in the reference can be drawn as a curve with `automate`,197naming the effect and the parameter. The effect must be declared above the automation.198199```sonata200composition "A Filter Sweep" {201 tempo 124bpm202 instrument pad: SynthStrings {203 gain -8dB204 chord [D3, A3, D4, F4] duration 4bars205 effects {206 filter(mode: lowpass, cutoff: 300Hz, resonance: 3)207 reverb hall(mix: 0.2)208 }209 automate filter.cutoff {210 0bars: 300Hz211 3bars: 8000Hz exp212 4bars: 600Hz213 }214 automate reverb.mix {215 0bars: 0.1216 4bars: 0.5217 }218 }219}220```221222## What the numbers mean223224The effects were measured, not only written: the limiter never lets a sample above its225ceiling, the compressor follows its static curve, a delay is exact to the sample, the226equaliser has the gain you ask for at its centre frequency, the reverb's measured decay is227within 35 % of its `decay` setting. The **Filter Lab** of [WaveLab](wavelab.md) shows the228amplitude, phase and impulse response of any effect with the parameters you choose.229230Known limits of 0.1: the limiter works on sample peaks (inter-sample peaks are measured by231the meters, not limited); changing the `size` of a reverb while it sounds is audible; the232`space`, `decay` and `brightness` of the convolution reverb are fixed once it is sounding.233