SPB Git

Repository Public

beats-and-bars.md 8.0 KB 203 lines markdown

1# Beats and Bars23DJs count in beats and bars, and so does ORIX Script. This chapter explains exactly how positions are counted, how the automation's own bars relate to the bars of the master clock, and how to make things land where you expect.45## The grid67- A **beat** is one beat of the master clock.8- A **bar** is 4 beats. This is fixed; ORIX Script has no other time signature.9- Phrases in dance music are usually 4, 8, 16 or 32 bars: 16, 32, 64 or 128 beats.1011| Length | Beats | At 128 BPM |12| --- | --- | --- |13| 1 beat | 1 | 0.47 s |14| 1 bar | 4 | 1.875 s |15| 4 bars | 16 | 7.5 s |16| 8 bars | 32 | 15 s |17| 16 bars | 64 | 30 s |18| 32 bars | 128 | 60 s |1920## Counting from 12122Positions are counted the way a musician counts: the first bar is bar 1, and its first beat is beat 1.2324```text25bar:     |   1   |   2   |   3   |   4   |   5   |26beat:     1 2 3 4 5 6 7 8 9 …             1727offset:   0 1 2 3 4 5 6 7 8 …             16     (beats elapsed since the start)28```2930| Position | Beats elapsed since the start of the automation |31| --- | --- |32| `at bar 1`, `at beat 1`, `at 0 beats` | 0 |33| `at beat 2` | 1 |34| `at bar 2`, `at beat 5`, `at 1 bar` | 4 |35| `at bar 3`, `at beat 9`, `at 2 bars` | 8 |36| `at bar 5`, `at beat 17`, `at 4 bars` | 16 |37| `at bar 9`, `at beat 33`, `at 8 bars` | 32 |3839In general:4041```text42bar N   is (N - 1) × 4 beats after the start43beat N  is (N - 1) beats after the start44```4546`at bar 0` and `at beat 0` do not exist (`E-RANGE`): counting starts at 1.4748The bar and beat numbers can be computed. Fractions are allowed: `at beat 2.5` is one and a half beats after the start, the "and" of beat 2.4950```orixdj51for hit in 1...4 {52    at beat hit + 0.5 { deck.A.eq.high = -26dB }      // on every off-beat of bar 153    at beat hit + 0.75 { deck.A.eq.high = 0dB }54}55wait 1 bar56```5758## Durations count from 05960A duration is a length, not a position. `wait 8 bars` lasts 32 beats. A ramp `over 8 bars` started at bar 1 ends at the **start of bar 9**, not during bar 8.6162This is the most common source of off-by-one-bar surprises:6364| You want | Write |65| --- | --- |66| Something at the end of an 8-bar ramp started at bar 1 | `at bar 9 { … }`, or simply put it after the `over` block |67| Something on the last bar of an 8-bar phrase | `at bar 8 { … }` (28 beats in; the ramp is still running) |68| Something on the last beat of an 8-bar phrase | `at beat 32 { … }` (31 beats in) |6970```orixdj71at bar 8 { deck.B.play() }                 // last bar of the phrase: B starts under the ramp72over 8 bars { deck.A.volume -> -60dB }     // ends at the start of bar 973deck.A.pause()                             // start of bar 974deck.A.volume = 0dB75```7677## Two grids: the automation and the master clock7879There are two ways of talking about bars, and they are the same only if you ask for it.8081- **The automation's bars** start when the automation starts. `at bar N`, `at beat N` and `wait until bar N` count on this timeline.82- **The master clock's bars** are the bars of the music: the clock follows the beat grid of the master deck, bar lines included. `wait nextBar`, `wait nextBeat`, `at nextBar`, `at nextBeat`, the `on bar` and `on beat` events and `quantize` use this grid.8384If you start an automation in the middle of a bar without quantizing, its "bar 2" is four beats after the moment you pressed the button, which is in the middle of a musical bar.8586**`quantize bar` aligns the two.** The automation then starts on a bar line of the master clock, so the automation's bar lines fall on the music's bar lines.8788```orixdj89automation "On The Grid" quantize bar {90    // bar 1 of this automation is a real bar line of the music91    at bar 3 { deck.A.eq.low = -26dB }92    at bar 5 { deck.A.eq.low = 0dB }93    wait 4 bars94}95```9697Use `quantize bar` for anything that has to sit on the phrase. Use `quantize beat` for short rhythmic effects that only need to be on the beat. Leave quantizing out for things that should react immediately, such as a console command or a trigger handler.9899`quantize bar` gives you a bar line, not necessarily the first bar of a phrase. Starting the automation during the last bar of a phrase is up to you.100101## Getting back on the grid in the middle of a script102103`wait nextBar` and `wait nextBeat` move the cursor to the next line of the master clock. They are useful after something that is not musical: a wait in seconds, or an event.104105```orixdj106wait 1500ms                 // not a whole number of beats107wait nextBar                // realign with the music108deck.A.eq.low = -26dB109wait 1 bar110deck.A.eq.low = 0dB111```112113Remember that when the cursor is already on a line, these statements do not wait.114115## Subdivisions116117Fractions of a beat give the usual rhythmic values.118119| Written | Notes per beat | Name |120| --- | --- | --- |121| `1 beat` | 1 | Quarter note |122| `1/2beat` | 2 | Eighth note |123| `1/3beat` | 3 | Eighth-note triplet |124| `1/4beat` | 4 | Sixteenth note |125| `1/8beat` | 8 | Thirty-second note |126| `3/4beat` | – | Dotted eighth (the classic delay time) |127| `3/2beat` | – | Dotted quarter |128129```orixdj130// a sixteenth-note stutter for one bar, then a dotted-eighth echo131every 1/4beat for 1 bar {132    deck.A.volume = -60dB133    wait 1/8beat134    deck.A.volume = 0dB135}136fx.echo.time = 3/4beat137fx.echo.enable()138wait 2 bars139fx.echo.disable()140```141142The shortest period accepted by `every` is 1/64 of a beat.143144## Reading the clock145146| Path | Value |147| --- | --- |148| `master.bpm` | Tempo of the master clock |149| `master.beat` | Beat counter of the master clock (a fractional number that keeps increasing) |150| `master.bar` | Bar counter of the master clock: `master.beat` divided by 4, rounded down |151| `master.deck` | Letter of the deck that drives the clock, or `""` when the clock runs free |152| `deck.X.beat` | Fractional beat index of the playhead on the track's own beat grid |153| `deck.X.bpm` | Effective tempo of the deck (track tempo × playback rate) |154| `deck.X.trackBpm` | Analysed tempo of the track at original speed; 0 when unknown. The analysis reports tempos between 78 and 156 BPM (the ÷2 and ×2 buttons on the deck change it) |155156`master.beat` and `master.bar` are counters of the clock, not positions in the automation, and they start from 0. Use them for arithmetic such as "is this an even bar".157158```orixdj159if master.bar % 2 == 0 {160    print("even bar of the master clock")161} else {162    print("odd bar of the master clock")163}164```165166## The master clock and the master deck167168The master clock follows the master deck: its tempo is the effective tempo of that deck, and its beats and bar lines are locked to the deck's beat grid. The master deck is the deck you chose as master, or else the current master while it keeps playing, or else the first playing deck that has a beat grid.169170When no deck with a beat grid is playing, the clock runs free at its own tempo. Writing `master.bpm` sets that free-running tempo; it has no audible effect while a master deck is driving the clock.171172```orixdj173if master.deck == "" {174    master.bpm = 124          // nothing is driving the clock: choose the tempo175}176```177178A deck with `sync` on follows the tempo of the clock and is steered onto its beat phase. That is why transitions start with `deck.B.sync(true)`: afterwards "one bar" means the same thing on both decks.179180## Deck positions are a different thing181182`deck.X.seek(…)`, `deck.X.jump(…)` and `deck.X.loop(…)` work on the **track**, not on the automation's timeline.183184- `deck.A.seek(64 beats)` moves the playhead to beat 64 of the track's beat grid, counted from the first beat of the grid. `deck.A.seek(30s)` moves it 30 seconds from the start of the file.185- `deck.A.jump(-4 beats)` moves the playhead back four beats from where it is.186- `deck.A.loop(4 beats)` starts a four-beat loop at the playhead. A loop length must be between 1/64 beat and 256 beats.187188```orixdj189deck.B.seek(32 beats)        // cue deck B at its ninth bar190deck.B.sync(true)191wait nextBar192deck.B.play()193```194195## Related196197- [Timing](timing.md)198- [Automation Scheduling](scheduling.md)199- [Units](units.md)200- [Loops](loops.md)201- [Mixer Commands](mixer-api.md)202- [Troubleshooting](troubleshooting.md)203
Files main
Menu

Theme