# Main Title (Terminator 2 Theme) by Brad Fiedel - https://lab.glossema.dev/play/judgement-day/code # It plays the notes of https://lab.glossema.dev/play/judgement-day, tone for tone. # The opening of the main title of Terminator 2: Judgment Day (1991): four bars of the ostinato # alone, then the theme's first statement over it, and one last bar of the arrangement's own. # Here it runs as a step sequencer on one speaker: 24 steps to the bar, six to the beat, a unit # of 87 ms that broadens to 88 for the close. The ostinato is a pattern of hits on D3, the tune # a lane of note letters an octave above the film's. A hit takes the front of the tune's slot, # and the tune sounds on for the rest. { # the ostinato: a hit on each x of the bar's 24 steps. # The intro plays the same figure, cut after five hits :local ostinato "x.x...x...x.x...x...x..." :local intro ([:pick $ostinato 0 13] . "...........") # the tune's notes in Hz, one letter each: capitals D4 to G4, small letters C5 to A5. # A lane has a character a step: a letter where a note begins, a dash (0) where none does :local notes {"-"=0; "D"=294; "E"=330; "F"=349; "G"=392; "c"=523; "d"=587; "e"=659; "f"=698; "g"=784; "a"=880} # under the intro the tune is silent :local silence "------------------------" # the theme: three phrases climb D, E, F from the same two written bars and end apart, # on the low F held, on A stepping down to G, on the low G held :local opening {"d--e--f-----------------"; "------------e-------c---"} :local endings { {"F-----------------------"; "------------------------"}; {"a-----------------------"; "g-----------------------"}; {"G-----------------------"; "------------------------"} } # the close sinks back towards D: the low F held into a short D, then F and E :local close {"F-----------------------"; "--------------------D---"; "F-----------------------"; "E-----------------------"} # share: the hit, paid out of the tune's slot. It sounds 30 ms and takes 40, # and the tune has the rest: a note that begins here, the held note struck again, or silence under the intro :local share do={ :local rest ($span - 40ms) :beep frequency=147 length=30ms :delay 40ms :if ($new > 0) do={ :beep frequency=$new length=$rest } else={ :if ($held > 0) do={ :beep frequency=$held length=$rest } } :delay $rest } # the form: each part's line on the terminal, its unit, its hits and its bars of tune :local form { {title="Ostinato"; unit=87ms; hits=$intro; bars={$silence; $silence; $silence; $silence}}; {title="Theme, phrase 1 of 3"; unit=87ms; hits=$ostinato; bars=($opening, ($endings->0))}; {title="Theme, phrase 2 of 3"; unit=87ms; hits=$ostinato; bars=($opening, ($endings->1))}; {title="Theme, phrase 3 of 3"; unit=87ms; hits=$ostinato; bars=($opening, ($endings->2))}; {title="Close"; unit=88ms; hits=$ostinato; bars=$close} } # the scheduler walks each bar step by step, keeping the tune's sounding note :local held 0 :foreach part in=$form do={ :put ($part->"title") :local unit ($part->"unit") :local hits ($part->"hits") :foreach tune in=($part->"bars") do={ :local steps [:len $tune] :for step from=0 to=($steps - 1) do={ :local hit ([:pick $hits $step] = "x") :local new ($notes->[:pick $tune $step]) :if ($hit || ($new > 0)) do={ # the slot runs to the next hit, the next note or the bar line :local next $steps :local ahead ($step + 1) :while ($ahead < $next) do={ :if (([:pick $hits $ahead] = "x") || ([:pick $tune $ahead] != "-")) do={ :set next $ahead } :set ahead ($ahead + 1) } :local span ($unit * ($next - $step)) :if ($hit) do={ $share new=$new held=$held span=$span } else={ # a note with no hit in front has its whole slot :beep frequency=$new length=$span :delay $span } :if ($new > 0) do={ :set held $new } } } } } # the arrangement's own last bar: one more hit, and the tune steps down to D4 for 1.5 s $share new=($notes->"D") span=1540ms }