Repository Public
1// ORIX Sonata2// File: Examples/lang_module_drumkit.sonata3// Description: Splitting a project into files: the drum patterns live in lib/drumkit.sonata and are imported here, where the form of the piece is a table of sections that decides which variation each bar plays.4//5// Author: Simon-Pierre Boucher6// Contact: contact@spboucher.ai7//8// category: Language9// title: A Module of Your Own10// teaches: import of a project module, patterns with default parameters, a form described as data11//12// expect: notes 17613// expect: tracks 414// expect: duration 19.2000s15// expect: deterministic16import lib.drumkit1718// Each section: [bars, kick variation, ghost notes (0 or 1), hat division].19const form = [[2, 0, 0, 8], [2, 1, 1, 8], [2, 1, 1, 16], [2, 2, 1, 16]]20const kicks = [[0, 8], [0, 6, 8], [0, 3, 6, 10, 13]]2122composition "A Module of Your Own" {23 tempo 100bpm24 key E minor2526 instrument kick: Kick {27 gain -3dB28 for section in form {29 repeat section[0] {30 kick_on(kicks[section[1]])31 }32 }33 }3435 instrument snare: Snare {36 gain -7dB37 for section in form {38 repeat section[0] {39 backbeat(ghost: section[2] == 1)40 }41 }42 }4344 instrument hat: ClosedHat {45 gain -14dB46 pan 0.347 for section in form {48 repeat section[0] {49 hats(division: section[3], accent_every: if section[3] == 16 then 4 else 2)50 }51 }52 }5354 instrument bass: PickBass {55 gain -5dB56 // total_bars() comes from the module too.57 repeat total_bars([2, 2, 2, 2]) / 2 {58 play E2 duration 3/859 play E2 duration 1/8 velocity 0.660 play G2 duration 1/461 play A2 duration 1/462 play B2 duration 3/863 play A2 duration 1/8 velocity 0.664 play G2 duration 1/465 play D2 duration 1/466 }67 }68}69