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。
请问如何才能设置采样频率呢?
谢谢!

解决方案 »

  1.   

    不需要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 LongPrivate 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 SubPrivate 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
      

  2.   

    这样就可以了:
    开始录音,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)
      

  3.   

    请教:在:mciSendString( "open   new   type   waveaudio   alias   MyRecord ",   0&,   0,   0) 
    中,如何用声卡2录音呢?