SPB Git

Repository Public

patch_drum_machine.sonata 2.0 KB 78 lines

1// ORIX Sonata2// File: Examples/patch_drum_machine.sonata3// Description: A drum machine built entirely from patch graphs: a sine kick with a pitch envelope, a noise snare through a band-pass and a metallic hat from two detuned squares.4//5// Author: Simon-Pierre Boucher6// Contact: contact@spboucher.ai7//8// expect: notes 969// expect: tracks 310// expect: duration 8.1356s11// expect: deterministic12instrument PatchKick {13    model patch14    release 300ms15    graph {16        node amp = adsr(attack: 0ms, decay: 260ms, sustain: 0, release: 80ms)17        node drop = adsr(attack: 0ms, decay: 45ms, sustain: 0, release: 20ms)18        node body = sine(freq: 48Hz + drop * 170)19        out saturate(in: body * amp, drive: 2) * 0.820    }21}2223instrument PatchSnare {24    model patch25    release 250ms26    graph {27        node amp = adsr(attack: 0ms, decay: 140ms, sustain: 0, release: 60ms)28        node tone = sine(freq: 190Hz) * 0.429        node rattle = bandpass(in: noise(), cutoff: 2400Hz, q: 0.8)30        out (tone + rattle) * amp * note.velocity31    }32}3334instrument PatchHat {35    model patch36    release 120ms37    graph {38        node amp = adsr(attack: 0ms, decay: 45ms, sustain: 0, release: 30ms)39        node metal = square(freq: 5400Hz) + square(freq: 8130Hz) * 0.740        out highpass(in: metal, cutoff: 7000Hz) * amp * note.velocity * 0.341    }42}4344composition "Patch Drum Machine" {45    tempo 118bpm4647    instrument kick: PatchKick {48        gain 0dB49        repeat 4 {50            rhythm(C2, euclid(5, 16), step: 1/16, vel: 0.9)51        }52    }5354    instrument snare: PatchSnare {55        gain -2dB56        repeat 4 {57            rest 1/458            play C3 duration 1/459            rest 3/1660            play C3 duration 1/16 velocity 0.561            play C3 duration 1/462        }63        effects {64            reverb room(mix: 0.15)65        }66    }6768    instrument hat: PatchHat {69        gain -5dB70        pan 0.371        repeat 4 {72            for i in 0..16 {73                play C4 duration 1/16 velocity if i % 2 == 0 then 0.8 else 0.474            }75        }76    }77}78
Files main
Menu

Theme