SPB Git

Repository Public

glitch-fills.md 2.8 KB

# Glitch Fills

For sixteen bars, the last bar of every four-bar phrase gets four short beat-repeat fills, each with a slice length picked from a list. The picks come from random(), which gives the same sequence on every run: the fills sound varied, and the routine is identical each time you play it. It shows random, len, array indexing with a computed index, and nested repeat.

# The script

orixdj
automation "Glitch Fills" quantize bar {
    let slices = [1/2beat, 1/4beat, 1/4beat, 1/8beat, 1/16beat]
    let phrases = 4           // number of four-bar phrases

    repeat phrases {
        wait 3 bars
        // Fourth bar of the phrase: four one-beat fills with slices picked from the list.
        repeat 4 {
            let pick = floor(random() * len(slices))
            fx.beatrepeat.length = slices[pick]
            fx.beatrepeat.enable()
            wait 3/4beat
            fx.beatrepeat.disable()
            wait 1/4beat
        }
    }
}

# What happens, bar by bar

Position What happens
Before bar 1 The automation waits for the next bar line.
Bars 1 to 3 Nothing: the track plays.
Bar 4 On each beat: a slice length is picked, the master beat repeat is switched on for three quarters of a beat, then off for the last quarter.
Bars 5 to 16 The same phrase three more times: three bars of music, one bar of fills (bars 8, 12 and 16).
Bar 17, beat 1 The automation finishes with the beat repeat switched off.

# When to use it

To add variation to a long, repetitive section without touching anything by hand. Start it on the first bar of a phrase so that the fills land on bars 4, 8, 12 and 16.

# Check before running it live

  • Something is playing through the master.
  • The master beat repeat is free to be reconfigured.
  • The automation starts on a phrase boundary: quantize bar gives a bar line, the choice of the bar is yours.
  • You have listened to the sequence once: it is always the same, so if one fill is unpleasant you can change the list.

# Notes and variations

random() returns a number from 0 up to 1. Multiplying by len(slices) and rounding down with floor gives a whole number from 0 to 4, a valid index into the five-element list. In the simulator the first bar of fills uses slices of 1/4, 1/16, 1/4 and 1/4 beat.

The sequence restarts each time the automation is started. Two runs give the same fills; a longer run continues the sequence.

let pick is declared inside the inner loop. It is a new value on every turn and exists only within that block.

If the script failed in the middle of a fill, the runtime would switch the effect off again.

Files main
Menu

Theme