N
N
Nikolay L2018-06-25 18:41:28
Windows
Nikolay L, 2018-06-25 18:41:28

How to output sound to two devices at the same time?

Audio devices are connected to the green socket of the integrated sound card.
You need to output sound at the same time using C# code.
What methods and libraries to use?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Nemiro, 2018-06-25
@kolyaL

If all devices are connected to the same socket, then it is apparently enough to simply play the sound, in any convenient way.
More complex things can be done with NAudio for example .

var searcher = new System.Management.ManagementObjectSearcher("SELECT * FROM Win32_SoundDevice");
var devices = searcher.Get();
foreach (var device in devices) 
{
  Console.WriteLine(device.GetPropertyValue("Caption").ToString());
}

// ...

var waveReader = new NAudio.Wave.WaveFileReader(fileName);
var waveOut = new NAudio.Wave.WaveOut();
waveOut.DeviceNumber = deviceNumber;

var output = new NAudio.Wave.DirectSoundOut();
output = waveOut;
output.Init(waveReader);
output.Play();

G
GavriKos, 2018-06-25
@GavriKos

Audio devices are connected to the green socket of the integrated sound card.

From the driver's point of view, this is one device. Namely - "green nest". Anything further is not controlled by the OS.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question