Repository Public
1// ORIX Sonata2// File: Examples/gs_dynamics.sonata3// Description: One phrase played at six dynamic levels from ppp to fff, then a crescendo computed with lerp(): velocity changes the level and the brightness of the piano.4//5// Author: Simon-Pierre Boucher6// Contact: contact@spboucher.ai7//8// category: Getting started9// title: Soft to Loud10// teaches: velocity, dynamics constants, lerp(), default velocity11//12// expect: notes 4813// expect: tracks 114// expect: duration 12.7778s15// expect: deterministic16composition "Soft to Loud" {17 tempo 108bpm18 key F major1920 instrument piano: GrandPiano {21 gain -3dB22 let phrase = [F4, A4, C5, A4]23 // The standard library names the usual dynamics.24 for level in [ppp, pp, mp, mf, ff, fff] {25 for n in phrase {26 play n duration 1/8 velocity level27 }28 }29 rest 1/430 // A crescendo over sixteen notes, then a subito piano.31 let run = scale_run(F3, major, 2)32 for i in 0..len(run) {33 play run[i] duration 1/16 velocity lerp(0.2, 1.0, i / (len(run) - 1))34 }35 rest 1/1636 default velocity 0.337 chord [F3, C4, F4, A4] duration 1/238 chord [F2, C3, F3, A3, C4] duration 1/1 velocity 0.9539 }40}41