Click here to Skip to main content
12,503,947 members (58,849 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: DirectSound
A few years ago I wrote some software for amateur radio that generates a morsecode ID on a user selected interval and send it over your radio to identify your station automatically.(This is a 10 minute interval for US stations). Recently I got a request to allow the option of choosing a secondary sound device (like a usb soundcard) that isn't the OS's primary default device.

I've spent a few days searching and have found some examples using C++ but very little for C#.

using Microsoft.DirectX.DirectSound;
public class wfEnum : System.Windows.Forms.Form
private DevicesCollection myDevices = null;
private struct myDeviceDescription
{
    public DeviceInformation info;
    public override string ToString()
    {
        return info.Description;
    }
        public myDeviceDescription(DeviceInformation di)
        {
            info = di;
        }
}
public wfEnum()
{
    // Retrieve the available DirectSound devices
    myDevices = new DevicesCollection();
    
    foreach (DeviceInformation dev in myDevices)
    {
        myDeviceDescription dd = new myDeviceDescription(dev);
        
        // Use DevicesCollection and DeviceInformation to query for devices.
    }
[C#]using Microsoft.DirectX.DirectSound;
public class wfEnum : System.Windows.Forms.Form
private DevicesCollection myDevices = null;
private struct myDeviceDescription
{
    public DeviceInformation info;
    public override string ToString()
    {
        return info.Description;
    }
        public myDeviceDescription(DeviceInformation di)
        {
            info = di;
        }
}
public wfEnum()
{
    // Retrieve the available DirectSound devices
    myDevices = new DevicesCollection();
    
    foreach (DeviceInformation dev in myDevices)
    {
        myDeviceDescription dd = new myDeviceDescription(dev);
        
        // Use DevicesCollection and DeviceInformation to query for devices.
    }



and

private Device dsDevice = null;
dsDevice = new Device();

and

dsDevice = new Device(deviceGuid);

all seem to point in the right direction, but I can't get my head wrapped around how to implement this into my project solution.

I want to enumerate the sound devices and select the device I want my program to use. I would like it to remember my settings for later use and possibly even give an option to allow different users to have different settings.

Any help with this would be very appreciated.

Please email me to let me know you've responded. secretary at elevated wire dot org. Thanks

Posted 26-Mar-12 11:25am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160919.1 | Last Updated 26 Mar 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100