Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 output devices.

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

Thanks!

like image 451
herman Avatar asked Nov 05 '22 00:11

herman


1 Answers

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.

like image 196
Liero Avatar answered Nov 09 '22 16:11

Liero