Rogerson Nazário
Rogerson Nazário

Reputation: 342

Get the name of the sound devices in C#

I need to get the names of a computer sound drivers. Put it in a list or string. All that I found was a "int" return methods of the "winmm.dll", like "waveInGetDevCapsA" and "waveInGetDevCapsW".

Upvotes: 0

Views: 3356

Answers (1)

user1222021
user1222021

Reputation:

If you want to enumerate audio devices, it becomes very easy by using SlimDX. It requires DirectX to be installed in the computer though.

For example, to enumerate the audio capture devices:

 DeviceCollection coll = DirectSoundCapture.GetDevices();
 foreach( DeviceInformation dev in coll ) {
    ...

 }

To enumerate audio playback devices:

DeviceCollection coll = DirectSound.GetDevices();
   foreach( DeviceInformation di in coll ) {

   }

The DeviceInformation class has a Description property of type string. It also has a DriverGuid property of type Guid that enables you to "select" the device to perform either audio capture or playback (that can also be done by means of SlimDX).

EDIT: a method using Winmm.dll Please take a look at the following entry in Code Project. It builds an enumerator using Winmm.dll only.

Hope this helps!

Upvotes: 4

Related Questions