Repository Public
1// ORIX Sonata2// File: Examples/gs_major_scale.sonata3// Description: The simplest loop: a C major scale up and down on the piano, built with scale() and a for loop.4//5// Author: Simon-Pierre Boucher6// Contact: contact@spboucher.ai7//8// category: Getting started9// title: Major Scale10// teaches: for loops, scale(), lists, reverse()11//12// expect: notes 3213// expect: tracks 114// expect: duration 12.3000s15// expect: deterministic16composition "Major Scale" {17 tempo 100bpm18 key C major1920 instrument piano: GrandPiano {21 gain -4dB22 // scale() gives the seven notes of one octave; add the octave to close it.23 let up = scale(C4, major) + [C5]24 for n in up {25 play n duration 1/826 }27 for n in drop(reverse(up), 1) {28 play n duration 1/829 }30 play C4 duration 1/231 rest 1/432 // The same scale in thirds.33 for i in 0..6 {34 play [up[i], up[i + 2]] duration 1/435 }36 chord [C4, E4, G4, C5] duration 1/137 }38}39