gpt4 book ai didi

python - 如何从 Python 访问 DirectSound 设备信息?

转载 作者:太空宇宙 更新时间:2023-11-03 19:30:31 26 4
gpt4 key购买 nike

我找到了this有关如何使用 .NET 枚举声音设备信息的信息,但我真的不知道如何在 Python 中使用这些信息。正如您可能知道的那样,我的 Windows API 编程经验几乎为零。

我可以弄清楚如何通过 WMI 获取基本信息,但我需要更多信息,看起来下面的 C# 代码片段可能就是我需要的,但我只是不知道如何从 Python 访问 DirectSound 对象。我已经了解了 ctypes 的一些基本内容,但我不知道加载哪个或如何加载 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
}

有什么指点吗?

最佳答案

对于“穷人”的 .NET 库访问,请查看 "Python for .NET" .

但是,使用 IronPython 访问 DirectSound 设备可能更容易由于其通过 clr 库进行 .NET 绑定(bind)。

来自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()

在 IronPython 中使用 Managed DirectX 的更全面的教程可以从 http://www.neotitans.com/resources/dot-net/mdx-ironpython-1.html 找到。

关于python - 如何从 Python 访问 DirectSound 设备信息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6119587/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com