SPB Git

Repository Public

baroque_invention.sonata 1.7 KB 73 lines

1// ORIX Sonata2// File: Examples/baroque_invention.sonata3// Description: A two-part invention for harpsichord: one subject, imitated at the octave below, sequenced through the circle of fifths by a function.4//5// Author: Simon-Pierre Boucher6// Contact: contact@spboucher.ai7//8// expect: notes 1879// expect: tracks 210// expect: duration 24.2857s11// expect: deterministic12// The subject as intervals above its first note.13const subject = [0st, 2st, 4st, 5st, 7st, 4st, 5st, 2st]1415fn subject_on(root: Pitch) -> List<Pitch> {16    let notes = []17    for i in subject {18        notes = notes + [root + i]19    }20    return notes21}2223pattern run(root: Pitch) {24    for n in subject_on(root) {25        play n duration 1/1626    }27}2829pattern answer(root: Pitch) {30    play root duration 1/8 staccato31    play root + 7st duration 1/8 staccato32    play root + 4st duration 1/8 staccato33    play root + 7st duration 1/8 staccato34}3536composition "Baroque Invention" {37    tempo 84bpm38    key C major3940    // Each step of the sequence: the upper part's root, falling by fifths.41    let steps = [C5, F4, Bb4, E4, A4, D4, G4, C4]4243    instrument right: Harpsichord {44        gain -8dB45        pan 0.246        for s in steps {47            run(s)48            answer(s + 7st)49        }50        chord [E4, G4, C5] duration 1/251    }5253    instrument left: Harpsichord {54        gain -9dB55        pan -0.256        // The imitation enters half a bar late, an octave lower.57        rest 1/258        for s in take(steps, 7) {59            run(s - 12st)60            answer(s - 5st)61        }62        play G2 duration 1/463        play G3 duration 1/464        chord [C2, C3] duration 1/265    }6667    master {68        effects {69            reverb chamber(mix: 0.18)70        }71    }72}73
Files main
Menu

Theme