# Gran Vals (Francisco Tarrega, 1902), the waltz behind the Nokia tune: a score for one speaker # https://lab.glossema.dev/play/gran-vals # A major. The phone rings at 180 bpm; the waltz turns at 143, light on two and three. :local phone 334ms; :local waltz 420ms; :global notes { "E3"=165; "F#3"=185; "G#3"=208; "A3"=220; "B3"=247; "C#4"=277; "D4"=294; "D#4"=311; "E4"=330; "F#4"=370; "G#4"=415; "A4"=440; "B4"=494; "C#5"=554; "D5"=587; "D#5"=622; "E5"=659; "F#5"=740 }; # a duration is counted in eighths: e q h d; p is a quarter that only taps, the pah of the waltz :global eighths {"e"=1; "q"=2; "h"=4; "d"=6; "p"=2}; # $play "NOTE:dur" beat sounds one note against the given beat; "-" is a rest :global play do={ :global notes; :global eighths; :local cut [:find $1 ":"]; :local note [:pick $1 0 $cut]; :local key [:pick $1 ($cut + 1) [:len $1]]; :local slot (($2 / 2) * ($eighths->$key)); :local len ($slot - 30ms); :if ($key = "p") do={ :set len ($slot / 3); } :if ($note != "-") do={ :beep frequency=($notes->$note) length=$len; } :delay $slot; } # Ring: the thirteen notes, as the phone said them :put "Ring"; :local ring { "E5:e"; "D5:e"; "F#4:q"; "G#4:q"; "C#5:e"; "B4:e"; "D4:q"; "E4:q"; "B4:e"; "A4:e"; "C#4:q"; "E4:q"; "A4:d" }; :foreach n in=$ring do={ $play $n $phone; } # Waltz: the first strain, one line per bar, the phrase arriving as its last four bars :put "Waltz"; :local strain { "-:h"; "E4:q"; "E4:q"; "C#4:p"; "C#4:p"; "F#4:q"; "C#4:p"; "C#4:p"; "F#4:q"; "C#4:p"; "C#4:p"; "G#4:q"; "C#4:p"; "C#4:p"; "G#4:h"; "A4:q"; "A4:h"; "G#4:q"; "F#4:q"; "D4:p"; "D4:p"; "B3:q"; "C#4:q"; "D4:q"; "F#4:q"; "D4:p"; "D4:p"; "G#4:h"; "A4:q"; "C#5:q"; "G#4:p"; "G#4:p"; "B4:q"; "G#4:p"; "G#4:p"; "E5:e"; "D5:e"; "F#4:q"; "G#4:q"; "C#5:e"; "B4:e"; "D4:q"; "E4:q"; "B4:e"; "A4:e"; "C#4:q"; "E4:q"; "E4:d" }; :foreach n in=$strain do={ $play $n $waltz; } # the answering strain, in E: the bass on one, the runs on two and three :local answer { "A3:q"; "E5:e"; "D#5:e"; "F#5:e"; "E5:e"; "C#5:q"; "G#4:p"; "G#4:p"; "E3:e"; "B3:e"; "E4:e"; "G#4:e"; "E4:e"; "G#4:e"; "A4:q"; "D#4:p"; "D#4:p"; "B3:q"; "F#5:e"; "D#5:e"; "E5:e"; "C#5:e"; "E5:q"; "A4:p"; "A4:p"; "B3:q"; "D#5:e"; "B4:e"; "C#5:e"; "A4:e"; "C#5:q"; "G#4:p"; "G#4:p"; "E3:q"; "E5:e"; "D#5:e"; "F#5:e"; "E5:e"; "C#5:q"; "G#4:p"; "G#4:p"; "E3:e"; "G#3:e"; "B3:e"; "E4:e"; "G#4:e"; "B4:e"; "B4:q"; "C#4:p"; "C#4:p"; "A3:e"; "F#3:e"; "G#3:e"; "A3:e"; "B3:e"; "C#4:e"; "C#4:q"; "E4:q"; "E5:q"; "D#5:q"; "C#5:q"; "D#4:q"; "E4:q"; "B3:p"; "G#3:p" }; :foreach n in=$answer do={ $play $n $waltz; } # Ring again: a bar of silence, then the phone alone in a pocket :put "Ring again"; :delay ($waltz * 3); :foreach n in=$ring do={ $play $n $phone; }