Directsound控制声道出现问题,请大家帮忙看看问题出在哪里,拜托了!
我想用directsound做一个可以控制左右声道的小程序。程序可以运行,但是播放音频文件的时候会出现一个错误。想请大家帮我看看问题处在哪里。
问题描述如下:
按“play”按钮播放声音的时候
Buf = New SecondaryBuffer("D:\11.WAV", BD, Dev)
语句会出现一个“ArgumentException”的错误。
编程环境:Windows Vista;Microsoft Vusial Studio 2008
已添加Microsoft.DirectX & Microsoft.DirectX.DirectSound的引用
Imports Microsoft.DirectX
Imports Microsoft.DirectX.DirectSound
Public Class Form1
Dim Dev As Device '声明设备
Dim Buf As SecondaryBuffer '声明缓冲区
Private Sub Btn_Play_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Play.Click
Dev = New Device
Dim BD As New BufferDescription '初始化描述
BD.ControlPan = True '允许修改声道
BD.Flags = BufferDescriptionFlags.GlobalFocus
Dev.SetCooperativeLevel(Me.Handle, CooperativeLevel.Normal) '绑定设备到窗口
Buf = New SecondaryBuffer("D:\11.WAV", BD, Dev) '通过描述初始化缓冲区
Buf.Play(0, BufferPlayFlags.Looping) '播放声音
End Sub
Private Sub Btn_Left_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Left.Click
Buf.Pan = -10000
End Sub
Private Sub Btn_Right_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Right.Click
Buf.Pan = 10000
End Sub
End Class --------------------编程问答-------------------- 请大家帮帮忙啊,我实在是搞不定啊!!!
补充:.NET技术 , VB.NET