2

古いVB6アプリを更新しています。昔は、オーディオを録音および再生できるように、mciSendStringコマンドのラッパーをコーディングしていました。当時、コンピュータには通常1枚のオーディオカードがありました。

現在、多くの顧客は複数のサウンドカードを持っています(通常は1つとUSBヘッドセットが組み込まれています)。

mciSendStringで使用するサウンドカードを指定するAPIが見つからないようです。誰かが私を正しい方向に向けることができますか?

4

2 に答える 2

2

ソースコード(Ergebnisse des Wettbewerbs /ドイツ語)を使用して、ここでいくつかのソリューションを確認してください:http: //www.activevb.de/rubriken/wettbewerbe/2009_september/comp_2009_september_mp3_player.html

ここに私のプロジェクトのいくつかのソースがあります

''' <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を使用して、記録と使用を開始します。お役に立てば幸い

于 2011-10-25T14:26:52.343 に答える
1

マイクロソフトは答えを提供しました。

マルチメディアコントロールで使用されるWaveAudioデバイス(サウンドカード)を設定するには、mciSendCommandAPIを使用する必要があります。マルチメディアコントロールは、再生または記録に使用するデバイスを設定する方法を直接提供していません。

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)
于 2012-11-10T07:18:19.483 に答える