+ Code Snippetsync on : sync rate 40
load sound "your_sound.wav",1
make memblock from sound 1,1
DrawMonoSnd(0,0,639,255,1,0,100,rgb(0,0,128),rgb(255,255,255),0)
DrawMonoSnd(0,300,320,364,1,0,100,rgb(128,0,0),rgb(255,255,0),1)
sync
wait key
delete memblock 1
end
Function DrawMonoSnd(left,top,right,bottom,block,startpercent#,endpercent#,bckcol,wavcol,drawmode)
` left, top, right, bottom = boxed area to draw sound
` block = number of memblock containing sound
` startpercent# = where to draw from in sound data
` endpercent# = where to draw to in sound data
` bckcol = background color
` wavcol = wav color
` drawmode = 0 for dot, 1 for line
width = (right - left) + 1
height = (bottom - top) + 1
centerline = top + height/2
vscale# = (height/2.0)/127.0
blocksize = get memblock size(block)
startpos = int((blocksize-12) * (startpercent#/100.0))
endpos = int((blocksize-12) * (endpercent#/100.0))
startpos = startpos + 12
endpos = endpos + 12
if startpos < 12 then startpos = 12
if endpos > blocksize then endpos = blocksize
skip = (endpos - startpos) / ((right - left) + 1)
if skip < 1 then skip = 1
` draw background and set wav color
ink bckcol,0 : box left,top,right+1,bottom+1
ink wavcol,0
x = left-1
while (startpos < endpos) and (x <= right)
` read value from sound byte
v = memblock byte(block,startpos) - 127
x = x + 1
y = centerline + (v * vscale#)
startpos = startpos + skip
if drawmode = 1
` draw as lines
if x > left then line lastx,lasty,x,y
lastx = x : lasty = y
else
` draw as dots
box x,y,x+1,y+1
endif
endwhile
endfunction