G'Afternoon,
I'm attempting to mix two wavs using memblocks.
` mix down 1
`
setvirtualresolution(640,480)
`
loadsound(1,"1.wav") ` "1,2,3,4,2,2,3,4,3,2,3,4,4,2,3,4"
loadsound(2,"2.wav") ` "you can mix down sounds using memblocks, yes you can, using memblocks you can mix down"
`
creatememblockfromsound(1,1)
creatememblockfromsound(2,2)
`
dim channels[2] : dim bitspersample[2] : dim samplespersecond[2] : dim numberofframes[2] : dim sounddatainbytes[2]
`
channels[1] = getmemblockshort(1,0) : channels[2] = getmemblockshort(2,0)
bitspersample[1] = getmemblockshort(1,2) : bitspersample[2] = getmemblockshort(2,2)
samplespersecond[1] = getmemblockint(1,4) : samplespersecond[2] = getmemblockint(2,4)
numberofframes[1] = getmemblockint(1,8) : numberofframes[2] = getmemblockint(2,8)
sounddatainbytes[1] = numberofframes[1]*(bitspersample[1]/8)*channels[1]
sounddatainbytes[2] = numberofframes[2]*(bitspersample[2]/8)*channels[2]
`
if sounddatainbytes[1]>sounddatainbytes[2] : memblocksize3 = sounddatainbytes[1] : n=1 : endif
if sounddatainbytes[1]<sounddatainbytes[2] : memblocksize3 = sounddatainbytes[2] : n=2 : endif
if sounddatainbytes[1]=sounddatainbytes[2] : memblocksize3 = sounddatainbytes[1] : n=1 : endif
`
creatememblock(3,memblocksize3+13)
setmemblockshort(3,0,channels[n])
setmemblockshort(3,2,bitspersample[n])
setmemblockint(3,4,samplespersecond[n])
setmemblockint(3,8,numberofframes[n])
`
for t = 13 to memblocksize3
setmemblockbyte(3,t,(getmemblockbyte(1,t)+getmemblockbyte(2,t)))
next t
`
createsoundfrommemblock(3,3)
`
playsound(3)
`
setprintsize(12)
`
do
`
print("channels1 "+str(channels[1])+" : "+"channels2 "+str(channels[2]))
print("bits per sample 1 "+str(bitspersample[1])+" : "+"bits per sample 2 "+str(bitspersample[2]))
print("samples per second 1 "+str(samplespersecond[1])+" : "+"samples per second 2 "+str(samplespersecond[2]))
print("number of frames 1 "+str(numberofframes[1])+" : "+"number of frames 2 "+str(numberofframes[2]))
print("sound data in bytes 1 "+str(sounddatainbytes[1])+" : "+"sound data in bytes 2 "+str(sounddatainbytes[2]))
`
sync()
loop
The "mixdown" happens but with lots of static (whitish noise).
I know this is rather ambitious with AppGameKit but I'm so close.
Does anyone have any ideas how to make it work properly.
Also, can the 'record sound' command be functional sooner rather than later.
I'd love to be able to make a multi-track recorder for Android.
festive regards,
miki.
in the end