First Automation
This 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.
The situation
Deck 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.
By hand that is six or seven moves on two channels. In a script it is a short list.
Step 1: an empty automation
automation "Bass Swap Intro" {
}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.
Step 2: start deck B silently
automation "Bass Swap Intro" {
deck.B.sync(true)
deck.B.volume = -60dB
deck.B.eq.low = -26dB
deck.B.play()
}deck.B.sync(true)makes deck B follow the tempo and the beat phase of the master deck.-60dBis silence on a channel fader, and-26dBon an EQ band is a full kill.- The four lines run at the same instant: none of them takes time.
Order still matters. The volume is set before play(), so deck B never plays a beat at full level.
Step 3: bring deck B in over two bars
automation "Bass Swap Intro" {
deck.B.sync(true)
deck.B.volume = -60dB
deck.B.eq.low = -26dB
deck.B.play()
over 2 bars {
deck.B.volume -> 0dB
}
}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).
The automation stays in the over block for two bars. Whatever comes after the block happens two bars later.
Step 4: swap the bass on the bar
automation "Bass Swap Intro" {
deck.B.sync(true)
deck.B.volume = -60dB
deck.B.eq.low = -26dB
deck.B.play()
over 2 bars {
deck.B.volume -> 0dB
}
deck.A.eq.low = -26dB
deck.B.eq.low = 0dB
}The 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.
Step 5: take deck A out and tidy up
automation "Bass Swap Intro" {
deck.B.sync(true)
deck.B.volume = -60dB
deck.B.eq.low = -26dB
deck.B.play()
over 2 bars {
deck.B.volume -> 0dB
}
deck.A.eq.low = -26dB
deck.B.eq.low = 0dB
over 2 bars {
deck.A.volume -> -60dB
}
deck.A.pause()
deck.A.eq.low = 0dB
deck.A.volume = 0dB
}The 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.
Step 6: land on the bar
So far the automation starts the instant you launch it, which is rarely on a bar line. Add quantize bar:
automation "Bass Swap Intro" quantize bar {
deck.B.sync(true)
deck.B.volume = -60dB
deck.B.eq.low = -26dB
deck.B.play()
over 2 bars { deck.B.volume -> 0dB }
deck.A.eq.low = -26dB
deck.B.eq.low = 0dB
over 2 bars { deck.A.volume -> -60dB }
deck.A.pause()
deck.A.eq.low = 0dB
deck.A.volume = 0dB
}Now 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.
Step 7: make the length a setting
A value that you may want to change belongs in a named constant. let gives a value a name.
automation "Bass Swap Intro" quantize bar {
let half = 4 bars
deck.B.sync(true)
deck.B.volume = -60dB
deck.B.eq.low = -26dB
deck.B.play()
over half { deck.B.volume -> 0dB }
deck.A.eq.low = -26dB
deck.B.eq.low = 0dB
over half { deck.A.volume -> -60dB }
deck.A.pause()
deck.A.eq.low = 0dB
deck.A.volume = 0dB
}Change 4 bars to 8 bars and the whole transition stretches.
Step 8: refuse to run when it cannot work
A 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.
automation "Bass Swap Intro" quantize bar {
let half = 4 bars
if not deck.B.loaded {
print("Load a track on deck B first.")
stop
}
deck.B.sync(true)
deck.B.volume = -60dB
deck.B.eq.low = -26dB
deck.B.play()
over half { deck.B.volume -> 0dB }
deck.A.eq.low = -26dB
deck.B.eq.low = 0dB
over half { deck.A.volume -> -60dB }
deck.A.pause()
deck.A.eq.low = 0dB
deck.A.volume = 0dB
}stop ends the automation. print writes to the automation log.
What happens, bar by bar
With half = 4 bars:
| Position | What happens |
|---|---|
| Before bar 1 | The automation waits for the next bar line. |
| Bar 1, beat 1 | Deck B is synced, silenced, bass-killed and started. Its fader starts to rise. |
| Bars 1 to 4 | Deck B fades in without bass. Deck A is untouched. |
| Bar 5, beat 1 | Bass swap: deck A low EQ killed, deck B low EQ restored. Deck A starts to fade. |
| Bars 5 to 8 | Deck A fades out. |
| Bar 9, beat 1 | Deck A is paused; its low EQ and fader are restored. The automation finishes. |
Try it safely first
Run 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.
Before running it live, check:
- deck A is playing and deck B is loaded and cued where you want it to start;
- both tracks have a tempo, so that sync can work;
- nothing else is automating the same controls at the same time.
Where to go next
- The bundled preset "Bass Swap" is this transition; "Auto DJ Blend" is the same idea written as a reusable function. See Presets.
- Timing explains
wait,overandatprecisely. - Functions shows how to write the transition once and use it for any pair of decks.