您的位置:程序门 -> vb -> 多媒体



用mci控件录音时如何设置采样频率?


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


用mci控件录音时如何设置采样频率?
发表于:2007-03-14 18:01:52 楼主
mci默认的采样频率为11k,8bit,想设置不16k,16bit
代码如下:
szbuf   =   space(257)
mm.notify   =   false
mm.wait   =   true
mm.shareable   =   false
mm.devicetype   =   "waveaudio "
mcisendstring   "set   waveaudio   bitpersample   16   samplespersec   16000 ",   szbuf,   256,   0
if   right$(app.path,   1)   =   "\ "   then   ph   =   app.path   else   ph   =   app.path   &   "\ "
mm.command   =   "close "
mm.filename   =   ph   &   "recorder.wav "
mm.command   =   "open "
但录音后,仍为11k。
请问如何才能设置采样频率呢?
谢谢!
发表于:2007-03-14 19:10:091楼 得分:0
这个是一回事,然而声卡也要支持
发表于:2007-03-19 16:11:332楼 得分:0
查了好多资料,都是这样是可以的,但我试来试去,就是不成。
急啊
发表于:2007-03-19 16:49:253楼 得分:0
不需要mmcontrol,   直接用api函数mcisendstring就行了:

private   declare   function   mcisendstring   lib   "winmm.dll "   alias   "mcisendstringa "   _
                (byval   lpstrcommand   as   string,   byval   lpstrreturnstring   as   string,   _
                byval   ureturnlength   as   long,   byval   hwndcallback   as   long)   as   long

private   sub   command1_click()
        '开始录音
        dim   iret   as   long
        iret   =   mcisendstring( "open   new   type   waveaudio   alias   myrecord ",   0&,   0,   0)
        iret   =   mcisendstring( "set   myrecord   bitspersample   16   samplespersec   16384 ",   0&,   0,   0)    
        iret   =   mcisendstring( "record   myrecord   overwrite ",   0&,   0,   0)
end   sub

private   sub   command2_click()
        '保存录音
        dim   iret   as   long
        iret   =   mcisendstring( "save   myrecord   c:\1.wav ",   0&,   0,   0)
        iret   =   mcisendstring( "close   myrecord ",   0&,   0,   0)
end   sub
发表于:2007-03-19 18:02:574楼 得分:0
原来这样录音啊,学习~
发表于:2007-03-20 19:52:375楼 得分:0
这样就可以了:
开始录音,wav1.wav是个已经存在的按制定格式制作的wav文件
s   =   "open   c:\test\wav1.wav   type   waveaudio   alias   wave "
errorcode   =   mcisendstring(s,   resturnstr,   256,   0)
errorcode   =   mcisendstring( "seek   wave   to   start ",   resturnstr,   256,   0)
errorcode   =   mciEXECute( "record   wave ")


停止并保存录音,按wav1.wav文件格式保存
errorcode   =   mcisendstring( "stop   wave ",   resturnstr,   256,   0)
errorcode   =   mcisendstring( "save   wave   "   &   filename,   resturnstr,   256,   0)
errorcode   =   mcisendstring( "close   wave ",   resturnstr,   256,   0)


快速检索

最新资讯
热门点击