How can I select the output device with NAudio

Mar 13, 2013 at 11:25 AM
Hi,
I am able to select the input device, eg. one of four microphones with the input deviceNumber:
sourceStream.WaveFormat = new WaveFormat(44100,   WaveIn.GetCapabilities(deviceNumber).Channels);
But how can I also select the output device (e.g. one of four speakers) ?
      public void StartMicro(int deviceNumber)
      {
         sourceStream = new WaveIn();
         sourceStream.DeviceNumber = deviceNumber;
         sourceStream.WaveFormat = new WaveFormat(44100,    WaveIn.GetCapabilities(deviceNumber).Channels);

         waveIn = new WaveInProvider(sourceStream);
         waveOut = new DirectSoundOut();
         waveOut.Init(waveIn);

         sourceStream.StartRecording();
         waveOut.Play();
      }
Right now it takes only the default output device (speaker). I have chosen the DirectSoundOut Api for the output device because of less latency as against the WaveOut device. I have already the device number for my output device. But how can I select with the device number (index) the output device ?

It must be like this:
waveOut = new DirectSoundOut(outDeviceNumber);
but it doesn't work.

Regards,
Lestan
Coordinator
Mar 19, 2013 at 10:11 AM
The NAudioDemo code shows how to select a specific DirectSoundOut device. You'd need to enumerate the output devices into a list, and then you can index that by output device number.