# Battle City: the stage-start fanfare (NES, Namco 1985), for one speaker # https://lab.glossema.dev/play/battle-city # Tuning: equal temperament, A4 = 440 Hz, rounded to whole hertz :global notes {"C5"=523; "D5"=587; "Eb5"=622; "F5"=698; "G5"=784; "A5"=880; "Ab5"=831; "Bb5"=932; "C6"=1047}; # Clock: 120 beats per minute; every note of the figure is a sixteenth, the held notes a dotted eighth :local beat 500ms; :local sixteenth ($beat / 4); :local held ($sixteenth * 3); :local dur {"s"=$sixteenth; "h"=$held}; :global gap 20ms; # Voice: one note, then the clock; the gap after each beep lets the repeated notes articulate :global play do={ :global notes; :global gap; :beep frequency=($notes->$1) length=($2 - $gap); :delay $2; } # Score: the rising figure (four steps, each sounded twice), the held note, three march steps, the stop :local melody { "C5:s"; "D5:s"; "Eb5:s"; "C5:s"; "D5:s"; "Eb5:s"; "Eb5:s"; "F5:s"; "G5:s"; "Eb5:s"; "F5:s"; "G5:s"; "F5:s"; "G5:s"; "A5:s"; "F5:s"; "G5:s"; "A5:s"; "Ab5:s"; "Bb5:s"; "C6:s"; "Ab5:s"; "Bb5:s"; "C6:s"; "C6:h"; "C6:s"; "C6:s"; "C6:s"; "C6:h" }; # Performance: twice, a full second of silence between, as the game did on the next stage :put "Stage"; :for stage from=1 to=2 do={ :if ($stage > 1) do={ :delay 1000ms }; :foreach step in=$melody do={ :local colon [:find $step ":"]; :local name [:pick $step 0 $colon]; :local len [:pick $step ($colon + 1) [:len $step]]; $play $name ($dur->$len); } }