1

I've found this information on SO about how to enumerate the sound device info on with .NET, but I don't really know how to use this information with Python. As you can probably tell, I have almost zero experience with Windows API programming.

I can figure out how to get basic information via WMI, but I need more information, and it looks like maybe the following C# code snippet is what I need, but I just don't know how to access DirectSound objects from Python. I've figured out some basic stuff with ctypes, but I don't know which or how to load the DirectX .dll...

DevicesCollection devColl = new DevicesCollection();
    foreach (DeviceInformation devInfo in devColl)
    {
        Device dev = new Device(devInfo.DriverGuid);   

        //use dev.Caps, devInfo to access a fair bit of info about the sound device
    }

Any pointers?

Community
  • 1
  • 1
Dustin Wyatt
  • 4,046
  • 5
  • 31
  • 60

1 Answers1

1

For a "poor man's" .NET library access, take a look at "Python for .NET".

However, it is potentially easier to access DirectSound devices with IronPython due to its .NET bindings via its clr library.

Tips from IronPython cookbook:

Playing an MP3 song with DirectX:

import clr
clr.AddReference('Microsoft.DirectX.AudioVideoPlayback')
from Microsoft.DirectX import AudioVideoPlayback
mp3 = AudioVideoPlayback.Audio("C:\\myreallyfunky.mp3")
mp3.Play()

A more comprehensive tutorial of using Managed DirectX in IronPython can be found from http://www.neotitans.com/resources/dot-net/mdx-ironpython-1.html

jsalonen
  • 29,593
  • 15
  • 91
  • 109