SPB Git

Repository Public

end-of-track-guard.md 3.4 KB

# End Of Track Guard

A safety net for long sets: the automation stays in the background and looks at deck A on every bar. When 32 bars or less remain, it blends to deck B over sixteen bars, if deck B is ready, and then ends. It is event-driven, uses a flag variable, and compares a time in seconds with a length in bars.

# The script

orixdj
automation "End Of Track Guard" {
    let warning = 32 bars     // how much track must be left when the blend starts
    let blend = 16 bars
    var started = false

    on bar {
        if not started and deck.A.playing and deck.A.remaining <= warning {
            started = true
            if deck.B.loaded and not deck.B.playing {
                deck.B.sync(true)
                deck.B.volume = -60dB
                deck.B.play()
                over blend {
                    deck.B.volume -> 0dB
                    deck.A.volume -> -60dB
                }
                deck.A.pause()
                deck.A.volume = 0dB
                print("Blend to deck B done.")
            } else {
                print("Deck A is ending and deck B is not ready.")
            }
            stop
        }
    }
}

# What happens, bar by bar

Position What happens
Start Three values are set and a bar handler is registered. Nothing else happens; the automation stays alive because of the handler.
Every bar line The handler checks: not started yet, deck A playing, and 32 bars or less remaining. Otherwise it does nothing.
The first bar line with 32 bars or less left started becomes true, so later bars are ignored. If deck B is loaded and paused: it is synced, silenced and started, and the blend begins.
The next 16 bars Deck B fades in while deck A fades out.
16 bars later Deck A is paused and its fader restored; a message is printed; stop ends the automation.
If deck B was not ready A message is printed and the automation stops at once.

# When to use it

When you may be away from the decks, or as a backstop while you prepare something else. Start it once deck A is playing and deck B is loaded.

# Check before running it live

  • Deck B is loaded, paused and cued where it should start, with its EQ and filter as you want them.
  • Both tracks have an analysed tempo.
  • Deck A's track is longer than the warning distance, and it is the track you expect to end.
  • No other automation is going to move the faders of decks A and B.
  • You know it is running: status lists it. Stop it with stop "End Of Track Guard" if you decide to mix by hand.

# Notes and variations

deck.A.remaining <= warning compares seconds with bars. Both are converted to beats with the tempo of the master clock at that moment, so the test means "32 bars of the current tempo".

The handler takes sixteen bars while its event fires every bar. The started flag is what prevents a second run from starting a second blend; without it there would be one more run per bar.

The blend lands on a bar line because bar events fire on bar lines. It does not know about phrases: choose warning and the cue point of deck B so that the entry makes musical sense.

The automation stops after one transition. To keep guarding, start it again when the next track is loaded, or see Back To Back.

Files main
Menu

Theme