Repository Public
1# Back To Back23The simplest possible auto-play: whenever the track on one deck ends, the other deck starts and the deck that just ended loads the next track of the Auto DJ queue. No blend, no sync; one track after the other. It runs until you stop it. It shows deck events, a procedure with two deck parameters, and `loadNext`.45## The script67```orixdj8fn handOver(ended: deck, next: deck) {9 next.volume = 0dB10 next.play()11 // The deck that just ended is paused, so it can be reloaded.12 ended.loadNext()13}1415automation "Back To Back" {16 on deck.A.trackEnd { handOver(deck.A, deck.B) }17 on deck.B.trackEnd { handOver(deck.B, deck.A) }18 on trigger(16) { stop }19 print("Back To Back is armed. Trigger 16 stops it.")20}21```2223## What happens, bar by bar2425| Position | What happens |26| --- | --- |27| Start | Three handlers are registered and a message is printed. The automation waits. |28| Deck A reaches the end of its track | Deck B's fader is opened and deck B starts. Deck A, which is now paused, loads the next track of the queue. |29| Deck B reaches the end of its track | The same with the roles exchanged. |30| Trigger 16 | The automation stops. Whatever is playing keeps playing. |3132## When to use it3334For background music, a warm-up, or a break, when tracks should simply follow each other. For beat-matched transitions use Auto DJ or the preset "Auto DJ Blend".3536## Check before running it live3738- Deck A is playing; deck B is loaded and cued at its start.39- The Auto DJ queue contains the tracks to come. When the queue is empty, `loadNext()` fails and the automation is cancelled with `E-ACTION`; the deck that just started keeps playing.40- A control is mapped to `automation.trigger.16`, or you will stop it with `stop "Back To Back"`.41- There will be a gap or an overlap depending on how the tracks end and begin: nothing is trimmed or faded.4243## Notes and variations4445`trackEnd` fires when the playhead reaches the end of the file. The deck is paused at that point, which is what allows `loadNext()` on it: loading is refused on a playing deck.4647The procedure takes the two decks as parameters, so the two handlers are one line each.4849Loading takes a moment. The freshly loaded deck is not started by this script until the other deck ends, so that is not a problem here. If you need to act when a load completes, use the `loaded` event.5051Because the automation has handlers and no `once`, it never finishes by itself.5253## Related5455- [Events](../events.md)56- [Functions](../functions.md)57- [Deck Commands](../deck-api.md)58- [Troubleshooting](../troubleshooting.md)59- [Examples](README.md)60