SPB Git

Repository Public

pc_chiptune.sonata 3.0 KB 118 lines

1// ORIX Sonata2// File: Examples/pc_chiptune.sonata3// Description: An 8-bit style tune from four custom voices on the synth engine: two pulse waves with different duty cycles, a triangle bass and noise drums, with fast arpeggios faking chords the way old sound chips did.4//5// Author: Simon-Pierre Boucher6// Contact: contact@spboucher.ai7//8// category: Pieces9// title: Chiptune10// teaches: synth engine from scratch, pulse width, noise as percussion, fast arpeggios, bitcrusher on the master11//12// expect: notes 43613// expect: tracks 414// expect: duration 12.8000s15// expect: deterministic16instrument Pulse50 {17    model synth18    osc1.wave pulse19    pulse_width 0.520    osc2.level 021    sub.level 022    unison 123    filter.cutoff 20000Hz24    filter.env_amount 025    envelope adsr(attack: 1ms, decay: 50ms, sustain: 0.8, release: 30ms)26}2728instrument Pulse25: Pulse50 {29    pulse_width 0.2530}3132instrument TriBass: Pulse50 {33    osc1.wave triangle34}3536instrument NoiseHit: Pulse50 {37    osc1.level 038    noise.level 139    envelope adsr(attack: 0ms, decay: 60ms, sustain: 0, release: 30ms)40}4142// A chord as a fast arpeggio: one voice, three notes.43pattern fake_chord(notes: Chord, length: Duration) {44    let count = length / note_value(1/32)45    for i in 0..count {46        play notes[i % len(notes)] duration 1/3247    }48}4950composition "Chiptune" {51    tempo 150bpm52    key C major5354    instrument lead: Pulse25 {55        gain -12dB56        pan -0.257        repeat 2 {58            for n in [E5, G5, C6, G5, E5, G5, D5, G5] {59                play n duration 1/860            }61            for n in [F5, A5, C6, A5, D5, G5, B5, D6] {62                play n duration 1/863            }64            play C6 duration 1/465            play B5 duration 1/866            play A5 duration 1/867            play G5 duration 1/468            play E5 duration 1/469            play F5 duration 1/870            play G5 duration 1/871            play A5 duration 1/872            play B5 duration 1/873            play C6 duration 1/274        }75    }7677    instrument chords: Pulse50 {78        gain -16dB79        pan 0.280        repeat 2 {81            fake_chord([C4, E4, G4], 1/1)82            fake_chord([F4, A4, C5], 1/2)83            fake_chord([G4, B4, D5], 1/2)84            fake_chord([A3, C4, E4], 1/1)85            fake_chord([F3, A3, C4], 1/2)86            fake_chord([G3, B3, D4], 1/2)87        }88    }8990    instrument bass: TriBass {91        gain -7dB92        repeat 2 {93            for root in [C2, C2, F2, G2, A2, A2, F2, G2] {94                play root duration 1/895                play root + 12st duration 1/896                play root duration 1/897                play root + 12st duration 1/898            }99        }100    }101102    instrument drums: NoiseHit {103        gain -14dB104        repeat 16 {105            play C3 duration 1/8 velocity 0.9106            play C6 duration 1/8 velocity 0.3107            play C5 duration 1/8 velocity 0.7108            play C6 duration 1/8 velocity 0.3109        }110    }111112    master {113        effects {114            bitcrusher(bits: 8, downsample: 2, mix: 0.6)115        }116    }117}118
Files main
Menu

Theme