The hammered figure is a pattern of hits, the theme one written opening with three endings, and a scheduler walks every bar step by step, striking the held note again after each hit. It plays the same notes as the notes page, tone for tone.
1# Main Title (Terminator 2 Theme) by Brad Fiedel - https://lab.glossema.dev/play/judgement-day/code2# It plays the notes of https://lab.glossema.dev/play/judgement-day, tone for tone.3# The opening of the main title of Terminator 2: Judgment Day (1991): four bars of the ostinato4# alone, then the theme's first statement over it, and one last bar of the arrangement's own.5# Here it runs as a step sequencer on one speaker: 24 steps to the bar, six to the beat, a unit6# of 87 ms that broadens to 88 for the close. The ostinato is a pattern of hits on D3, the tune7# a lane of note letters an octave above the film's. A hit takes the front of the tune's slot,8# and the tune sounds on for the rest.9{10# the ostinato: a hit on each x of the bar's 24 steps.11# The intro plays the same figure, cut after five hits12:localostinato"x.x...x...x.x...x...x..."13:localintro([:pick$ostinato 0 13]."...........")1415# the tune's notes in Hz, one letter each: capitals D4 to G4, small letters C5 to A5.16# A lane has a character a step: a letter where a note begins, a dash (0) where none does17:localnotes{"-"=0;"D"=294;"E"=330;"F"=349;"G"=392;"c"=523;"d"=587;"e"=659;"f"=698;"g"=784;"a"=880}1819# under the intro the tune is silent20:localsilence"------------------------"2122# the theme: three phrases climb D, E, F from the same two written bars and end apart,23# on the low F held, on A stepping down to G, on the low G held24:localopening{"d--e--f-----------------";"------------e-------c---"}25:localendings{26{"F-----------------------";"------------------------"};27 {"a-----------------------";"g-----------------------"};28 {"G-----------------------";"------------------------"}29 }3031# the close sinks back towards D: the low F held into a short D, then F and E32:localclose{"F-----------------------";"--------------------D---";"F-----------------------";"E-----------------------"}3334# share: the hit, paid out of the tune's slot. It sounds 30 ms and takes 40,35# and the tune has the rest: a note that begins here, the held note struck again, or silence under the intro36:localsharedo={37:localrest($span- 40ms)38:beepfrequency=147 length=30ms39:delay 40ms40:if($new> 0)do={41:beepfrequency=$newlength=$rest42 }else={43:if($held> 0)do={44:beepfrequency=$heldlength=$rest45 }46 }47:delay$rest48 }4950# the form: each part's line on the terminal, its unit, its hits and its bars of tune51:localform{52{title="Ostinato"; unit=87ms; hits=$intro; bars={$silence;$silence;$silence;$silence}};53 {title="Theme, phrase 1 of 3"; unit=87ms; hits=$ostinato; bars=($opening,($endings->0))};54 {title="Theme, phrase 2 of 3"; unit=87ms; hits=$ostinato; bars=($opening,($endings->1))};55 {title="Theme, phrase 3 of 3"; unit=87ms; hits=$ostinato; bars=($opening,($endings->2))};56 {title="Close"; unit=88ms; hits=$ostinato; bars=$close}57 }5859# the scheduler walks each bar step by step, keeping the tune's sounding note60:localheld 061:foreachpartin=$formdo={62:put($part->"title")63:localunit($part->"unit")64:localhits($part->"hits")65:foreachtunein=($part->"bars")do={66:localsteps[:len$tune]67:forstepfrom=0 to=($steps- 1)do={68:localhit([:pick$hits$step]="x")69:localnew($notes->[:pick$tune$step])70:if($hit||($new> 0))do={71# the slot runs to the next hit, the next note or the bar line72:localnext$steps73:localahead($step+ 1)74:while($ahead<$next)do={75:if(([:pick$hits$ahead]="x")||([:pick$tune$ahead]!="-"))do={:setnext$ahead}76:setahead($ahead+ 1)77 }78:localspan($unit*($next-$step))79:if($hit)do={80 $share new=$new held=$held span=$span81 }else={82# a note with no hit in front has its whole slot83:beepfrequency=$newlength=$span84:delay$span85 }86:if($new> 0)do={:setheld$new}87 }88 }89 }90 }9192# the arrangement's own last bar: one more hit, and the tune steps down to D4 for 1.5 s93$share new=($notes->"D") span=1540ms94}
One command sounds one tone: :beep frequency=<hertz> length=<time>; the beeper plays one note at a time.
:delay is the clock. A beep starts the tone and returns at once, so every note is a beep followed by a delay of the same length and a small gap.
Most tunes here are written out note by note, a beep and a delay each; some also come as code, with loops, tables and functions, that plays the very same notes. Download any of these and run it in a terminal.