SPB Git

Repository Public

al_arpeggiator.sonata 2.2 KB 80 lines

1// ORIX Sonata2// File: Examples/al_arpeggiator.sonata3// Description: A parameterised arpeggiator pattern with five modes (up, down, up-down, inside-out, random) and an octave range, driving a synth pluck through four chords.4//5// Author: Simon-Pierre Boucher6// Contact: contact@spboucher.ai7//8// category: Algorithmic9// title: Arpeggiator10// teaches: patterns with parameters and defaults, string parameters, if chains, shuffle()11//12// expect: notes 34413// expect: tracks 214// expect: duration 40.6452s15// expect: deterministic16// The notes of `c` over `octaves` octaves, ordered by `mode`.17fn arp_order(c: Chord, octaves: Number, mode: String) -> List<Pitch> {18    let all = []19    for o in 0..octaves {20        all = all + (c + 12st * o)21    }22    if mode == "down" {23        return reverse(all)24    }25    if mode == "updown" {26        return up_down(all)27    }28    if mode == "inside" {29        let acc = []30        for i in 0..len(all) {31            let k = if i % 2 == 0 then floor(i / 2) else len(all) - 1 - floor(i / 2)32            acc = acc + [all[k]]33        }34        return acc35    }36    if mode == "random" {37        return shuffle(all)38    }39    return all40}4142pattern arp(c: Chord, mode: String = "up", octaves: Number = 2, steps: Number = 16, step: Duration = 1/16) {43    let order = arp_order(c, octaves, mode)44    for i in 0..steps {45        play order[i % len(order)] duration step velocity if i % 4 == 0 then 0.8 else 0.5546    }47}4849composition "Arpeggiator" {50    tempo 124bpm51    key E minor52    seed 115354    let chords = [chord(E3, min7), chord(C3, maj7), chord(A2, min7), chord(B2, dom7)]5556    instrument pluck: SynthPluck {57        gain -8dB58        for mode in ["up", "down", "updown", "inside", "random"] {59            for c in chords {60                arp(c, mode: mode)61            }62        }63        play [E3, B3, E4] duration 1/164        effects {65            delay echo(time: note_value(3/16), feedback: 0.4, mix: 0.25, mode: ping_pong)66            reverb plate(mix: 0.15)67        }68    }6970    instrument bass: SubBass {71        gain -7dB72        repeat 5 {73            for c in chords {74                play c[0] - 12st duration 1/175            }76        }77        play E1 duration 1/178    }79}80
Files main
Menu

Theme