开发者

Send sound to different audio devices

Is it possible to play a sound on a playback device that is not set as default playback device? I need to play multiple files simultaniously trough multiple o开发者_如何学JAVAutput devices.

Does anyone knows a solution for .net? (C#)

Thanks!


you will have to go to lower level API. You can try find C# wrapper for Wasapi, ASIO, DirectSound or MediaFoundation. Maybe XNA framework could do the job, which is managed framework over directX


well I was playing around with similar issue.

  1. XNA could not do send output to specific device.
  2. I have ended out with http://naudio.codeplex.com/, which is exactly what you need. It's C# wrapper for Wasapi, ASIO, DirectSound libraries. It also includes many very helpful classes for converting, decoding, visualizing etc. For simple player, check out NAudioDemo sample project.

find out CreateWaveOut() method. This is where you should select your playbackdevice. for example:

MMDevice device = new MMDeviceEnumerator()
     .EnumerateAudioEndPoints(DataFlow.Render, DeviceState.All)
     .FirstOrDefault(d => d.ID == "yourplaybackdeviceid");
IWavePlayer waveOut = new WasapiOut(device, AudioClientShareMode.Shared, false, latency);

Download the naudio library from sourcecode tab not from Download->Release, it's not very actual and it's little buggy.


another good tool is bass.net http://www.un4seen.com/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜