Repository Public
1// ORIX DJ2// File: Packages/ORIXDJCore/Sources/ORIXScript/Presets.swift3// Description: The bundled automation presets. Each one is ordinary ORIX Script that users can open, read and change;4// the test suite compiles and simulates every one of them.5//6// Author: Simon-Pierre Boucher7// Contact: contact@spboucher.ai8import Foundation910public enum PresetCategory: String, Sendable, CaseIterable, Codable {11 case transitions = "Transitions"12 case crossfades = "Crossfades"13 case filters = "Filters"14 case echo = "Echo"15 case reverb = "Reverb"16 case beatEffects = "Beat effects"17 case buildUps = "Build-ups"18 case drops = "Drops"19 case loops = "Loops"20 case autoDJ = "Auto DJ"21 case creative = "Creative performance"22}2324public struct ScriptPreset: Sendable, Identifiable, Equatable {25 public var id: String { name }26 public let name: String27 public let category: PresetCategory28 public let summary: String29 public let source: String30}3132public enum PresetLibrary {33 public static func preset(named name: String) -> ScriptPreset? { all.first { $0.name == name } }3435 public static let all: [ScriptPreset] = [36 ScriptPreset(name: "Eight Bar Transition", category: .transitions, summary: "Deck A fades out under a rising high-pass while deck B comes in, over eight bars.", source: """37 // Eight Bar Transition38 // Start it while deck A plays and deck B is loaded and cued on its first beat.39 automation "Eight Bar Transition" quantize bar {40 deck.B.sync(true)41 deck.B.volume = -12dB42 deck.A.filter.highpass = 20Hz43 deck.B.play()4445 over 8 bars {46 deck.A.filter.highpass -> 12000Hz47 deck.A.volume -> -60dB48 deck.B.volume -> 0dB49 }5051 deck.A.pause()52 deck.A.filter.highpass = 20Hz53 deck.A.volume = 0dB54 }55 """),56 ScriptPreset(name: "Bass Swap", category: .transitions, summary: "Brings deck B in without its bass, then swaps the low end on the bar.", source: """57 // Bass Swap58 // Two tracks never share the low end: B enters with its bass cut, and the basses swap on bar 5.59 automation "Bass Swap" quantize bar {60 deck.B.sync(true)61 deck.B.eq.low = -26dB62 deck.B.volume = -60dB63 deck.B.play()6465 over 4 bars { deck.B.volume -> 0dB }6667 // The swap, exactly on the bar.68 deck.A.eq.low = -26dB69 deck.B.eq.low = 0dB7071 over 4 bars { deck.A.volume -> -60dB }7273 deck.A.pause()74 deck.A.eq.low = 0dB75 deck.A.volume = 0dB76 }77 """),78 ScriptPreset(name: "Harmonic Transition", category: .transitions, summary: "Long blend that only runs when both tracks have a tempo; mid EQ makes room for the new track.", source: """79 // Harmonic Transition80 // A 16-bar blend for tracks in compatible keys. Check the key display of both decks before starting it.81 automation "Harmonic Transition" quantize bar {82 if deck.A.trackBpm == 0 or deck.B.trackBpm == 0 {83 print("Both decks need an analysed tempo for this transition.")84 stop85 }86 deck.B.sync(true)87 deck.B.keylock = true88 deck.B.volume = -60dB89 deck.B.eq.low = -26dB90 deck.B.play()9192 over 8 bars {93 deck.B.volume -> 0dB94 deck.A.eq.mid -> -6dB95 }96 deck.A.eq.low = -26dB97 deck.B.eq.low = 0dB98 over 8 bars {99 deck.A.volume -> -60dB100 deck.A.eq.high -> -12dB101 }102103 deck.A.pause()104 deck.A.eq.low = 0dB105 deck.A.eq.mid = 0dB106 deck.A.eq.high = 0dB107 deck.A.volume = 0dB108 }109 """),110 ScriptPreset(name: "Smooth Crossfade", category: .crossfades, summary: "Moves the crossfader from A to B over eight bars with a smooth curve.", source: """111 // Smooth Crossfade112 automation "Smooth Crossfade" quantize bar {113 mixer.curve = "smooth"114 mixer.crossfader = 0115 deck.B.sync(true)116 deck.B.play()117 over 8 bars curve smooth { mixer.crossfader -> 1 }118 deck.A.pause()119 }120 """),121 ScriptPreset(name: "Quick Cut", category: .crossfades, summary: "Cuts from A to B on the next bar.", source: """122 // Quick Cut123 automation "Quick Cut" {124 mixer.curve = "cut"125 deck.B.sync(true)126 wait nextBar127 deck.B.play()128 mixer.crossfader = 1129 deck.A.pause()130 }131 """),132 ScriptPreset(name: "Filter Sweep", category: .filters, summary: "Opens a high-pass on deck A over four bars and snaps it back on the bar.", source: """133 // Filter Sweep134 automation "Filter Sweep" quantize bar {135 deck.A.filter.resonance = 2136 over 4 bars curve easeIn { deck.A.filter.highpass -> 6kHz }137 deck.A.filter.highpass = 20Hz138 deck.A.filter.resonance = 0.9139 }140 """),141 ScriptPreset(name: "Low-Pass Dive", category: .filters, summary: "Closes a low-pass on the master for two bars, then releases it.", source: """142 // Low-Pass Dive143 automation "Low-Pass Dive" quantize bar {144 fx.lowpass.cutoff = 20kHz145 fx.lowpass.resonance = 1.5146 fx.lowpass.enable()147 over 2 bars curve easeOut { fx.lowpass.cutoff -> 250Hz }148 over 1 bar curve easeIn { fx.lowpass.cutoff -> 20kHz }149 fx.lowpass.disable()150 }151 """),152 ScriptPreset(name: "Echo Out", category: .echo, summary: "Throws deck A into a three-quarter-beat echo and lets the tail carry the exit.", source: """153 // Echo Out154 automation "Echo Out" quantize bar {155 deck.A.fx.echo.time = 3/4beat156 deck.A.fx.echo.feedback = 0.6157 deck.A.fx.echo.mix = 0158 deck.A.fx.echo.enable()159 over 2 beats { deck.A.fx.echo.mix -> 0.6 }160 wait 2 beats161 // Stop the deck; the echo keeps repeating what it already holds.162 deck.A.pause()163 over 2 bars { deck.A.fx.echo.feedback -> 0.2 }164 deck.A.fx.echo.disable()165 }166 """),167 ScriptPreset(name: "Dub Echo Throw", category: .echo, summary: "A one-beat echo throw on the last beat of the bar.", source: """168 // Dub Echo Throw169 automation "Dub Echo Throw" quantize bar {170 fx.echo.time = 1/2beat171 fx.echo.feedback = 0.7172 fx.echo.tone = 2500Hz173 fx.echo.mix = 0174 fx.echo.enable()175 wait 3 beats176 fx.echo.mix = 0.8177 wait 1 beat178 fx.echo.mix = 0179 wait 2 bars180 fx.echo.disable()181 }182 """),183 ScriptPreset(name: "Reverb Wash", category: .reverb, summary: "Swells a large reverb over two bars, then cuts it dry on the bar.", source: """184 // Reverb Wash185 automation "Reverb Wash" quantize bar {186 fx.reverb.size = 0.85187 fx.reverb.damping = 0.3188 fx.reverb.mix = 0189 fx.reverb.enable()190 over 2 bars curve easeIn { fx.reverb.mix -> 0.7 }191 fx.reverb.mix = 0192 fx.reverb.disable()193 }194 """),195 ScriptPreset(name: "Beat Repeat", category: .beatEffects, summary: "Repeats the last quarter beat for one bar, halving the slice every beat.", source: """196 // Beat Repeat197 automation "Beat Repeat" quantize beat {198 let slices = [1/4beat, 1/8beat, 1/8beat, 1/16beat]199 for slice in slices {200 fx.beatrepeat.length = slice201 fx.beatrepeat.enable()202 wait 1 beat203 fx.beatrepeat.disable()204 }205 }206 """),207 ScriptPreset(name: "Gate Pattern", category: .beatEffects, summary: "A sixteenth-note gate on deck A for two bars.", source: """208 // Gate Pattern209 automation "Gate Pattern" quantize bar {210 deck.A.fx.gate.rate = 1/4beat211 deck.A.fx.gate.duty = 0.5212 deck.A.fx.gate.depth = 1213 deck.A.fx.gate.enable()214 wait 2 bars215 deck.A.fx.gate.disable()216 }217 """),218 ScriptPreset(name: "Progressive Build-up", category: .buildUps, summary: "Eight bars of rising high-pass, noise riser and reverb, released on the drop.", source: """219 // Progressive Build-up220 automation "Progressive Build-up" quantize bar {221 fx.noise.level = -60dB222 fx.noise.cutoff = 400Hz223 fx.noise.enable()224 fx.reverb.mix = 0225 fx.reverb.size = 0.7226 fx.reverb.enable()227228 over 8 bars curve easeIn {229 deck.A.filter.highpass -> 900Hz230 fx.noise.level -> -14dB231 fx.noise.cutoff -> 9kHz232 fx.reverb.mix -> 0.35233 }234235 // The drop: everything back at once, on the bar.236 deck.A.filter.highpass = 20Hz237 fx.noise.disable()238 fx.reverb.mix = 0239 fx.reverb.disable()240 }241 """),242 ScriptPreset(name: "Snare Roll Build", category: .buildUps, summary: "Loop roll that halves every two beats, from one beat down to an eighth.", source: """243 // Snare Roll Build244 automation "Snare Roll Build" quantize bar {245 deck.A.loop(1beat)246 wait 2 beats247 deck.A.loopHalve()248 wait 2 beats249 deck.A.loopHalve()250 wait 2 beats251 deck.A.loopHalve()252 wait 2 beats253 deck.A.loopExit()254 }255 """),256 ScriptPreset(name: "Drop Preparation", category: .drops, summary: "Kills the bass for the last bar before the drop and brings it back on the one.", source: """257 // Drop Preparation258 automation "Drop Preparation" quantize bar {259 wait 3 bars260 deck.A.eq.low = -26dB261 over 1 bar { deck.A.filter.highpass -> 400Hz }262 deck.A.eq.low = 0dB263 deck.A.filter.highpass = 20Hz264 }265 """),266 ScriptPreset(name: "Tape Stop Drop", category: .drops, summary: "Brakes deck A over one beat and starts deck B on the next bar.", source: """267 // Tape Stop Drop268 automation "Tape Stop Drop" {269 deck.B.sync(true)270 wait until bar 2271 at bar 2 {272 wait 3 beats273 deck.A.brake(1beat)274 }275 wait until bar 3276 deck.B.play()277 }278 """),279 ScriptPreset(name: "Loop Roll", category: .loops, summary: "Four-beat loop on deck A that tightens to a quarter beat, then releases.", source: """280 // Loop Roll281 automation "Loop Roll" quantize bar {282 deck.A.loop(4beats)283 wait 1 bar284 repeat 4 {285 deck.A.loopHalve()286 wait 2 beats287 }288 deck.A.loopExit()289 }290 """),291 ScriptPreset(name: "Loop and Hold", category: .loops, summary: "Holds an eight-beat loop on deck A until trigger 1 is fired.", source: """292 // Loop and Hold293 // Fire trigger 1 (a MIDI pad, the keyboard, or 'trigger 1' in the console) to leave the loop.294 automation "Loop and Hold" quantize bar {295 deck.A.loop(8beats)296 on trigger(1) once {297 deck.A.loopExit()298 stop299 }300 }301 """),302 ScriptPreset(name: "Auto DJ Blend", category: .autoDJ, summary: "The transition Auto DJ uses by default: sync, bass swap and a sixteen-bar blend.", source: """303 // Auto DJ Blend304 // Auto DJ generates this script with the two decks and the length it needs; this copy goes from A to B.305 fn blend(from: deck, to: deck, length: duration) {306 to.sync(true)307 to.volume = -60dB308 to.eq.low = -26dB309 to.play()310 over length / 2 { to.volume -> 0dB }311 from.eq.low = -26dB312 to.eq.low = 0dB313 over length / 2 { from.volume -> -60dB }314 from.pause()315 from.eq.low = 0dB316 from.volume = 0dB317 }318319 automation "Auto DJ Blend" quantize bar {320 blend(deck.A, deck.B, 16bars)321 }322 """),323 ScriptPreset(name: "Play Next on Track End", category: .autoDJ, summary: "Starts deck B the moment deck A reaches the end of its track.", source: """324 // Play Next on Track End325 automation "Play Next on Track End" {326 on deck.A.trackEnd once {327 deck.B.play()328 stop329 }330 }331 """),332 ScriptPreset(name: "Stutter Cut", category: .creative, summary: "Chops deck A's fader in eighths for one bar.", source: """333 // Stutter Cut334 automation "Stutter Cut" quantize bar {335 var open = false336 every 1/2beat for 1 bar {337 if open { deck.A.volume = 0dB } else { deck.A.volume = -60dB }338 open = not open339 }340 deck.A.volume = 0dB341 }342 """),343 ScriptPreset(name: "Ping-Pong Delay Ride", category: .creative, summary: "A ping-pong delay whose feedback and mix rise for four bars and then drop out.", source: """344 // Ping-Pong Delay Ride345 automation "Ping-Pong Delay Ride" quantize bar {346 fx.delay.time = 3/4beat347 fx.delay.pingpong = true348 fx.delay.feedback = 0.2349 fx.delay.mix = 0.1350 fx.delay.enable()351 over 4 bars {352 fx.delay.feedback -> 0.75353 fx.delay.mix -> 0.5354 }355 fx.delay.mix = 0356 wait 1 bar357 fx.delay.disable()358 }359 """),360 ScriptPreset(name: "Four Deck Layering", category: .creative, summary: "Brings decks C and D in under A and B one after the other, four bars apart.", source: """361 // Four Deck Layering362 automation "Four Deck Layering" quantize bar {363 let layers = [-9dB, -12dB]364 deck.C.sync(true)365 deck.D.sync(true)366 deck.C.volume = -60dB367 deck.D.volume = -60dB368 deck.C.play()369 over 4 bars { deck.C.volume -> layers[0] }370 deck.D.play()371 over 4 bars { deck.D.volume -> layers[1] }372 }373 """),374 ScriptPreset(name: "Beat Counter", category: .creative, summary: "Prints the bar number of the master clock; a starting point for event-driven scripts.", source: """375 // Beat Counter376 // Runs until you stop it.377 automation "Beat Counter" {378 var count = 0379 on bar {380 count = count + 1381 print("bar", count, "at", master.bpm, "BPM")382 }383 }384 """),385 ]386}387