当前位置:编程学习 > VB >>

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

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。
请问如何才能设置采样频率呢?
谢谢! --------------------编程问答-------------------- 这个是一回事,然而声卡也要支持 --------------------编程问答-------------------- 查了好多资料,都是这样是可以的,但我试来试去,就是不成。
急啊 --------------------编程问答-------------------- 不需要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
--------------------编程问答-------------------- 原来这样录音啊,学习~ --------------------编程问答-------------------- 这样就可以了:
开始录音,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) --------------------编程问答-------------------- 什么呀 --------------------编程问答-------------------- 请教:在:mciSendString( "open   new   type   waveaudio   alias   MyRecord ",   0&,   0,   0) 
中,如何用声卡2录音呢?
补充:VB ,  多媒体
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,