首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何指定用于mciSendString API的声卡

如何指定用于mciSendString API的声卡
EN

Stack Overflow用户
提问于 2011-06-04 14:34:59
回答 2查看 2.2K关注 0票数 2

我正在更新一个旧的VB6应用程序。当时,我在mciSendString命令周围编写了一个包装器,以便能够录制和回放音频。当时,计算机通常只有一块声卡。

现在,许多客户都有多个声卡(通常是内置声卡和USB耳机)。

我似乎找不到指定mciSendString使用哪块声卡的接口。谁能给我指个方向?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-11-10 15:18:19

微软提供了answer

要设置多媒体控件使用的WaveAudio设备(声卡),必须使用mciSendCommand API。多媒体控件不直接提供让您设置播放或录制所使用的设备的方法。

代码语言:javascript
复制
Dim parms As MCI_WAVE_SET_PARMS
Dim rc As Long

' Specify the soundcard. This specifies the soundcard with a deviceID
' of 0. If you have a single soundcard, then this will open it. If you
' have multiple soundcards, the deviceIDs will be 0, 1, 2, etc.
parms.wOutput = 0

' Send the MCI command to set the output device.
rc = mciSendCommand(MMControl1.DeviceID, MCI_SET, MCI_WAVE_OUTPUT, parms)
票数 1
EN

Stack Overflow用户

发布于 2011-10-25 22:26:52

请在这里查看源码(Ergebnisse des Wettbewerbs /德语)的几个解决方案:http://www.activevb.de/rubriken/wettbewerbe/2009_september/comp_2009_september_mp3_player.html

下面是我的项目的一些源代码

代码语言:javascript
复制
''' <summary>
''' Return all audio devices by names
''' </summary>
Private Function ListSoundDevices(ByRef LDev As List(Of String)) As Boolean

    Dim intItem As New Integer
    Dim intNext As New Integer
    Dim intCount As New Integer
    Dim tWIC As New WaveInCaps
    Dim Enc As System.Text.ASCIIEncoding = New System.Text.ASCIIEncoding()
    Dim res As Boolean = False

    Try
        'Throw New Exception("test")
        intCount = waveInGetNumDevs()
    Catch ex As Exception
        'no devices found
        Return False
    End Try

    If intCount <> 0 Then
        For intItem = 0 To intCount - 1
            If waveInGetDevCaps(intItem, tWIC, Marshal.SizeOf(tWIC)) = MMSYSERR_NOERROR Then
                If (tWIC.Formats And WAVE_FORMAT_4S16) = WAVE_FORMAT_4S16 Then
                    If LDev Is Nothing Then LDev = New List(Of String)
                    Dim B() As Byte = System.Text.Encoding.Default.GetBytes(tWIC.ProductName.ToString.ToCharArray)
                    LDev.Add(Enc.GetString(B, 0, B.Length))
                    intNext += 1
                End If
            End If
        Next

        If intNext > 0 Then res = True
    End If

    Return res
End Function

使用设备ID开始录制和使用。希望这能有所帮助

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6235179

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档