SPB Git

Repository Public

st_stepped_sweep.sonata 1.6 KB 62 lines

1// ORIX Sonata2// File: Examples/st_stepped_sweep.sonata3// Description: A measurement sweep in steps: a sine at every third-octave from 62.5 Hz to 8 kHz, a quarter of a second each, played twice — once flat, once through an equaliser — to trace a frequency response by reading the levels.4//5// Author: Simon-Pierre Boucher6// Contact: contact@spboucher.ai7//8// category: Studies9// title: Stepped Sweep10// teaches: computing frequencies with pow(), microtonal pitches from ratios, the oscillator of the synth engine as a sine source11//12// expect: notes 4413// expect: tracks 214// expect: duration 12.0000s15// expect: deterministic16instrument PureSine {17    model synth18    osc1.wave sine19    osc2.level 020    sub.level 021    unison 122    filter.cutoff 20000Hz23    filter.env_amount 024    filter.keytrack 025    envelope adsr(attack: 10ms, decay: 0ms, sustain: 1, release: 10ms)26}2728// The pitch whose frequency is `ratio` times that of `base`.29fn times(base: Pitch, ratio: Number) -> Pitch {30    return base + 1200cents * (ln(ratio) / ln(2))31}3233pattern sweep() {34    // 1000 Hz is A4 (440 Hz) times 1000/440; third-octave steps are factors of 2^(1/3).35    for k in -12..=9 {36        play times(A4, 1000/440 * pow(2, k / 3)) duration 1/16 velocity 0.637    }38}3940composition "Stepped Sweep" {41    tempo 60bpm4243    instrument flat: PureSine {44        gain -6dB45        sweep()46        rest 1/447    }4849    instrument shaped: PureSine {50        gain -6dB51        rest 1/16 * 22 + 1/452        sweep()53        effects {54            eq(low_cut: 200Hz, mid2_freq: 2000Hz, mid2_gain: 9dB, mid2_q: 2, high_cut: 8000Hz)55        }56    }5758    master {59        peak_limit off60    }61}62
Files main
Menu

Theme