WASAPI + Windows存储应用程序初始化 [英] WASAPI + windows store app initialization

查看:147
本文介绍了WASAPI + Windows存储应用程序初始化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个捕获您的语音的程序,将我的效果应用于捕获的音频并立即播放.我正在用C ++将这个应用程序写入Windows商店.在遭受MediaCapture的痛苦之后,我决定使用WASAPI来做到这一点.我正在使用msdn中的示例来设置 WASAPI .如我所料,我很快就遇到了问题.因此,问题出在以下两行:

I am trying to write a program which captures your speech applies my effect on the captured audio and play it back immediately. I am writing this app to the windows store in c++. After suffering with MediaCapture I decided to use WASAPI to do that. I am using an example from the msdn to set up WASAPI. As I expected I ran into a problem very soon. So the problem is with the following two lines:

const CLSID CLSID_MMDeviceEnumerator = __uuidof(MMDeviceEnumerator);
const IID IID_IMMDeviceEnumerator = __uuidof(IMMDeviceEnumerator);

视觉工作室说:

Error: operand of __uuidof must have a class or enum type for which __declspec(uuid('..')) has been specified.

我不知道这意味着什么.我希望在这里提供一些帮助.

I haven't got any idea what it means. I would appreciate some help here.

推荐答案

要能够使用__uuidof(),必须已为目标声明了uuid.在为Windows 8 Store Apps进行编译时,似乎MMDeviceEnumerator和IMMDeviceEnumerator没有任何uuid声明,而应使用Windows :: Devices :: Enumeration命名空间枚举设备,然后使用IActivateAudioInterfaceAsyncOperation初始化和激活音频设备.

To be able to use __uuidof() a uuid must have been declared for the target. When compiling for Windows 8 Store Apps it seems that MMDeviceEnumerator and IMMDeviceEnumerator don't have any uuid declaration and you should instead use the Windows::Devices::Enumeration namespace to enumerate the devices and then use IActivateAudioInterfaceAsyncOperation to initialize and activate the audio device.

这里是指向完整工作示例的链接,该示例捕获pcm数据并将其写入wav文件.它使用系统的默认音频捕获设备,但枚举可用设备并使用其中任何一个都是小菜一碟. :)

Here is a link to a fully working example that captures pcm data and writes it to a wav-file. It uses the systems' default audio capture device but enumerating the available devices and using any of them instead is a piece of cake. :)

适用于Windows 8的WASAPI示例

这篇关于WASAPI + Windows存储应用程序初始化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆