remstart
createsound("c0",0,10,268,5000,1000,0,0,1000,10,0,0,1000) `note c etc Slegh bells
createsound("d0",0,11,301,5000,1000,0,0,1000,10,0,0,1000)
createsound("e0",0,12,337,5000,1000,0,0,1000,10,0,0,1000)
createsound("f0",0,13,358,5000,1000,0,0,1000,10,0,0,1000)
createsound("g0",0,14,401,5000,1000,0,0,1000,10,0,0,1000)
createsound("a0",0,15,451,5000,1000,0,0,1000,10,0,0,1000)
createsound("b0",0,16,506,5000,1000,0,0,1000,10,0,0,1000)
createsound("c1",0,17,536,5000,1000,0,0,1000,10,0,0,1000)
createsound("d1",0,18,602,5000,1000,0,0,1000,10,0,0,1000)
createsound("e1",0,19,675,5000,1000,0,0,1000,10,0,0,1000)
remend
remstart
createsound("c0",0,10,268,5000,1000,0,0,0,0,3,3000,1000) `note c etc organ
createsound("d0",0,11,301,5000,1000,0,0,0,0,3,3000,1000)
createsound("e0",0,12,337,5000,1000,0,0,0,0,3,3000,1000)
createsound("f0",0,13,358,5000,1000,0,0,0,0,3,3000,1000)
createsound("g0",0,14,401,5000,1000,0,0,0,0,3,3000,1000)
createsound("a0",0,15,451,5000,1000,0,0,0,0,3,3000,1000)
createsound("b0",0,16,506,5000,1000,0,0,0,0,3,3000,1000)
createsound("c1",0,17,536,5000,1000,0,0,0,0,3,3000,1000)
createsound("d1",0,18,602,5000,1000,0,0,0,0,3,3000,1000)
createsound("e1",0,19,675,5000,1000,0,0,0,0,3,3000,1000)
remend
`remstart
createsound("c0",0,10,268,5000,1000,0,0,0,0,0,0,1000) `note c etc Pure
createsound("d0",0,11,301,5000,1000,0,0,0,0,0,0,1000)
createsound("e0",0,12,337,5000,1000,0,0,0,0,0,0,1000)
createsound("f0",0,13,358,5000,1000,0,0,0,0,0,0,1000)
createsound("g0",0,14,401,5000,1000,0,0,0,0,0,0,1000)
createsound("a0",0,15,451,5000,1000,0,0,0,0,0,0,1000)
createsound("b0",0,16,506,5000,1000,0,0,0,0,0,0,1000)
createsound("c1",0,17,536,5000,1000,0,0,0,0,0,0,1000)
createsound("d1",0,18,602,5000,1000,0,0,0,0,0,0,1000)
createsound("e1",0,19,675,5000,1000,0,0,0,0,0,0,1000)
createsound("f1",0,20,716,5000,1000,0,0,0,0,0,0,1000)
createsound("g1",0,21,803,5000,1000,0,0,0,0,0,0,1000)
createsound("a1",0,22,902,5000,1000,0,0,0,0,0,0,1000)
`remend
remstart
createsound("c0",0,10,268,5000,1000,0,0,1000,10,1,100,1000) `note c etc Slegh bells
createsound("d0",0,11,301,5000,1000,0,0,1000,10,1,100,1000)
createsound("e0",0,12,337,5000,1000,0,0,1000,10,1,100,1000)
createsound("f0",0,13,358,5000,1000,0,0,1000,10,1,100,1000)
createsound("g0",0,14,401,5000,1000,0,0,1000,10,1,100,1000)
createsound("a0",0,15,451,5000,1000,0,0,1000,10,1,100,1000)
createsound("b0",0,16,506,5000,1000,0,0,1000,10,1,100,1000)
createsound("c1",0,17,536,5000,1000,0,0,1000,10,1,100,1000)
createsound("d1",0,18,602,5000,1000,0,0,1000,10,1,100,1000)
createsound("e1",0,19,675,5000,1000,0,0,1000,10,1,100,1000)
remend
Notelength=timer()
do
playing=0
If Notelength<timer() and pause=0
read notelength
notelength=notelength+timer()
for temp= 10 to 22
if sound playing(temp)=1 then stop sound temp
next temp
pause=1
pausetimer=Timer()+5
endif
if timer()>pausetimer and pause=1
read note$
if note$="end" then restore
if note$="c0" then loop sound 10
if note$="d0" then loop sound 11
if note$="e0" then loop sound 12
if note$="f0" then loop sound 13
if note$="g0" then loop sound 14
if note$="a0" then loop sound 15
if note$="b0" then loop sound 16
if note$="c1" then loop sound 17
if note$="d1" then loop sound 18
if note$="e1" then loop sound 19
if note$="f1" then loop sound 20
if note$="g1" then loop sound 21
if note$="a1" then loop sound 22
pause=0
endif
loop
`junglebells:
`verse:
`data 250,"d0",250,"b0",250,"a0",250,"g0",750,"d0",125,"d0",125,"d0",250,"d0",250,"b0",250,"a0",250,"g0",1000,"e0",250,"e0",250,"c1",250,"b0",250,"a0",500,"f0",250,"d1",250,"d1",250,"c1",250,"a0",1000,"b0"
`data 250,"d0",250,"b0",250,"a0",250,"g0",1000,"d0",250,"d0",250,"b0",250,"a0",250,"g0",750,"e0",250,"e0",250,"e0",250,"c1",250,"b0",250,"a0",250,"d1",250,"d1",250,"d1",250,"d1",250,"e1",250,"d1",250,"c1",250,"a0",1000,"g0"
`chorus:
`data 250,"e0",250,"e0",500,"e0",250,"e0",250,"e0",500,"e0",250,"e0",250,"g0",250,"c0",250,"d0",1000,"e0"
`data 250,"f0",250,"f0",500,"f0",250,"f0",250,"e0",500,"e0",250,"e0",250,"d0",250,"d0",250,"e0",500,"d0",500,"g0"
`data 250,"e0",250,"e0",500,"e0",250,"e0",250,"e0",500,"e0",250,"e0",250,"g0",250,"c0",250,"d0",1000,"e0"
`data 250,"f0",250,"f0",500,"f0",250,"f0",250,"e0",500,"e0",250,"g0",250,"g0",250,"f0",250,"d0",1000,"c0"
`verse
data 250,"d0",250,"b0",250,"a0",250,"g0",750,"d0",125,"d0",125,"d0",250,"d0",250,"b0",250,"a0",250,"g0",1000,"e0",250,"e0",250,"c1",250,"b0",250,"a0",500,"f0",250,"d1",250,"d1",250,"c1",250,"a0",1000,"b0"
data 250,"d0",250,"b0",250,"a0",250,"g0",1000,"d0",250,"d0",250,"b0",250,"a0",250,"g0",750,"e0",250,"e0",250,"e0",250,"c1",250,"b0",250,"a0",250,"d1",250,"d1",250,"d1",250,"d1",250,"e1",250,"d1",250,"c1",250,"a0",1000,"g0"
`chorus
data 250,"b0",250,"b0",500,"b0",250,"b0",250,"b0",500,"b0",250,"b0",250,"d1",375,"g0",125,"a0",500,"b0",250,"c1",250,"c1",375,"c1",125,"c1",250,"c1",250,"b0",250,"b0",125,"b0",125,"b0",250,"b0",250,"a0",250,"a0",250,"b0",500,"a0",500,"d0"
data 250,"b0",250,"b0",500,"b0",250,"b0",250,"b0",500,"b0",250,"b0",250,"d1",375,"g0",125,"a0",500,"b0",250,"c1",250,"c1",375,"c1",125,"c1",250,"c1",250,"b0",250,"b0",125,"b0",125,"b0",250,"d1",250,"d1",250,"c1",250,"a0",1000,"g0",1000," "
`return
`We Wish you a merry christmas
data 500,"a0",500,"d1",250,"d1",250,"e1",250,"d1",250,"c1",500,"b0",500,"b0",500,"b0",500,"e1",250,"e1",250,"f1",250,"e1",250,"d1",500,"c1",500,"a0",500,"a0"
data 500,"f1",250,"f1",250,"g1",250,"f1",250,"e1",500,"d1",500,"b0",250,"a0",250,"a0",500,"b0",500,"e1",500,"c1",1000,"d1",500,"a0"
data 500,"d1",500,"d1",500,"d1",1000,"c1",500,"c1",500,"d1",500,"c1",500,"b0",1000,"a0",500,"e1"
data 500,"f1",500,"e1",500,"d1",500,"a1",500,"a0",250,"a0",250,"a0",500,"b0",500,"e1",500,"c1",1000,"d1",1000," "
`Away in a manger
data 500,"d1",750,"d1",250,"c1",500,"b0",500,"b0",500,"a0",500,"g0",500,"g0",500,"f0",500,"e0",1000,"d0",500,"d0"
data 750,"d0",250,"e0",500,"d0",500,"d0",500,"a0",500,"f0",500,"e0",500,"d0",500,"g0",1000,"b0",500,"d1"
data 750,"d1",250,"c1",500,"b0",500,"b0",500,"a0",500,"g0",500,"g0",500,"f0",500,"e0",1000,"d0",500,"d0"
data 750,"c1",250,"b0",500,"a0",500,"b0",500,"a0",500,"g0",500,"a0",500,"e0",500,"f0",1000,"g0",1000,"end"
function createsound(name$,soundtype,soundnumber,frequency#,length#,loudness#,bend#,decay#,vibratospeed#,vibratodepth#,tremelospeed#,tremelodepth#,attack#)
outWord as word
dword1 as dword: dword2 as dword: dword3 as dword: dword4 as dword
dword5 as dword: dword6 as dword: dword7 as dword
samples=int((length#/1000)*44100)
if memblock exist(1) then delete memblock 1
make memblock 1,samples*2+44
` write 28 memblock header bytes
dword1=1 ` gg query: is this the number of channels?
dword2=2
dword3=22050 ` gg query: seems to be half the number of samples per second - why?
dword4=88200 ` gg query: is this the number of bytes per second?
dword5=4 ` gg query: what does this represent?
dword6=16 ` gg query: (ditto) ?
dword7=0 ` gg query: (ditto) ?
position=0
write memblock byte 1, position, asc("R") : inc position
write memblock byte 1, position, asc("I") : inc position
write memblock byte 1, position, asc("F") : inc position
write memblock byte 1, position, asc("F") : inc position
write memblock dword 1, position, samples*2+36 : inc position,4
write memblock byte 1, position, asc("W") : inc position
write memblock byte 1, position, asc("A") : inc position
write memblock byte 1, position, asc("V") : inc position
write memblock byte 1, position, asc("E") : inc position
write memblock byte 1, position, asc("f") : inc position
write memblock byte 1, position, asc("m") : inc position
write memblock byte 1, position, asc("t") : inc position
write memblock byte 1, position, asc(" ") : inc position
write memblock dword 1, position, 16 : inc position,4
write memblock word 1, position, dword1 : inc position,2
write memblock word 1, position, dword2 : inc position,2
write memblock dword 1, position, dword3 : inc position,4
write memblock dword 1, position, dword4 : inc position,4
write memblock word 1, position, dword5 : inc position,2
write memblock word 1, position, dword6 : inc position,2
write memblock byte 1, position, asc("d") : inc position
write memblock byte 1, position, asc("a") : inc position
write memblock byte 1, position, asc("t") : inc position
write memblock byte 1, position, asc("a") : inc position
write memblock dword 1, position, samples*2 : inc position,4
rem generate and write wave
if file exist(name$+".wav")=1 then delete file name$+".wav"
`inc param_attackamount#,0.0001
riseinloudness#=loudness#
for x=1 to samples
outInteger=int(sin((x/122.5)*(frequency#+vibratodepth#*sin(theta#)))*(loudness#-fallinloudness#-riseinloudness#+tremelodepth#*sin(phi#)))*3.0
if outInteger <-32767 then outInteger=-32767 ` gg query: is this the valid range?
if outInteger>32767 then outInteger=32767 ` gg query: (ditto) ?
outWord=outInteger
inc theta#,vibratospeed#
inc phi#,tremelospeed#
dec frequency#,bend#
if fallinloudness#<loudness#
inc fallinloudness#,decay#
endif
if riseinloudness#>0
dec riseinloudness#,attack#
endif
write memblock word 1,position,outWord : inc position,2
next x
open to write 1,name$+".wav"
make file from memblock 1,1
close file 1
if sound exist(soundnumber)=1 then delete sound soundnumber
if soundtype
load 3dsound name$+".wav", soundnumber
else
load sound name$+".wav", soundnumber
endif
` memblock no longer required
delete memblock 1
endfunction
Thought i was being very clever using a modified version of rics sound system I found in the codebase, and frequencies which I found in my old commodore 64 Manual, to give a couple of octaves of notes. Then I seen when browsing that last year some guy made MIDIs In much the same way. Only I’m sure they sound better. Well anyway thought this code might help, I will be using some form of it in my entry.