简体   繁体   English

如何使用DirectShow在C ++中呈现音频

[英]how to use DirectShow to render audio in C++

I am just starting to learn DirectShow with C++. 我刚刚开始学习C ++的DirectShow。 I need to use DirectShow to record the audio and write it to a WAV file on the disk. 我需要使用DirectShow录制音频并将其写入磁盘上的WAV文件。 I heard from other people that Win 7 does not allow for rendering audio using DirectShow. 我从其他人那里听说Win 7不允许使用DirectShow渲染音频。

In addition, I would like to know how should I start with recoding audio using DirectShow with C++? 另外,我想知道如何开始使用DirectShow和C ++对音频进行编码? If there is sample source, it would be great. 如果有样本来源,那就太好了。

Thanks in advance. 提前致谢。

I think you may have misunderstood these other people. 我认为您可能误解了这些其他人。 Windows Media Foundation is aimed to be the successor of DirectShow, but DirectShow is still a very valid technology on Windows 7 . Windows Media Foundation旨在成为DirectShow的继任者,但是DirectShow仍然是Windows 7上非常有效的技术

The easiest thing to accomplish what you want to do, is to get it right using the GraphEdit tool first ( I assume you want to do this programmatically). 完成您想要做的事情的最简单的事情就是首先使用GraphEdit工具正确处理它(我想您想通过编程方式做到这一点)。

Create a graph that contains your audio device, a WavDestFilter , and a file writer . 创建一个包含音频设备, WavDestFilter文件writer的图形。

Source -> WavDest -> File Writer

Play the graph. 播放图表。 Stop the graph and you should have created a .wav file with the recorded audio. 停止图形,您应该已经用录制的音频创建了一个.wav文件。 If you can get this right, then you need to do the whole thing programmatically. 如果您能做到这一点,那么您需要以编程方式完成整个任务。 There are a couple of samples in the SDK that show you how to programmatically add filters to a graph and connect them, that should enable you to get started. SDK中有几个示例,向您展示如何以编程方式将过滤器添加到图形并进行连接,从而使您入门。

WRT the WavDestFilter, IIRC it might not be in all versions of the SDK, you'll have to find an appropriate one. WRT WavDestFilter,IIRC可能不在所有版本的SDK中,您都必须找到一个合适的版本。 You also need to build it, and regsvr32 it, so that it will show up in your list of available filters in GraphEdit. 您还需要构建它,并对其进行regsvr32,以便它可以显示在GraphEdit中的可用过滤器列表中。

If this all seems a bit much, I would read through the DirectShow documentation on MSDN to at least get an overview of DirectShow. 如果这一切看起来有点多,我将通读MSDN上的DirectShow文档以至少获得DirectShow的概述。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM