SPB Git

Repository Public

midi.md 8.6 KB 217 lines markdown

1# MIDI Integration23A MIDI controller and a script meet in one place: the **automation triggers**. A script does not read MIDI. It reacts to sixteen numbered triggers, and you decide in the MIDI mapping which pad, button or key fires each one. This keeps scripts independent of hardware: the same script works with any controller, the keyboard or the console.45## The model67```text8pad or button  →  MIDI mapping  →  target "automation.trigger.3"  →  on trigger(3) { … } in every running automation9```10111. In the MIDI mapping, a control is assigned to a **target**. Targets are the things a control can drive: a fader, a play button, an automation trigger.122. When you press the pad, ORIX DJ fires trigger 3.133. Every running automation that has registered `on trigger(3)` runs that handler.1415## Reacting to a trigger in a script1617```orixdj18automation "Pad Effects" {19    on trigger(1) {20        fx.echo.mix = 0.721        fx.echo.enable()22        wait 1 beat23        fx.echo.mix = 024    }25    on trigger(2) {26        fx.echo.disable()27        stop28    }29}30```3132Start this automation and leave it running. Pad 1 throws one beat into the echo each time it is hit. Pad 2 switches the echo off and ends the automation.3334Rules:3536- Triggers are numbered 1 to 16. `on trigger(0)` or `on trigger(17)` is an error (`E-RANGE`).37- A trigger carries no value: no velocity, no pressure, no position. It only says "now".38- A trigger is delivered to all running automations. Two automations may both listen to trigger 1.39- A trigger fired when nothing listens is ignored. It is not kept for an automation started later.40- A handler exists from the moment its `on` statement runs. Start the automation before you need the pad.41- A paused automation does not receive triggers.42- The handler runs at the next scheduler step after the press, a few milliseconds later. It is not quantized. To land on the grid, wait inside the handler:4344```orixdj45on trigger(1) {46    wait nextBeat                 // or: wait nextBar47    deck.A.loop(1 beat)48    wait 1 bar49    deck.A.loopExit()50}51wait 16 bars52stop53```5455See [Events](events.md) for everything about handlers.5657## Other ways to fire a trigger5859- The console: `trigger 3`.60- A keyboard shortcut assigned to the target "Automation trigger 3".6162```console63> trigger 364Trigger 3 fired65```6667They are equivalent to the pad. This is convenient for rehearsing a pad routine without the controller.6869## Mappable targets7071A MIDI mapping assigns a control to a target identifier. These are the targets of this version.7273### Automation7475| Target | Kind | Effect |76| --- | --- | --- |77| `automation.trigger.1` … `automation.trigger.16` | trigger | Fires the automation trigger of that number |78| `automation.panic` | trigger | Emergency stop: stops every automation and bypasses every effect |7980Map `automation.panic` to a button you can find without looking. It is the fastest way out of a script that misbehaves.8182### Per deck (X = A, B, C, D)8384| Target | Kind | Effect |85| --- | --- | --- |86| `deck.X.play` | trigger | Play / pause |87| `deck.X.cue` | trigger | Cue |88| `deck.X.setCue` | trigger | Set the cue point |89| `deck.X.sync` | toggle | Sync |90| `deck.X.keylock` | toggle | Key lock |91| `deck.X.quantize` | toggle | Quantize |92| `deck.X.reverse` | toggle | Reverse |93| `deck.X.cueMonitor` | toggle | Headphone cue (the script path is `deck.X.cue`) |94| `deck.X.volume` | value | Channel fader |95| `deck.X.gain` | value | Trim |96| `deck.X.eq.high`, `deck.X.eq.mid`, `deck.X.eq.low` | value | EQ bands |97| `deck.X.filter` | value | Filter knob |98| `deck.X.tempo` | value | Tempo fader, ±8 % (moving it switches sync off) |99| `deck.X.keyShift` | value | Key shift |100| `deck.X.loopExit`, `deck.X.loopHalve`, `deck.X.loopDouble` | trigger | Loop controls |101| `deck.X.loop.1`, `.2`, `.4`, `.8`, `.16` | trigger | Loop of that many beats |102| `deck.X.jump.-4`, `.-1`, `.1`, `.4` | trigger | Beat jump |103| `deck.X.hotcue.1` … `deck.X.hotcue.8` | trigger | Hot cue pad: stores the position when empty, jumps to it when set |104| `deck.X.brake` | trigger | Tape stop |105106### Mixer107108| Target | Kind |109| --- | --- |110| `mixer.crossfader` | value |111| `mixer.master.volume` | value |112| `mixer.cue.mix` | value |113| `mixer.cue.volume` | value |114| `mixer.master.limiter` | toggle |115116### Master effects117118For each effect of the master rack (`reverb`, `delay`, `echo`, `flanger`, `phaser`, `chorus`, `distortion`, `bitcrusher`, `highpass`, `lowpass`, `bandpass`, `tremolo`, `autopan`, `gate`, `compressor`, `limiter`, `beatrepeat`, `noise`):119120| Target | Kind |121| --- | --- |122| `fx.<effect>.enabled` | toggle |123| `fx.<effect>.mix` | value |124125### Kinds and mapping modes126127| Kind | What the control does |128| --- | --- |129| value | Sets a position from 0 to 1, scaled to the range of the control (faders follow a fader law, frequencies are logarithmic) |130| toggle | Flips a switch |131| trigger | Does something once per press |132133A mapping also has a mode that says how the hardware control behaves: `absolute` (fader or knob), `relative` (endless encoder), `toggle`, `trigger` or `momentary` (active while held). A control is identified by its kind (`note`, `cc` or `pitchBend`), its MIDI channel (0 to 15) and its number (0 to 127).134135Most target identifiers look like script paths, and most address the same control as the path. Three do not exist as script paths: `deck.X.tempo`, `deck.X.cueMonitor`, and the numbered forms such as `deck.X.loop.4`. Conversely, a script can reach many things that have no direct MIDI target, such as the parameters of channel effects. That is exactly what triggers are for.136137## What scripts can and cannot do with MIDI138139| A script can | A script cannot |140| --- | --- |141| React to triggers 1…16 | Read notes, velocities, control changes or pitch bend |142| Do anything in the handler: effects, loops, transitions | Know which device or pad fired the trigger |143| Wait for the grid inside the handler | Receive a value from a knob or fader |144| Run alongside your hands on the same controller | Send MIDI: light pads, move motor faders, send clock |145| | Create or change MIDI mappings |146147If you need a knob to control "how much", map the knob to a real parameter (for example `fx.echo.mix`) and let the script read that parameter:148149```orixdj150on trigger(1) {151    let amount = fx.echo.mix          // the knob mapped to fx.echo.mix sets the amount152    fx.echo.feedback = 0.3 + amount * 0.5153    fx.echo.enable()154    wait 2 bars155    fx.echo.disable()156}157wait 16 bars158stop159```160161## Hands and scripts on the same control162163A fader moved by hand and a script writing the same control do not lock each other out: each change takes effect when it arrives. While a script ramps a control, the ramp writes it at every scheduler step, so a hand movement on that control is overwritten almost at once until the ramp ends. If you want to take over, stop the automation (or hit the emergency stop), then move the control.164165## Pad layouts that work well166167Scripts that listen to pads usually run for the whole set. A few conventions make them easier to live with:168169- Keep one long-running "pads" automation rather than several; you can see all the assignments in one file.170- Give each handler a self-contained move that puts back what it changed.171- Use a variable as a "busy" flag when a pad should not be re-triggered while its move is in progress.172- Reserve one pad for a handler that restores the controls the others touch.173174```orixdj175automation "Pads" {176    var busy = false177178    on trigger(1) {                     // filter drop for one bar179        if not busy {180            busy = true181            wait nextBar182            deck.A.filter.highpass = 400Hz183            wait 1 bar184            deck.A.filter.highpass = 20Hz185            busy = false186        }187    }188189    on trigger(2) {                     // reverb swell into the next bar190        fx.reverb.mix = 0191        fx.reverb.enable()192        over 1 bar curve easeIn { fx.reverb.mix -> 0.6 }193        fx.reverb.mix = 0194        fx.reverb.disable()195    }196197    on trigger(16) {                    // put everything back and quit198        deck.A.filter.highpass = 20Hz199        fx.reverb.disable()200        stop201    }202}203```204205## Asking Claude Studio for a mapping206207Claude Studio has a task for creating a MIDI mapping from a description of your controller. The answer is a mapping profile, not a script: a list of controls with a target and a mode each. ORIX DJ checks it locally before offering it: mappings to targets that do not exist are removed and listed, and the profile is validated. Nothing is applied without your decision.208209## Related210211- [Events](events.md)212- [Console Usage](console.md)213- [Automation Scheduling](scheduling.md)214- [Security Model](security.md)215- [Deck Commands](deck-api.md)216- [Effects Commands](effects-api.md)217
Files main
Menu

Theme