| 发表于:2007-01-14 00:55:091楼 得分:0 |
private sub drawwav() dim picwidth, picheight as integer dim lx, ly, x, y as integer ' 上一个采样点座标与新采样点座标 dim i as long static nowposition, lastposition as long '当前位置与上一次位置 dim bufsize as long '缓冲区与缓冲区大小 dim index as long picwidth = picwav.scalewidth picheight = picwav.scaleheight '获取文件播放位置 需要使用 dscursors 数据来获取 dscb.getcurrentposition capcurs '当前播放指针位置 nowposition = capcurs.lplay '如果不录音则退出 if nowposition = 0 then exit sub ' 计算上次和这次的位置,得到一个值 bufsize = nowposition - lastposition 'dsd.lbufferbytes = bufsize 'dsd.lflags = dsbcaps_ctrlvolume or dsbcaps_static dscd.lbufferbytes = bufsize '重定义数组 redim bytebuffer(bufsize) dscb.readbuffer lastposition, bufsize, bytebuffer(0), dscblock_default picwav.forecolor = vbgreen picwav.cls lx = 0 ly = picheight / 2 for i = 0 to width index = int(bufsize / picwidth) y = (bytebuffer(index) + 32768) * picheight / 65536 'for test movetoex picwav.hdc, lx, ly, xy lineto picwav.hdc, i, y 'movetoex picwav.hdc, lx, ly, xy ' lineto picwav.hdc, i, y ly = y lx = i next picwav.refresh 'lastposition = nowposition end sub | | |
|