开发者

How to access DirectSound device info from Python?

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?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜