BBC BASIC, 141 ASCII characters (65.217BPM)
*TEMPO1
F.i=2TO71j=i>65SOUND1-j*(479+i/2),-9,ASCM." \\VX\\VX\DHLNRVXVVNRVV>@DHD@D>@D@@HD@@>:>:6:>@DH@@HDHHLNLDHLNRVXNNVV\\",i)*2,23-j*161N.
Revised to accomodate limit on tempo. Will update explanation later.
BBC BASIC, 123 ASCII characters (noncompeting as 60BPM)
Download interpreter at http://www.bbcbasic.co.uk/bbcwin/download.html
Plays the song directly when run.
F.i=1TO67j=i>64SOUND1-j*(447+i),-9,ASCM."\\VX\\VX\DHLNRVXVVNRVV>@DHD@D>@D@@HD@@>:>:6:>@DH@@HDHHLNLDHLNRVXNV\",i)*2,5-j*75N.
Ungolfed
FOR i = 1 TO 67
j = i > 64: REM j=0 for the first four bars composed of 16th notes, j=-1 for the final chord (whole note)
SOUND 1 - j * (447 + i), -9, ASC(MID$("\\VX\\VX\DHLNRVXVVNRVV>@DHD@D>@D@@HD@@>:>:6:>@DH@@HDHHLNLDHLNRVXNV\", i)) * 2, 5 - j * 75
NEXT i
Explanation
j
is a flag indicating whether we are in the first 4 bars or the final chord. TRUE is -1
in BBC BASIC.
The SOUND
statement takes 4 parameters:
CHANNEL: for the first 4 bars this is channel 1. For the 3 notes of the chord in the 5th bar, the channel numbers are 201, 202 and 203 hex (513,514 and 515 decimal.) This means play on channels 1,2 and 3, the initial 2 meaning play simultaneously with 2 notes on other channels (i.e play a 3 note chord).
VOLUME: Given as a negative value because positive values represent other effects (sound envelopes.). Set at -9 (will go up to -15 which is loudest.)
PITCH: For this tune, ranges from D4=108 to A5=184. Each integer step is 1/4 of a semitone. Values are stored as ASCII codes in the range 54 to 92 and doubled to regenerate the correct value. 1/8th notes are stored as duplicate 1/16th notes. The final chord is stored as 3 separate pitches and the note length varied to whole note as below.
DURATION: in 1/20 of a second. Duration of 1/16th note is 5/20 of a second so 60 1/4 notes per minute (there is insufficient resolution to make the tempo more precise.) The whole note is 5-(-75)=80 units (4 seconds) long.
Would that snippet be competitive as it downloads it from elsewhere – Blue – 2016-12-25T17:09:23.197
4@muddyfish No, because fetching the output from an external source is a standard loophole. – Mego – 2016-12-25T17:10:04.733
Would outputting a midi file instead of audio be acceptable? – James – 2016-12-25T17:31:19.777
@DJMcMayhem Yes, MIDI files are acceptable. – Mego – 2016-12-25T17:32:23.970
I assume the final (only) chord is required in full? That effectively prohibits non-polyphonic languages / API's – Level River St – 2016-12-25T19:39:55.540
@LevelRiverSt Yes. That exact excerpt is to be played. – Mego – 2016-12-25T19:52:49.837
Is it okay to output two sixteenth notes for an eighth note (and sixteen sixteenth notes for a whole note)? – JungHwan Min – 2016-12-26T03:25:00.113
@JungHwanMin If it's indistinguishable from an actual eighth note (meaning the first doesn't taper noticeably before the second begins), sure. – Mego – 2016-12-26T03:26:22.000
Would you consider the tempo 64.8649 close enough to 65? – JungHwan Min – 2016-12-26T03:36:59.987
@JungHwanMin Yeah that's fine. A 0.1401 bpm difference would take several more measures to become audible than are present in this except. – Mego – 2016-12-26T03:38:21.077
Let us continue this discussion in chat.
– Mego – 2016-12-26T03:40:00.363Is outputting an ABC-notation version OK?
– FlipTack – 2016-12-30T12:21:00.370@FlipTack If you can find a codec for it (or, rather, a translation program that translates ABC notation to some common audio format) that existed prior to this challenge, sure. – Mego – 2016-12-31T01:00:00.510
Just pointing out that this melody was originally in 32th notes. – ericw31415 – 2017-12-21T02:10:23.467
@DLosc: QBasic deserves an answer here also! – sergiol – 2018-06-12T00:13:13.953