如何捕获正在播放的音频?

发布于 2024-07-07 02:44:17 字数 52 浏览 8 评论 0原文

有谁知道如何以编程方式捕获正在播放的声音(即来自声卡的所有声音,而不是麦克风等输入设备)。

Does anyone know how to programmatically capture the sound that is being played (that is, everything that is coming from the sound card, not the input devices such as a microphone).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

与风相奔跑 2024-07-14 02:44:17

假设您正在谈论 Windows,则基本上可以通过三种方法来实现此目的。

首先是打开音频设备的主输出作为录音源。 这只有在驱动程序支持时才可能实现,尽管现在大多数驱动程序都支持它。 虚拟设备的常见名称是“What You Hear”或“Wave Out”。 您将需要使用合适的 API(请参阅 MSDN 中的 WaveIn 或 DirectSound)来进行捕获。

第二种方法是编写一个过滤器驱动程序,可以在音频流到达物理设备之前拦截它。 同样,该技术仅适用于具有合适驱动器拓扑的设备,并且肯定不适合胆小的人。

这意味着这两个选项都不能保证在具有任意硬件的 PC 上工作。

最后一种选择是使用虚拟音频设备,例如虚拟音频线。 如果此设备被设置为 Windows 中的默认播放设备,则所有运行良好的应用程序都将通过它播放。 然后,您可以从同一设备进行记录以捕获总输出。 只要您可以控制要录制的应用程序使用的设备,那么此选项将始终有效。

所有这些技术都有其优点和缺点 - 由您决定哪一种最适合您的需求。

Assuming that you are talking about Windows, there are essentially three ways to do this.

The first is to open the audio device's main output as a recording source. This is only possible when the driver supports it, although most do these days. Common names for the virtual device are "What You Hear" or "Wave Out". You will need to use a suitable API (see WaveIn or DirectSound in MSDN) to do the capturing.

The second way is to write a filter driver that can intercept the audio stream before it reaches the physical device. Again, this technique will only work for devices that have a suitable driver topology and it's certainly not for the faint-hearted.

This means that neither of these options will be guaranteed to work on a PC with arbitrary hardware.

The last alternative is to use a virtual audio device, such as Virtual Audio Cable. If this device is set as the defualt playback device in Windows then all well-behaved apps will play through it. You can then record from the same device to capture the summed output. As long as you have control over the device that the application you want to record uses then this option will always work.

All of these techniques have their pros and cons - it's up to you to decide which would be the most suitable for your needs.

再见回来 2024-07-14 02:44:17

您可以使用波形音频接口,有一篇 MSDN 文章如何通过 PInvoke 访问它。

为了捕获正在播放的声音,您只需打开播放设备而不是麦克风。 当然,打开输入,而不是输出;-)

You can use the Waveform Audio Interface, there is an MSDN article on how to access it per PInvoke.

In order to capture the sound that is being played, you just need to open the playback device instead of the microphone. Open for input, of course, not for output ;-)

悟红尘 2024-07-14 02:44:17

如果您使用的是 OSX,Rogue Amoeba 的音频劫持 Pro 可能是最简单的方法。

不管怎样,为什么不将音频循环回线路并录制呢? 这是一个非常简单的解决方案。 只需将电缆插入音频输出插孔和线路输入插孔即可开始录音。

If you were using OSX, Audio Hijack Pro from Rogue Amoeba probably is the easiest way to go.

Anyway, why not just looping your audio back into your line in and recording that? This is a very simple solution. Just plug a cable in your audio output jack and your line in jack and start recordung.

彡翼 2024-07-14 02:44:17

您必须启用设备立体声混音。 如果你这样做,直接声音找到这个设备。

You have to enable device stero mix. if you do this, direct sound find this device.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文