用DevicesCollection 枚举电脑的多个声卡设备(播放设备/音频输出设备),
通过他们的GUID创建播放声音的设备,遍历够就能在两个声卡上听到声音,下面是简要的C#代码:
Microsoft.DirectX.DirectSound.DevicesCollection sound_devices = new Microsoft.DirectX.DirectSound.DevicesCollection();
foreach (object sound in sound_devices)
{
Microsoft.DirectX.DirectSound.DeviceInformation deviceinfo =( Microsoft.DirectX.DirectSound.DeviceInformation)sound ;
if (string.IsNullOrEmpty (deviceinfo.ModuleName )) continue;
MessageBox.Show(deviceinfo.ToString());
Microsoft.DirectX.DirectSound.Device sound_device_output = new Microsoft.DirectX.DirectSound.Device(deviceinfo.DriverGuid);
sound_device_output.SetCooperativeLevel(this, Microsoft.DirectX.DirectSound.CooperativeLevel.Normal);//设置设备协作级别
Microsoft.DirectX.DirectSound.BufferDescription buffDes = new Microsoft.DirectX.DirectSound.BufferDescription();
buffDes.GlobalFocus = true;//设置缓冲区全局获取焦点
buffDes.ControlVolume = true;//指明缓冲区可以控制声音
buffDes.ControlPan = true;//指明缓冲区可以控制声道平衡
Microsoft.DirectX.DirectSound.SecondaryBuffer secondary_buffer = new Microsoft.DirectX.DirectSound.SecondaryBuffer(textBox1.Text, buffDes, sound_device_output);//创建辅助缓冲区
secondary_buffer.Play(0, Microsoft.DirectX.DirectSound.BufferPlayFlags.Looping);//设置缓冲区为循环播放
}
问题是如果实现声音同步在两个设备上播放,比如一个realtek的集成声卡和一个USB Audio Device,努力ing
本文介绍如何使用C#编程语言通过DirectX库枚举并利用电脑上的多个声卡设备(如Realtek集成声卡和USB音频设备)进行声音播放的方法。文章提供了具体的代码示例,并探讨了如何实现声音在不同声卡间的同步播放。

366

被折叠的 条评论
为什么被折叠?



