With these features, we can now play retro music using 4 simultaneous channels (a.k.a. voices). Each voice can have its own waveform, volume, and pan position, allowing for rich, layered audio playback.
The notes can be programmed in two main ways:
Using the SOUND command, combined with SOUND WAIT and SOUND RESUME for synchronization between voices.
Using the PLAY command, where each voice can be controlled with its own MML string.
In v4, the QB64-PE MML syntax has been extended to support all the new features. Much of the design draws inspiration from the SOUND and PLAY capabilities of Amiga Basic and Advanced BASIC (for the Tandy 1000 and IBM PCjr systems). This means many classic BASIC programs using SOUND and PLAY can run in QB64-PE with minimal or no modifications.
The purpose of this post is to showcase what’s possible with these new features.
I’m no musician by any stretch of the imagination. But I do understand the math (well, mostly!), and I’ve been able to port a few forgotten and abandoned gems from Amiga Basic and BASICA into QB64-PE. Below are a few examples of these ports. I’ll continue to share more as I complete them.
If you’ve created something cool using these new audio features, feel free to post and share it here!
Code: (Select All)
' Music - AmigaBasic Music/Graphic-Demo --- 20. July 1985 DEFLNG A-Z
InitSound: ' F#() contains frequencies of the chromatic scale. ' Note A in octave 0 = F#(12) = 55 Hz.
Log2of27.5# = LOG(27.5#) / LOG(2#) FOR x = 1TO88
F#(x) = 2 ^ (Log2of27.5# + x / 12#) NEXT x
' Create the waveform of tones, ' determines timbre. DIM Timbre(255) AS_BYTE FOR I = 0TO255 READ Timbre(I) NEXT I
' The following DATA rows were created using the following formula. ' Reading from these DATAs is faster than calculating the sine 1024 times. ' K# = 2 * 3.14159265/256 ' FOR I = 0 TO 255 ' Timbre(I) = 31 * (SIN(I * K#) + SIN(2 * I * K#) + SIN(3 * I * K#) + SIN( 4 * I * K#)) ' NEXT I DATA0,8,15,23,30,37,44,51,57,63,69,74,79,83,87,91 DATA93,96,98,99,100,100,100,99,98,97,95,92,89,86,83,79 DATA75,71,66,62,57,52,48,43,39,34,30,25,21,18,14,11 DATA8,5,3,0,-1,-3,-4,-5,-5,-6,-6,-5,-5,-4,-3,-1 DATA0,2,3,5,7,9,11,13,15,17,18,20,21,23,24,25 DATA26,26,27,27,27,27,27,26,25,24,23,22,20,18,17,15 DATA13,11,9,7,5,3,1,-1,-3,-5,-6,-8,-9,-10,-11,-12 DATA-12,-13,-13,-13,-13,-13,-12,-11,-11,-10,-8,-7,-6,-4,-3,-2 DATA0,2,3,4,6,7,8,10,11,11,12,13,13,13,13,13 DATA12,12,11,10,9,8,6,5,3,1,-1,-3,-5,-7,-9,-11 DATA-13,-15,-17,-18,-20,-22,-23,-24,-25,-26,-27,-27,-27,-27,-27,-26 DATA-26,-25,-24,-23,-21,-20,-18,-17,-15,-13,-11,-9,-7,-5,-3,-2 DATA0,1,3,4,5,5,6,6,5,5,4,3,1,0,-3,-5 DATA-8,-11,-14,-18,-21,-25,-30,-34,-39,-43,-48,-52,-57,-62,-66,-71 DATA-75,-79,-83,-86,-89,-92,-95,-97,-98,-99,-100,-100,-100,-99,-98,-96 DATA-93,-91,-87,-83,-79,-74,-69,-63,-57,-51,-44,-37,-30,-23,-15,-8
' Set AMIGA PAULA like panning (well mostly) SOUND0, 0, , -0.75!, 10, , 0' pan left SOUND0, 0, , 0.75!, 10, , 1' pan right SOUND0, 0, , 0.75!, 10, , 2' pan right SOUND0, 0, , -0.75!, 10, , 3' pan left
' Array CF maps MML commands to frequency indices.
C$ = "cdefgabp#-123468<>l" FOR I = 1TO19 READ CF(I) NEXT I DATA0,2,4,5,7,9,11,0,1,-1,0,0,0,0,0,0,-12,12,0
' Array CT# assigns note lengths to MML commands. FOR I = 1TO18 READ CT#(I) NEXT I ' MML commands p1,p2,p3,p4,p6,p8 correspond to pause times 36.4 ... 4.55 units DATA0,0,0,0,0,0,0,0,0,0,36.4,18.2,12.133333,9.1,6.0666667,4.55,0,0,0 RETURN
' The first 4 numbers are the base octaves (0-7) for each voice. ' ln - sets note length for the following notes of this voice: ' l1 = whole note, l2 = half note, l4 = quarter note, etc. ' > - selects the next higher octave for this voice. ' < - selects the next lower octave for this voice. ' a to g - play the respective note, ' # (sharp) or - (flat) may follow directly. ' It may also follow a number to determine the duration of this note. ' pn - make a rest/pause length as for note length (ln) above.
Song: DATA1,3,3,3 DATA l2g>ge,l2p2de,l2p2l6g3f#g3a,l6p6gab>dcced DATA <b>e<e,ge<b,b3ab3ge3d,dgf#gd<bgab DATA ab>c,a>dc,e3f#g3de3<b,>cdedc<babg DATA df#d,c<a>f#,a3>da3ga3f#,f#gadf#a>c<ba DATA gec,g<g>e,d3f#g3f#g3a,bgab>dcced DATA <b>ed,ge<b,b3ab3ge3g,dgf#gd<bgab DATA cc#d,>ced,a3f#g3e<a3>c,e>dc<bagdgf# DATA <gp3>g6d3<b6,dp2b3g6,<b3>gb3>dg3d,gb>dgd<bgb>d DATA g>f#e,d<gg,l2<g1g,l2<b1>c DATA f#ed,agf#,a1b,d1d DATA ef#g,gag,bag,c1<b DATA dp3d6d3d6,f#a3a6>d3d6,al6d3ef#3g,l6adef#aga>c<b DATA <d>p3d6d3d6,f#3a6f#3d6<a3>d6,a3>c<a3f#d3f#,>c<af#df#a>c<ba DATA gf#e,dde,g3dg3f#g3a,bgab>dcced DATA b<b>e,gd<b,b3ag3f#e3g,dgf#gd<bgab DATA cd<d,l4>c<a>d<b>c<al2,a3gf#3ga3c,e>dc<bagdgf# DATA g>ge,b>de,<b3>dg3f#g3a,gbab>dcced DATA <b>e<e,ge<b,b3ab3ge3d,dgf#gd<bgab DATA ab>c,a>dc,e3f#g3de3<b,>cdedc<babg DATA df#d,c<a>f#,a3>f#a3ga3f#,f#gadf#a>c<ba DATA gec,g<g>e,d3f#g3f#g3a,bgab>dcced DATA <b>ed,ge<b,b3ab3ge3g,dgf#gd<bgab DATA cc#d,>ced,a3f#g3e<a3>c,e>dc<bagdgf# DATA <g>f#e,d<gg,l2b1>c,l2g1g DATA f#ed,agf#,d1d,a1b DATA ef#g,gag,c1<b,bag DATA dp3d6d3d6,f#l6a3a>d3d,al6d3ef#3g,l6ddef#aga>c<b DATA <dp3>d6d3d6,f#3af#3d<a3>d,a3>c<a3f#d3f#,>c<af#df#a>c<ba DATA gf#e,l2dde,l2b1>c,bgab>dcced DATA b<b>e,gd<b,d1<b,dgf#gd<bgab DATA cd<d,l4>c<a>d<b>c<a,a4b8>c8<ba,e>dc<bagdgf# DATA g>ge,l2b>de,l6g3dg3f#g3a,gbab>dcced DATA <b>e<e,ge<b,b3ab3ge3d,dgf#gd<bgab DATA ab>c,a>dc,e3f#g3de3<b,>cdedc<babg DATA df#d,c<a>f#,a3>da3ga3f#,f#gadf#a>c<ba DATA gec,g<g>e,d3f#g3f#g3a,bgab>dcced DATA <b>ed,ge<b,b3ab3ge3g,dgf#gd<bgab DATA cc#d,>ced,a3f#g3e<a3>c,e>dc<bagdgf# DATA <gp3>g6f#3e6,dp3g6d3e6,<b3>gb3>dg3<g,gb>dgd<bdb>c# DATA dc<b,f#dd,l2a1b,d<def#ag#g#ba DATA a>a4g4f4e4,e<a>a,>c1c,a>c<b>c<aecde DATA d<b>e,aag#,<bb4>c8d8<b,f>dcd<bg#ef#g# DATA a>fd,e<a>f#,al6a3g#a3b,a>c<b>ceddfe DATA cfe,afc,>c3<b>c3<af3a,eag#aec<ab>c DATA dd#e,df#e,a3g#a3f#<b3>d,fedc<baeag# DATA <a>ab,c<ag,>l2c1d,a>ceap3l2d DATA >c<ae,>cag,e1e,l6ecdegfgb-a DATA fdg,df#g,dd4e8f8d,a>c<b>c<afdef DATA cec,geg,l6c3<g>c3<ge3d,egfgec<gab- DATA fdg,fag,c3ef3ab3>d,a>c<b>c<afdef DATA cp3c6<b3>d6,gp3d6d3d6,c3<g>c3<a>d3<f#,ecdegf#gba DATA <g>ge,dde,l2b1>c,bgab>dcced DATA <b>e<e,ge<b,d1d,dgf#gd<bgab DATA ab>c,a>dc,c<b1,>cdedc<babg DATA dp3d6d3d6,cl6<a3a>d3d,l6a3c#d3ef#3g,f#def#aga>c<b DATA <dp3>d6d3d6,f#3af#3d<a3>d,a3>c<a3f#d3f#,>c<af#df#a>c<ba DATA gf#e,l2dde,l2b1>c,bgab>dcced DATA b<b>e,gd<b,d1<b,dgf#gd<bgab DATA cd<d,l4>c<a>d<b>c<a,a4b8>c8<ba,e>dc<bagdgf# DATA g1g2,l2gp3>g6d3g6,gl6<b3>dg3d,gb>dgd<bgb>a DATA g1g2,dp3g6e3c6,<b3g>d3b>c2,fd<bgb>ded<a DATA g1g2,<ap3>d6<b3>e6,c3<ab2b3g,f#a>cd<bgegb DATA g1g2,<e3a6f#3>a6f#3d6,a2a3f#d3f#,>c<af#df#a>c<ba DATA g>ge,dde,g3dg3f#g3a,bgab>dcced DATA <b>e<e,ge<b,b3ab3ge3d,dgf#gd<bgab DATA ab>c,a>d<c,e3f#g3de3<b,>cdedc<babg DATA df#d,c<a>f#,a3>da3ga3f#,f#gadf#a>c<ba DATA gec,g<g>e,d3f#g3f#g3a,bgab>dcced DATA <b>ed,ge<d,b3ab3ge3g,dgf#gd<bgab DATA cc#d,d1d2,a3f#g3e<a3>c,e>dc<bagdgf# DATA <g1g2,p2,<b1b2,g1g2 DATA p1,p1,p1,p1 DATA x
dl_right: LINE (0, winHeight * i1!)-(winWidth * I!, 0), hue RETURN END SUB
Code: (Select All)
'----------------------------------------------------------------------------------------------------------------------- ' QB64-PE v4.0.0 Multi-voice PLAY Demo by a740g '-----------------------------------------------------------------------------------------------------------------------
DIMASSTRING CH0Verse_1, CH0Verse_2, CH1Verse_1, CH1Verse_2, CH2Verse_1, CH2Verse_2, CH2Verse_3, CH3Verse_1 DIMASSTRING Channel_0, Channel_1, Channel_2, Channel_3, Caption DIM c ASLONG
DO DO CLS PRINT PRINT"Enter number for a tune to play." PRINT PRINT"1. Demo 1 by J. Baker" PRINT"2. Demo 2 by Wilbert Brants" PRINT"3. Demo 3 by Wilbert Brants" PRINT"4. Demo 4 by J. Baker" PRINT"5. Demo 5 by Wilbert Brants" PRINT INPUT"Your choice (0 exits)"; c LOOP WHILE c < 0OR c > 7
12-17-2024, 02:57 PM (This post was last modified: 12-17-2024, 11:27 PM by a740g.
Edit Reason: Add images
)
Port of BACH.BAS for Tandy 1000 Advanced BASIC. I got rid of all the line numbers and used a lot of modern QB64-PE features. However, the MML is almost untouched.
Warning: Has palette animation.
Code: (Select All)
' BACH.BAS Copyright (c) 1987 by Unique Software ' Ported from TANDY 1000 Advanced BASIC to QB64-PE by a740g
DIM i AS_UNSIGNEDLONG: FOR i = 1TO srcSize STEP4
index = ASC(s, i): GOSUB find_index: char1 = index
index = ASC(s, i + 1): GOSUB find_index: char2 = index
index = ASC(s, i + 2): GOSUB find_index: char3 = index
index = ASC(s, i + 3): GOSUB find_index: char4 = index
' Loads a binary file encoded with Bin2Data ' Usage: ' 1. Encode the binary file with Bin2Data ' 2. Include the file or it's contents ' 3. Load the file like so: ' Restore label_generated_by_bin2data ' Dim buffer As String ' buffer = LoadResource ' buffer will now hold the contents of the file FUNCTIONBase64_LoadResourceData$ DIM ogSize AS_UNSIGNEDLONG, resize AS_UNSIGNEDLONG, isComp AS_BYTE READ ogSize, resize, isComp ' read the header
DIM buffer ASSTRING: buffer = SPACE$(resize) ' preallocate complete buffer
Ok. Here is another one. This one had a bit too much spaghetti. So, I left some of it in there for you guys to enjoy. Nonetheless, it works like a champ.
Code: (Select All)
' TWELVE.BAS COPYRIGHT (c) 1987 by Unique Software ' Ported from TANDY 1000 Advanced BASIC to QB64-PE by a740g
DIM i AS_UNSIGNEDLONG: FOR i = 1TO srcSize STEP4
index = ASC(s, i): GOSUB find_index: char1 = index
index = ASC(s, i + 1): GOSUB find_index: char2 = index
index = ASC(s, i + 2): GOSUB find_index: char3 = index
index = ASC(s, i + 3): GOSUB find_index: char4 = index
' Loads a binary file encoded with Bin2Data ' Usage: ' 1. Encode the binary file with Bin2Data ' 2. Include the file or it's contents ' 3. Load the file like so: ' Restore label_generated_by_bin2data ' Dim buffer As String ' buffer = LoadResource ' buffer will now hold the contents of the file FUNCTIONBase64_LoadResourceData$ DIM ogSize AS_UNSIGNEDLONG, resize AS_UNSIGNEDLONG, isComp AS_BYTE READ ogSize, resize, isComp ' read the header
DIM buffer ASSTRING: buffer = SPACE$(resize) ' preallocate complete buffer
Another one. This one is almost untouched with line numbers, GOTOs and other weird stuff.
Code: (Select All)
' MEDLEY.BAS Copyright (c) 1987 by Unique Software _TITLE"Christmas Medley" 1GOTO8 2READ L$, L, M1$, M2$, M3$, P 3IF P = 1THEN C = C + 1: C = C - (C = 8) + 12 * (C > 13): COLOR C, 0 4IF P = 2THENPALETTE14, 14 5IFPLAY(0) > 0_ORELSEPLAY(1) > 0_ORELSEPLAY(2) > 0THEN_LIMIT60: GOTO5 6IF MF = 0THENPRINT L$; MID$(CHR$(13), 1, L MOD2); 7PLAY M1$, M2$, M3$: GOTO2 8DEFINT A-Z: KEYOFF: ON ERRORGOTO10: LOCATE1, 1, 1, 0, 7: C = 1 9WIDTH80: COLOR8, 0: CLS: PALETTE14, 0: COLOR15, 0: PRINT" Christmas Medley Copyright (c) 1987 by Unique Software": LOCATE25, 22: COLOR14, 0: PRINT"Merry Christmas from Unique Software";: LOCATE2, 1: VIEW PRINT2TO24: COLOR1, 0: GOSUB2 10IFPLAY(0) > 0_ORELSEPLAY(1) > 0_ORELSEPLAY(2) > 0THEN_LIMIT60: GOTO10ELSESLEEP1: SYSTEM 11DATA"We ",0,"MBV12T120O3 C4","MBV9T120O3 P4","MBV10T120O3 P4",0 12DATA"wish you a Mer-ry ",0,"O3F4F8G8F8E8","O2MLD6.F6.A6.","O1F2.",0 13DATA"Christ-mas, We ",0,"O3D4D4D4","O2D6.F6.B-6.","O1B-2.",0 14DATA"wish you a Mer-ry ",0,"O3G4G8A8G8F8","O2D6.B6.O3MND6.","O1G2.",0 15DATA"Christ-mas, We ",0,"O3E4C4C4","O2MLC6G6MNB-6P4","O1C2.",0 16DATA"wish you a Mer-ry ",0,"O3A4A8B-8A8G8","O2MLF6.A6.O3C6.","O1F2.",0 17DATA"Christ-mas, and a ",0,"O3F4D4C8C8","O2F6A6O3MND6O2MLF12A12O3C12","O1D2F4",0 18DATA"hap-py New ",0,"O3D4G4E4","O2F6B-6O3MND6O2MLG12B-12O3MNC12","O1B-2O2C4",0 19DATA"Year!",1,"O3MLF2","O2MLF3A3O3MNC3","O1F2",0 20DATA"It ",0,"T90O3MNF8","T90O3P8","T90O3P8",1 21DATA"came up-on the ",0,"O4D4C8MLC8O3MNB-8G8","O2F4F#8MLE-8.MNG8.","O1MLB-2.",0 22DATA"mid-night clear, That ",0,"O3F4G8F4F8","O2MLD4.MNB-4.","O1MNB-2.",0 23DATA"glo-rious song of ",0,"O3MLG8MNA8B-8MLB-8O4MNC8D8","O2E-8F8G8MLE8.O3C8.","O1E-4.C4.",0 24DATA"old, From ",0,"O4MLC4.MNC4O3F8","O2F12.A12.O3C12.O2F12A12O3MNC12O2P8","O1MLF4.MNF4P8",0 25DATA"an-gels bend-ing ",0,"O4D4O3A8O4MLC8O3MNB-8G8","O2F4F#8MLE-8.MNG8.","O1MLB-2.",0 26DATA"near the earth to ",0,"O3F4G8F4F8","O2MLD4.B-4.","O1MNB-2.",0 27DATA"touch their harps of ",0,"O3G4G8MLA8MNG8F8","O2G8.MNB-8.MLF8.O3MNC8.","O1E-4.F4.",0 28DATA"gold, `Peace ",0,"O3MLB-4.MNB-4O4D8","O2MLD12.E12.B-12.D12E12MNB-12P8","O1MLB-4.MNB-4P8",0 29DATA"on the earth, good ",0,"O4D4O3D8MLD8MNE8F#8","O2MLD12.F#12.MNA12.F8G8A8","O1D2.",0 30DATA"will to men, From ",0,"O3G4A8B-4O4D8","O2MLD6.G6.MNB-6.","O1G2.",0 31DATA"heav'n's all gra-cious ",0,"O4MLC8O3MNB-8A8MLG8MNA8G8","O2A8O3D8MLC8C12.O2B-12.MNE12.","O1C2.",0 32DATA"King.' The ",0,"O3MLF4.MNF4F8","O2MLF12.A12.O3C12.O2F12A12O3MNC12O2P8","O1MLF4.MNF4P8",0 33DATA"world in sol-emn ",0,"O4D4O3A8O4MLC8O3MNB-8G8","O2F4F#8MLE-8.MNG8.","O1MLB-2.",0 34DATA"still-ness lay, To ",0,"O3F4G8F4F8","O2MLD4.MNB-4.","O1MNB-2.",0 35DATA"hear the an-gels ",0,"O3G4G8MLA8MNG8F8","O2MLG8.MNB-8.MLF8.O3MNC8.","O1E-4.F4.",0 36DATA"sing.",1,"O3MLB-4.B-4","O2MLD12.F12.B-12.D12F12MNB-12","O1MLB-4.MNB-4",0 37DATA"O ",0,"T120O3MNB4","T120O3P4","T120O3P4",1 38DATA"lit-tle town of ",0,"O3B4B4A#4B4","O2MLB4O3MND4MLC#8MNE8O2MLB8O3MND8","O1G1",0 39DATA"Beth-le-hem, How ",0,"O4D4C4O3E4A4","O2MLG#12B12O3MNF12O2MLA6.O3C6.MNE6.","O1C1",0 40DATA"still we see thee ",0,"O3G4MLF#8MNG8A4D4","O2B4A8B8MLF#4O3MNC4","O1D1",0 41DATA"lie! A-",0,"O3B2.B4","O2MLG6.B6.O3MND6.P4","O1G2.P4",0 42DATA"bove thy deep and",0,"O3B4B4O4E4D4","O2MLG8MNB8MLF8MNA8MLE6G#6B6","O1G4F4E2",0 43DATA"dream-less sleep, The ",0,"O4D4C4O3E4A4","O2E3A3O3MNC3","O1A2.C4",0 44DATA"si-lent stars go ",0,"O3G4MLF#8MNG8B4A4","O2B4A#8B8MLF#4O3MNC4","O1D1",0 45DATA"by, Yet ",0,"O3G2.B4","O2MLG6.B6.O3MND6.O2MLG8O3D8","O1G2.P4",0 46DATA"in thy dark streets ",0,"O3B4B4A4G4","O3MND2C4C#4","O2G2A4A#4",0 47DATA"shin-eth The ",0,"O3F#2F#4F#4","O3D#2.D4","O2B2.B4",0 48DATA"ev-er-last-ing ",0,"O3E4F#4G4A4","O2E4F#4G4MLA12O3C12MNE12","O2P2P4C4",0 49DATA"Light, The ",0,"O3B2.B4","O2MLF#6.B6.O3MND#6.P4","O1B2.P4",0 50DATA"hopes and fears of ",0,"O3B4B4A#4B4","O2MLG6B6O3MND6MLC#8MNE8O2MLB8O3MND8","O1G1",0 51DATA"all the years, Are ",0,"O4D4C4O3E4O4E4","O2MLG#12B12O3MNF12O2MLA6O3C6MNE6O2E8F#8","O1C1",0 52DATA"met in thee to-",0,"O4D4O3G4B4.A8","O2MLG8MNB8MLA8O3MNC#8O2MLB8O3MND8O2MLF#8O3MNC8","O1D4E4D2",0 53DATA"night. ",1,"O3MLG2.","O2MLG6.B6.O3MND6.","O1G2.",0 54DATA"Good King Wen-ces-",0,"t170O3MNG4G4G4A4","t170O2MLD6G6MNB6MLE2","t170O1G2E2",1 55DATA"las looked out, ",1,"O3G4G4D2","O2E6G6O3MNC6O2MLF#4MNA4","O1C2D2",0 56DATA"On the Feast of ",0,"O3E4D4E4F#4","O2MLG4O3MNC4O2F#2","O1C2D2",0 57DATA"Ste-phen, ",1,"O3G2G2","O2MLD3G3MNB3","O1G1",0 58DATA"When the snow lay ",0,"O3G4G4G4A4","O2MLD6G6MNB6MLE2","O1G2E2",0 59DATA"rounda-bout, ",1,"O3G4G4D2","O2E6G6O3MNC6O2MLF#4MNA4","O1C2D2",0 60DATA"Deep, and crisp, and ",0,"O3E4D4E4F#4","O2MLG4O3MNC4O2F#2","O1C2D2",0 61DATA"e-ven, ",1,"O3G2G2","O2MLD3G3MNB3","O1G1",0 62DATA"Bright-ly shone the ",0,"O4D4C4O3B4A4","O2B4A4G4F#4","O1G1",0 63DATA"moon that night, ",1,"O3B4A4G2","O2G4F#4E2","O1D2E2",0 64DATA"Though the frost was ",0,"O3E4D4E4F#4","O2MLE4O3MNC4O2F#2","O1C2D2",0 65DATA"cru-el, ",1,"O3G2G2","O2MLD3G3MNB3","O1G1",0 66DATA"When a poor man ",0,"O3D4D4E4F#4","O2G2O3C2","O1B2O2C2",0 67DATA"came in sight, ",1,"O3G4G4A2","O2MLG6B6O3MNE6O2MLF#6A6O3MND6","O1E2D2",0 68DATA"Gath-'ring win-ter ",0,"O4D4C4O3B4A4","O3D4E4D4O2F#4","O1B4O2C4O1D2",0 69DATA"fu-",0,"O3MLG2O4MNC2","O2MLB4O3MNE4MLC4MNE4","O1E2C2",0 70DATA"el. ",1,"O3G1","O2MLG3B3O3MND3","O1G1",0 71DATA"",0,"O3A1","O3F#1","O3C1",1 72DATA"God ",0,"O3E4","O3P4","O3P4",0 73DATA"rest you mer-ry ",0,"O3E4B4B4A4","O2MLE6G6B6D#4F#4","O1E2D#2",0 74DATA"gen-tle-men, Let ",0,"O3G4F#4E4D4","O2E6G6B6A4O3C4","O1E2A2",0 75DATA"noth-ing you dis-",0,"O3E4F#4G4A4","O2E6G6MNB6MLA4O3MNC4","O1B2A2",0 76DATA"may, Re-",0,"O3B2.E4","O2MLD#6.F#6.MNB6.P4","O1B2.P4",0 77DATA"mem-ber Christ our ",0,"O3E4B4B4A4","O2MLE6G6B6D#4F#4","O1E2D#2",0 78DATA"Sav-iour was ",0,"O3G4F#4E4D4","O2E6G6B6A4O3C4","O1E2A2",0 79DATA"born on Christ-mas ",0,"O3E4F#4G4A4","O2E6G6MNB6MLA4O3MNC4","O1B2A2",0 80DATA"Day. To ",0,"O3B2.B4","O2MLD#6.F#6.MNB6.P4","O1B2.P4",0 81DATA"save us all from ",0,"O4C4O3A4B4O4C4","O2MLA4O3MNC4O2MLB4O3MND4","O1A2E2",0 82DATA"Sa-tan's pow'r when ",0,"O4D4E4O3B4A4","O2MLD4MNG4MLD#4MNF#4","O1D2B2",0 83DATA"we were gone a-",0,"O3G4E4F#4G4","O2MLG4MNB4MLA4O3C4","O1E2A2",0 84DATA"stray. ",1,"O3A2","O2F#6O3C6MND6","O1D2",0 85DATA"O ",0,"O3MLG4MNA4","O2MLE4MNF#4","O2P2",0 86DATA"ti-dings of ",0,"O3B2O4C4O3B4","O2G2MLE4O3MNC4","O1G2C2",0 87DATA"com-fort and ",0,"O3MLB4MNA4G4F#4","O2MLG8O3MND8O2MLA8O3MNC8O2MLB4B8O3MND#8","O1G4A4B2",0 88DATA"joy, com-fort and ",0,"O3E2G8F#8E4","O2MLG3B3O3MNE3","O1E1",0 89DATA"joy, O ",0,"O3A2MLG4MNA4","O2MLF#6A6O3MND6O2B4O3C4","O1D2P2",0 90DATA"ti-dings of ",0,"O3MLB4O4MNC4D4E4","O2MLG4O3MNE4O2MLG4O3MND4","O1E2B2",0 91DATA"com-fort and ",0,"O3MLB4MNA4G4F#4","O3D4C4O2MLB4B8O3MND#8","O1G4A4B2",0 92DATA"joy. ",1,"O3E2.","O2MLG6.B6.O3MNE6.","O1E2.",0 93DATA"O ",0,"t140O3MNE4","t140O3P4","t140O3P4",1 94DATA"come, O come, Em-",0,"O3G4B4B4B4","O2MLE3G3B3","O1E1",0 95DATA"man-u-",0,"O3MLA4O4C4O3MNB4A4","O2E3F#3O3C3","O1A1",0 96DATA"el. And ",0,"O3G2.A4","O2E6.G6.MNB6.P4","O1E2.P4",0 97DATA"ran-som cap-tive ",0,"O3B4G4E4G4","O2MLD6G6MNB6O3MLC4O2B4","O1G2.E4",0 98DATA"Is-ra-",0,"O3MLA4F#4MNE4D4","O2E3A3O3C3","O1C1",0 99DATA"el, That ",0,"O3E2.A4","O2E6.G6.MNB6.P4","O1E2.P4",0 100DATA"mourns in lone-ly ",0,"O3A4E4E4F#4","O2MLE6A6O3MNC6O2MLG4F#8A8","O1A2G4F#4",0 101DATA"ex-ile ",0,"O3MLG2MNF#4E4","O2G4MNB4A4MLG8O3MNC#8","O1E2D4A4",0 102DATA"here. Un-",0,"O3D2.G4","O2MLF#4.O3MND4.P4","O1D2.P4",0 103DATA"til the Son of ",0,"O3A4B4B4B4","O2MLF#4O3MND4O2MLG4B4","O1D2G2",0 104DATA"God ap-",0,"O3MLA4O4C4O3MNB4A4","O2G6O3C6MNE6O2MLB8O3D8O2F#12O3C12D12","O1C2D2",0 105DATA"pear. ",1,"O3G2.","O2G6.B6.O3MND6.","O1G2.",0 106DATA"Re-",0,"O4D4","O2MLG12B12O3D12","O1G4",0 107DATA"joice! Re-",0,"O4D2.O3B4","O2F#6.A6.O3D6.","O1D2.E4",0 108DATA"joice! Em-",0,"O3B2.B4","O2F#6.B6.O3MND6.P4","O1B2.P4",0 109DATA"man-u-",0,"O3MLA4O4C4O3MNB4A4","O3MLC4MNE4O2MLB8O3D8O2F#8O3C8MND8","O1C2D2",0 110DATA"el, Shall ",0,"O3G2.A4","O2MLG6.B6.O3MNE6.P4","O1E2.P4",0 111DATA"come to thee, O ",0,"O3B4G4E4G4","O2MLD6G6MNB6O3C4O2B4","O1G2C4E4",0 112DATA"Is-ra-",0,"O3MLA4F#4MNE4D4","O2MLA4O3MNC4O2MLG8B8F#8B8","O1A2B2",0 113DATA"el. ",1,"O3E2.","O2E6.G6.MNB6.","O1E2.",0 114DATA"",0,"O3F#8G8G#8A8A#8B8O4C8C#8","O3P1","O3P1",1 115DATA"A-",0,"t120O4D4","t120O2B4","t120O2P4",0 116DATA"way in a ",0,"O4D4.C8O3B4","O2B4.A8G4","O1MLG2.",0 117DATA"man-ger, no ",0,"O3B4.A8G4","O3D4.C8O2B4","O1MNG2.",0 118DATA"crib for His ",0,"O3G4F#4E4","O2MLE4.O3MNC4.","O1C2.",0 119DATA"bed, the ",0,"O3D2D4","O2MLG4MNB4P4","O1G2P4",0 120DATA"lit-tle Lord ",0,"O3D4.E8D4","O2MLF#4.O3C4.","O1MLD2.",0 121DATA"Je-sus laid ",0,"O3D4A4F#4","O2F#4.O3MNC4.","O1MND2.",0 122DATA"down His sweet ",0,"O3E4D4G4","O2MLG4.B4.","O1MLG2.",0 123DATA"head. ",1,"O3B2","O2G6B6O3MND6","O1G2",0 124DATA"The ",0,"O4D4","O2B4","O2P4",0 125DATA"stars in the ",0,"O4D4.C8O3B4","O2B4.A8G4","O1MLG2.",0 126DATA"sky look'd ",0,"O3MLB4.MNA8G4","O3D4.C8O2B4","O1MNG2.",0 127DATA"down where He ",0,"O3G4F#4E4","O2MLE4.O3MNC4.","O1C2.",0 128DATA"lay, the ",0,"O3D2D4","O2MLG4MNB4P4","O1G2P4",0 129DATA"lit-tle Lord ",0,"O4C4.O3B8A4","O2MLF#6.A6.O3D6.","O1D2.",0 130DATA"Je-sus a-",0,"O3B4A4G4","O2G6.B6.O3MND6.","O1G2.",0 131DATA"sleep on the ",0,"O3A4E4F#4","O3C2MLD4","O1C2D4",0 132DATA"hay. ",1,"O3G2","O2G6B6O3MND6","O1G2",0 133DATA"",0,"O3MLG#4A4MNA#4","O2MLG#4A4MNA#4","O1MLG#4A4MNA#4",0 134DATA"We three ",0,"MBV12T85O3B4A8","MBV12T85O2MLE12.G12.B12.","MBV12T85O1MLE4.",1 135DATA"kings of ",0,"O3G4F#8","O2MLE12.G12.B12.","O1MNE4.",0 136DATA"O-ri-ent ",0,"O3F#8G8F#8","O2D#12.A12.B12","O1B4.",0 137DATA"are, ",1,"O3E4.","O2E12.G12.MNB12.","O1E4.",0 138DATA"Bear-ing ",0,"O3B4A8","O2MLE12.G12.B12.","O1MLE4.",0 139DATA"gifts we ",0,"O3G4F#8","O2MLE12.G12.B12.","O1MNE4.",0 140DATA"tra-verse a-",0,"O3F#8G8F#8","O2D#12.A12.B12","O1B4.",0 141DATA"far, ",1,"O3E4.","O2E12.G12.MNB12.","O1E4.",0 142DATA"Field and ",0,"O3G4G8","O2MLE8.MNB8.","O1E4.",0 143DATA"foun-tain, ",0,"O3A4A8","O2MLF#8.MNA8.","O1D4.",0 144DATA"moor and ",0,"O3B4B8","O2MLD12.G12.MNB12.","O1G4.",0 145DATA"moun-tain, ",0,"O4MLD8MNC8O3B8","O2B8A8G8","O1G4.",0 146DATA"Fol-low-ing ",0,"O3A8B8A8","O2MLE12.A12.O3MNC12.","O1A4.",0 147DATA"yon-der ",0,"O3G4F#8","O2MLD12.A12.B12.","O1B4.",0 148DATA"star. ",1,"O3E4.","O2E12.G12.MNB12.","O1E4.",0 149DATA"",0,"O3MLF#2MNA4","O2MLD6.A6.O3C6.","O1D2.",0 150DATA"An-gels we have ",0,"T140V12O3B4B4B4>D4","T140V9O2G3B3D3","T140V10O1G1",1 151DATA"heard on high, ",1,"O4D4.C8<B2","O2F6A6>D6<G6B6>D6<","O1D2G2",0 152DATA"Sweet-ly sing-ing ",0,"O3B4A4B4>D4","O2G4F+4G4B4","O1MLD1",0 153DATA"o'er the plains. ",1,"O3B4.A8G2","O2MLF4MN>C4<MLG4MNB4","O1MND2G2",0 154DATA"And the moun-tains ",0,"O3B4B4B4>D4","O3D4D+4E4<B4","O1G1",0 155DATA"in re-ply, ",1,"O4D4.C8<B2","O2MLA8>MNC8<MLF+8>MND8<MLG6B6MN>D6<","O1D2G2",0 156DATA"Ech-o-ing their ",0,"O3B4A4B4>D4","O2G4F+4G4B4","O1MLD1",0 157DATA"joy-ous strains. ",1,"O3B4.A8G2","O2MLF4MN>C4<MLG4MNB4","O1MND2G2",0 158DATA"",0,"V14","V13","V13",0 159DATA"Glo-",0,"O4MLD2E8D8C8<B8","O2B2G#2","O2P4G8>D8P4D8E8",0 160DATA"o-",0,"O4C2D8C8<B8A8","O2A2F#2","O3P4C8E8P4C8D8",0 161DATA"o-",0,"O3B2>C8<B8A8G8","O2G2E2","O3P4B8>D8<P4G8>C8",0 162DATA"ri-a ",0,"O3MNA4.D8D2","O2F+1","O3P4C8D8P4C8D8",0 163DATA"in ex-cel-sis ",0,"O3G4A4B4>C4","O2B4>C4D4E4","O2G1",0 164DATA"De-o, ",1,"O3B2A2","O3MLD2<F+6>C6MND6","O2D1",0 165DATA"Glo-",0,"V14O4MLD2E8D8C8<B8","V12O2B2G#2","V13O2P4G8>D8P4D8E8",0 166DATA"o-",0,"O4C2D8C8<B8A8","O2A2F#2","O3P4C8E8P4C8D8",0 167DATA"o-",0,"O3B2>C8<B8A8G8","O2G2E2","O3P4B8>D8<P4G8>C8",0 168DATA"ri-a ",0,"V12O3MNA4.D8D2","V9O2F+1","V10O3P4C8D8P4C8D8",0 169DATA"in ex-cel-sis ",0,"O3G4A4B4>C4","O2B4>C4D4E4","O1G1",0 170DATA"De-",0,"O3B2A2","O3MLD2<F+6>C6MND6","O1D1",0 171DATA"-o! ",1,"O3MLG2.G8.G16V12","O2G3B3MN>D3V9","O1MNG1V10",0 172DATA"Si-lent night, ",0,"V11T100O3MLG4.MNA8G4E2.","V9T100O2E4.F8E4G2.","V10T100O1MLC2.MNC2.",1 173DATA"ho-ly night. ",1,"O3MLG4.MNA8G4E2.","O2E4.F8E4G2.","O1MLC2.MNC2.",0 174DATA"All is calm, ",0,"O4D2D4O3B2.","O2MLF6.G6.B6.F6.G6.MNB6.","O1MLG2.MNG2.",0 175DATA"all is bright. ",1,"O4C2C4O3G2.","O2MLE6.G6.O3C6.O2E6.G6.O3MNC6.","O1MLC2.MNC2.",0 176DATA"Round yon Vir-gin ",0,"O3A2A4O4MLC4.O3MNB8A4","O2MLD6.F6.MNA6.A4.G8F4","O1MLF2.MNF2.",0 177DATA"Moth-er and Child. ",1,"O3G4.A8G4E2.","O2MLE6.G6.O3C6.O2E6.G6.O3MNC6.","O1MLC2.MNC2.",0 178DATA"Ho-ly In-fant so ",0,"O3A2A4O4C4.O3B8A4","O2MLD6.F6.MNA6.A4.G8F4","O1MLF2.MNF2.",0 179DATA"ten-der and mild, ",1,"O3G4.A8G4E2.","O2MLE6.G6.O3C6.O2E6.G6.O3MNC6.","O1MLC2.MNC2.",0 180DATA"Sleep in ",0,"O4D2D4","O2MLG4.B4.","O1MLG2.",0 181DATA"heav-en-ly ",0,"O4F4.D8O3B4","O2G4.MNB4.","O1MNG2.",0 182DATA"peace, ",1,"O4MLC2.MNE2.","O2MLG6.O3C6.E6.O2G6.O3C6.MNE6.","O1MLC2.MNC2.",0 183DATA"Sleep in ",0,"O4MLC4O3MNG4E4","O2MLE4.O3MNC4.","O1MLG2.",0 184DATA"heav-en-ly ",0,"O3G4.F8D4","O2MLF4.MNB4.","O1MNG2.",0 185DATA"peace. ",1,"O3MLC2.MNC2.","O2MLE4.G4.E4.MNG4.","O1MLC2.MNC2.",0 186DATA"",0,"O3MLF#4A4O4MNC#4","O2MLF#4A4O3MNC#4","O1MLF#4A4O2MNC#4",1 187DATA"Joy to the world! The ",0,"v12t110O4D4C#8.O3B16A4.G8","v9t110O2F#4A8.G16F#4.MLG16B16","v10t110O1MLD2D4.G8",0 188DATA"Lord is come. ",1,"O3F#4E4D4.","O2D8F#8C#8G8D12.F#12.MNA12.","O1A2D4.",0 189DATA"Let earth re-",0,"O3A8B4.B8","O2P8MLD6G6MNB6","O1P8G2",0 190DATA"ceive her King. ",1,"O4C#4.C#8MND2.","O2MLE6G6A6D6.F#6.MNA6.","O1A2D2.",0 191DATA"Let ev-'ry ",0,"O4MLD8MNC#8O3MLB8MNA8","O2F#8A8G8F#8","O1D2",0 192DATA"heart pre-",0,"O3MLA8.G16MNF#8O4D8","O2MLF#8.E16MND8F#8","O1D2",0 193DATA"pare Him ",0,"O4MLD8MNC#8O3MLB8MNA8","O2F#8A8G8F#8","O1D2",0 194DATA"room. ",1,"O3MLA8.G16MNF#8","O2MLF#8.E16MND8","O1MND4.",0 195DATA"And heav'n and na-ture sing, ",1,"O3F#8F#8F#8F#8MLF#16MNG16A4.","O2P8MLD6F#6A6D24F#24MNA24MLD24F#24MNA24MLD24F#24MNA24","O1P8MLD2D4.",0 196DATA"And heav'n and na-ture sing, ",1,"O3MLG16MNF#16E8E8E8MLE16MNF#16G4.","O2MLD24F#24MNA24MLC#6G6A6C#24G24A24C#24G24A24C#24G24A24","O1MND8MLA2A4.",0 197DATA"And heav-en, and ",0,"O3MLF#16MNE16D8O4D4O3B8","O2MLC#24G24MNA24MLF#8.MNA8MLG16MNB16","O1MNA8D2",0 198DATA"heav-en and ",0,"O3MLA8.MNG16F#8G8","O2MLF#8.MNA8.MLG16MNB16","O1D4.G8",0 199DATA"na-ture sing. ",1,"O3F#4E4D2","O2MLD12F#12A12MNA8G8MLD4MNF#4","O1A2D2",0 200DATA"",0,"v11O3MLE2MNF#2","v8O2MLE2MNF#2","v9O1MLE2MNF#2",1 201DATA"O come,all ye ",0,"v11t120O3G4G2D4G4","v8t120O2P4MLG3B3O3D3","v9t120O1P4G1",1 202DATA"faith-ful, ",0,"O3A2D2","O2F#3A3O3MND3","O1D1",0 203DATA"joy-ful and tri-",0,"O3B4A4B4O4C4","O2MLG8MNB8MLF#8MNA8MLG8B8G12O3E12","O1G4F#4G4C4",0 204DATA"um-phant. ",1,"O3B2A4","O2MNG2MLF#8MNA8","O1D2.",0 205DATA"O come ye, O ",0,"O3G4G2F#4E4","O2MLG8MNB8B4O3C#4O2MLA8O3MND8O2MLG8O3MNC8","O1E4E2D4A4",0 206DATA"come ye to ",0,"O3MLF#4MNG4A4B4","O2MLF#8MNA8MLG8MNB8MLF#8MNA8MLG8MNB8","O1D2.G4",0 207DATA"Beth-le-",0,"O3MLF#2MNE4D4","O2MLF#4A4G6A6O3MNC#6","O1A1",0 208DATA"hem! ",1,"O3MLD2MND2","O2MLF#3A3O3MND3","O1D1",0 209DATA"Come and be-",0,"O4D2C4O3B4","O2MLG4MNB4E8F#8MLG8MNB8","O1G2A4G4",0 210DATA"hold Him, ",0,"O4C2O3B2","O2E4F#4MLG4MNB4","O1D2G2",0 211DATA"born the King of ",0,"O3A4B4G4A4","O2A4G4B4O3C4","O1F#4G4E4C4",0 212DATA"an-gels! ",1,"O3MLF#4.MNE8D4","O2MLA4.MNG8F#4","O1D2.",0 213DATA"O come,let us a-",0,"V12O3G4G4F#4G4A4","V9O3D4MLD1","V10O2B4B4A4B4O3C4",2 214DATA"dore Him, ",1,"O3G2D4","O3MND2.","O2B2.",0 215DATA"O come,let us a-",0,"V13O3B4B4A4B4O4C4","V10O3D4MLD1","V11O2G4G4F#4G4A4",0 216DATA"dore Him, ",1,"O3B2A4","O3MND2.","O2MLG4MNB4MLF#8MNA8",0 217DATA"O come,let us a-",0,"V15O3B4O4C4O3B4A4G4","V12O2MLG12B12O3MND12O2E8F#8MLG8MNB8MLF#8A8E12A12O3C#12","V13O1G4A4G4F#4E4",0 218DATA"dore Him, ",1,"O3F#2MLG4O4MNC4","O3MND4C4O2MLG8B8G12O3C12MNE12","O1D2E4C4",0 219DATA"Christ, the Lord! ",1,"O3MLB2MNA4.G8G2.","O2MLG6B6O3D6O2F#4O3C4O2G6.B6.O3MND6.","O1D1G2.",0
DIM i AS_UNSIGNEDLONG: FOR i = 1TO srcSize STEP4
index = ASC(s, i): GOSUB find_index: char1 = index
index = ASC(s, i + 1): GOSUB find_index: char2 = index
index = ASC(s, i + 2): GOSUB find_index: char3 = index
index = ASC(s, i + 3): GOSUB find_index: char4 = index
' Loads a binary file encoded with Bin2Data ' Usage: ' 1. Encode the binary file with Bin2Data ' 2. Include the file or it's contents ' 3. Load the file like so: ' Restore label_generated_by_bin2data ' Dim buffer As String ' buffer = LoadResource ' buffer will now hold the contents of the file FUNCTIONBase64_LoadResourceData$ DIM ogSize AS_UNSIGNEDLONG, resize AS_UNSIGNEDLONG, isComp AS_BYTE READ ogSize, resize, isComp ' read the header
DIM buffer ASSTRING: buffer = SPACE$(resize) ' preallocate complete buffer