Repository Public
1// ORIX Sonata2// File: Examples/st_shepard.sonata3// Description: A Shepard scale: six octaves of the same pitch class sound together, loudest in the middle and fading at both ends, so the scale seems to climb forever while actually returning to where it began every twelve steps.4//5// Author: Simon-Pierre Boucher6// Contact: contact@spboucher.ai7//8// category: Studies9// title: Endless Ascent10// teaches: parallel blocks with per-note velocity, a bell-shaped loudness curve with exp(), auditory illusions11//12// expect: notes 51113// expect: tracks 114// expect: duration 20.4000s15// expect: deterministic16instrument PureSine {17 model synth18 osc1.wave sine19 osc2.level 020 sub.level 021 unison 122 filter.cutoff 20000Hz23 filter.env_amount 024 envelope adsr(attack: 30ms, decay: 0ms, sustain: 1, release: 60ms)25}2627// Loudness of a component at MIDI pitch `m`: a bell curve centred on middle C sharp.28fn weight(m: Number) -> Number {29 let d = (m - 61) / 1430 return exp(-d * d)31}3233// One step: the pitch class `pc` in six octaves at once.34pattern shepard_tone(pc: Number, length: Duration) {35 parallel {36 play midi(24 + pc) duration length velocity weight(24 + pc)37 play midi(36 + pc) duration length velocity weight(36 + pc)38 play midi(48 + pc) duration length velocity weight(48 + pc)39 play midi(60 + pc) duration length velocity weight(60 + pc)40 play midi(72 + pc) duration length velocity weight(72 + pc)41 play midi(84 + pc) duration length velocity weight(84 + pc)42 play midi(96 + pc) duration length velocity weight(96 + pc)43 }44}4546composition "Endless Ascent" {47 tempo 100bpm4849 instrument tones: PureSine {50 gain -5dB51 // Four trips around the twelve pitch classes: it never arrives.52 repeat 4 {53 for pc in 0..12 {54 shepard_tone(pc, 1/8)55 }56 }57 // And down again, faster.58 repeat 2 {59 for pc in reverse(0..12) {60 shepard_tone(pc, 1/16)61 }62 }63 shepard_tone(0, 1/1)64 effects {65 reverb room(mix: 0.15)66 }67 }68}69