SPB Git

Repository Public

first-automation.md 6.3 KB 228 lines markdown

1# First Automation23This chapter builds one automation step by step: a four-bar bass swap from deck A to deck B. Each step adds one idea. By the end you will have written a transition that you can reuse on any two tracks.45## The situation67Deck A is playing. Deck B has the next track loaded and cued on its first beat. You want deck B to come in, the bass lines to swap exactly on a bar, and deck A to leave.89By hand that is six or seven moves on two channels. In a script it is a short list.1011## Step 1: an empty automation1213```orixdj14automation "Bass Swap Intro" {15}16```1718`automation` starts a block, the name goes in double quotes, and the statements go between the braces. An empty automation is valid; it finishes at once.1920## Step 2: start deck B silently2122```orixdj23automation "Bass Swap Intro" {24    deck.B.sync(true)25    deck.B.volume = -60dB26    deck.B.eq.low = -26dB27    deck.B.play()28}29```3031- `deck.B.sync(true)` makes deck B follow the tempo and the beat phase of the master deck.32- `-60dB` is silence on a channel fader, and `-26dB` on an EQ band is a full kill.33- The four lines run at the same instant: none of them takes time.3435Order still matters. The volume is set *before* `play()`, so deck B never plays a beat at full level.3637## Step 3: bring deck B in over two bars3839```orixdj40automation "Bass Swap Intro" {41    deck.B.sync(true)42    deck.B.volume = -60dB43    deck.B.eq.low = -26dB44    deck.B.play()4546    over 2 bars {47        deck.B.volume -> 0dB48    }49}50```5152`over 2 bars { … }` is a ramp block. Inside it, `->` means "arrive at this value when the block ends". The ramp starts from wherever the control is now (here -60 dB).5354The automation stays in the `over` block for two bars. Whatever comes after the block happens two bars later.5556## Step 4: swap the bass on the bar5758```orixdj59automation "Bass Swap Intro" {60    deck.B.sync(true)61    deck.B.volume = -60dB62    deck.B.eq.low = -26dB63    deck.B.play()6465    over 2 bars {66        deck.B.volume -> 0dB67    }6869    deck.A.eq.low = -26dB70    deck.B.eq.low = 0dB71}72```7374The two assignments after the block run together, two bars after the start: the bass of deck A disappears and the bass of deck B appears on the same beat.7576## Step 5: take deck A out and tidy up7778```orixdj79automation "Bass Swap Intro" {80    deck.B.sync(true)81    deck.B.volume = -60dB82    deck.B.eq.low = -26dB83    deck.B.play()8485    over 2 bars {86        deck.B.volume -> 0dB87    }8889    deck.A.eq.low = -26dB90    deck.B.eq.low = 0dB9192    over 2 bars {93        deck.A.volume -> -60dB94    }9596    deck.A.pause()97    deck.A.eq.low = 0dB98    deck.A.volume = 0dB99}100```101102The last three lines matter as much as the fade. A script that leaves the bass of deck A killed and its fader down will surprise you when you load the next track on that deck. Put back what you changed.103104## Step 6: land on the bar105106So far the automation starts the instant you launch it, which is rarely on a bar line. Add `quantize bar`:107108```orixdj109automation "Bass Swap Intro" quantize bar {110    deck.B.sync(true)111    deck.B.volume = -60dB112    deck.B.eq.low = -26dB113    deck.B.play()114115    over 2 bars { deck.B.volume -> 0dB }116117    deck.A.eq.low = -26dB118    deck.B.eq.low = 0dB119120    over 2 bars { deck.A.volume -> -60dB }121122    deck.A.pause()123    deck.A.eq.low = 0dB124    deck.A.volume = 0dB125}126```127128Now you can start it anywhere in a bar. Nothing happens until the next bar line of the master clock; from there the swap is two bars later and the end is four bars later.129130## Step 7: make the length a setting131132A value that you may want to change belongs in a named constant. `let` gives a value a name.133134```orixdj135automation "Bass Swap Intro" quantize bar {136    let half = 4 bars137138    deck.B.sync(true)139    deck.B.volume = -60dB140    deck.B.eq.low = -26dB141    deck.B.play()142143    over half { deck.B.volume -> 0dB }144145    deck.A.eq.low = -26dB146    deck.B.eq.low = 0dB147148    over half { deck.A.volume -> -60dB }149150    deck.A.pause()151    deck.A.eq.low = 0dB152    deck.A.volume = 0dB153}154```155156Change `4 bars` to `8 bars` and the whole transition stretches.157158## Step 8: refuse to run when it cannot work159160A script can look at the rig before it acts. If deck B is not loaded, `deck.B.play()` fails and the automation is cancelled with an error. It is friendlier to check and say why.161162```orixdj163automation "Bass Swap Intro" quantize bar {164    let half = 4 bars165166    if not deck.B.loaded {167        print("Load a track on deck B first.")168        stop169    }170171    deck.B.sync(true)172    deck.B.volume = -60dB173    deck.B.eq.low = -26dB174    deck.B.play()175176    over half { deck.B.volume -> 0dB }177178    deck.A.eq.low = -26dB179    deck.B.eq.low = 0dB180181    over half { deck.A.volume -> -60dB }182183    deck.A.pause()184    deck.A.eq.low = 0dB185    deck.A.volume = 0dB186}187```188189`stop` ends the automation. `print` writes to the automation log.190191## What happens, bar by bar192193With `half = 4 bars`:194195| Position | What happens |196| --- | --- |197| Before bar 1 | The automation waits for the next bar line. |198| Bar 1, beat 1 | Deck B is synced, silenced, bass-killed and started. Its fader starts to rise. |199| Bars 1 to 4 | Deck B fades in without bass. Deck A is untouched. |200| Bar 5, beat 1 | Bass swap: deck A low EQ killed, deck B low EQ restored. Deck A starts to fade. |201| Bars 5 to 8 | Deck A fades out. |202| Bar 9, beat 1 | Deck A is paused; its low EQ and fader are restored. The automation finishes. |203204## Try it safely first205206Run a new automation in the simulator before you run it live. The simulator uses the same runtime against a simulated rig and shows every action with its beat, the curve of every parameter the script wrote, and any error. See [Debugging](debugger.md).207208Before running it live, check:209210- deck A is playing and deck B is loaded and cued where you want it to start;211- both tracks have a tempo, so that sync can work;212- nothing else is automating the same controls at the same time.213214## Where to go next215216- The bundled preset "Bass Swap" is this transition; "Auto DJ Blend" is the same idea written as a reusable function. See [Presets](presets.md).217- [Timing](timing.md) explains `wait`, `over` and `at` precisely.218- [Functions](functions.md) shows how to write the transition once and use it for any pair of decks.219220## Related221222- [Quick Start](quickstart.md)223- [Timing](timing.md)224- [Beats and Bars](beats-and-bars.md)225- [Variables](variables.md)226- [Conditions](conditions.md)227- [Deck Commands](deck-api.md)228
Files main
Menu

Theme