Repository Public
1// ORIX Sonata2// File: Examples/chords_and_rhythm.sonata3// Description: Functions, chords, patterns, a swung comping figure and a walking bass over a ii–V–I.4//5// Author: Simon-Pierre Boucher6// Contact: contact@spboucher.ai7//8// expect: notes 1289// expect: tracks 310// expect: duration 14.5455s11// expect: deterministic12// A ii–V–I in the given major key, as [root, quality] pairs resolved to chords.13fn two_five_one(tonic: Pitch) -> List<Chord> {14 return [chord(tonic + 2st, min7), chord(tonic + 7st, dom7), chord(tonic, maj7), chord(tonic, maj7)]15}1617// Shell voicing: root, third and seventh, the seventh dropped an octave when it is high.18fn shell(notes: Chord) -> Chord {19 let seventh = notes[3]20 return [notes[0], notes[1], if seventh > C5 then seventh - 12st else seventh]21}2223pattern comp(notes: Chord) {24 rest 1/825 chord notes duration 1/8 staccato velocity 0.5526 rest 1/427 chord notes duration 3/8 velocity 0.628 rest 1/829}3031pattern walk(notes: Chord) {32 play notes[0] - 12st duration 1/4 velocity 0.833 play notes[1] - 12st duration 1/4 velocity 0.6534 play notes[2] - 12st duration 1/4 velocity 0.735 play notes[0] - 12st + choose([1st, 2st, 11st]) duration 1/4 velocity 0.636}3738composition "Chords and Rhythm" {39 tempo 132bpm40 key C major41 seed 742 swing 62%4344 instrument keys: ElectricPiano {45 gain -9dB46 repeat 2 {47 for c in two_five_one(C4) {48 comp(shell(c))49 }50 }51 effects {52 chorus lush(mix: 0.3)53 reverb room(mix: 0.15)54 }55 }5657 instrument bass: FingerBass {58 gain -6dB59 repeat 2 {60 for c in two_five_one(C3) {61 walk(c)62 }63 }64 }6566 instrument ride: Ride {67 gain -16dB68 pan 0.2569 repeat 8 {70 play C4 duration 1/4 velocity 0.571 play C4 duration 1/8 velocity 0.3572 play C4 duration 1/8 velocity 0.4573 play C4 duration 1/4 velocity 0.574 play C4 duration 1/8 velocity 0.3575 play C4 duration 1/8 velocity 0.4576 }77 }78}79