Core Audio API

http://msdn.microsoft.com/en-us/library/dd370784(v=vs.85).aspx文章翻译

译文转载自http://www.cppblog.com/shenhuafeng/archive/2006/12/12/16323.html

Core Audio APIS :

Vista 里面,一组新的用户态的音频组件提供给应用程序来改善应用程序操作音频的能力,

包括以下的一些方面:

低延时,几乎无故障的音频流。

提高可靠性 ( 很多音频函数从核心态移到了用户态 )

提高了安全性 (在安全的,低优先级别的线程处理被保护的音频内容)

分配了特定的系统级别的规则 (console, multimedia, communications) 给单独的音频设备。

用户可以直接操作,相应 endpoint 设备的软件抽象 ( 如:扩音器,耳麦及麦克风 ) 以下的高层 API 是以 Core Audio APIs 来工作的。

DirectSound

DirectMusic

Windows multimedia waveXxx and mixerXxx functions

Media Foundation

Streaming Audio Renderer (SAR)

绝大多数的音频应用程序与以上的高层次的 API 交互而不是直接操作底层的 Core Audio API 。例如以下一些应用可能用到高等级的 API :

        媒体播放器

        DVD 播放器

        游戏

        商用软件

通常这些应用用到 DirectSound 和媒体的底层函数。

通常的应用不需要直接用到 Core Audio API ,例如 Core Audio API 中的 Audio streams 需要使用一个音频设备的原始数据格式。然而,一些第三方的软件开发人员开发以下的产品时,需要用到这些核心的 API :

       专业的音频应用程序 (PRO AUDIO)

       实时通信 (RTC) 应用程序

       第三方音频 API

一个 PRO AUDIO 和 RTC 应用程序可能需要直接用底层 Core Audio API 访问音频硬件来达到最小延时的效果。一个第三方的音频 API 需要直接访问 Core Audio API 来实现高层的 API 没有提供的功能。

Core Audio API 包括:

        Multimedia Device (MMDevice) API :用这些 API 来枚举系统中的音频设备。

        Windows Audio Session API (WASAPI) :用这些 API 来创建和管理来自音频设备音频流。

        DeviceTopology API :用这些 API 来直接访问声音适配器中的硬件数据通路的拓扑特性(如音量控制,复用器等)

        EndpointVolume API :用这些 API 直接访问音频设备的声音控制。这些 API 通常是给那些以独占模式管理音频流的应用程序。

这些 API 提供对于设备的抽象概念,这些概念被描述成为 Audio Endpoint Device 。每个 API 包含很多 COM 接口。由于音频需要低延时和精确的同步,所 MMDevice, WASAPI, DeviceTopology, 和 EndpointVolume APIs 不依赖于 .NET 框架。

除了 Vista 之外其他的操作系统都不支持 Core Audio API 。包括: Microsoft Windows Server 2003, Windows XP, Windows ME, Windows 2000, 和 Windows 98 。

 

Vista 中的音频控制的角色概念:

假如系统中有多个音频设备,那么一个设备可能用户是用来播放电影的,另一个可能是用来玩游戏的。这样 Vista 中就引入了角色的概念。

ERole 常量

设备角色

渲染举例

捕获举例

eConsole

与计算机交互

游戏和系统的通告声音

语音命令

eCommunications

与他人的声音交流

 聊天和 VOIP

eMultimedia

播放或者录制电影和音乐

电影和音乐

实时的声音录制 

Vista 中的音量控制被分成 4 种级别: 

IAudioStream 接口提供 session 每个流的音量控制。

methods in the IAudioStreamVolume interface.

IChannelAudioVolume 接口提供 session 中每个通道的音量控制。

ISimpleAudioVolume 接口控制每一个 Session 的主音量。

假如需要更改设备的音量大小,则需要操作 IAudioEndpointVolume 接口。

开发举例: Vista 中控制系统音量

l         初始化 COM :

CoInitializeEx(NULL, COINIT_MULTITHREADED)

l         获取 IMMDeviceEnumerator 设备指针:

  CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL,

                     CLSCTX_ALL, __uuidof(IMMDeviceEnumerator),

                     (void**)&m_pEnumerator)

l         获取 IMMDevice 指针,这是是所有 MM 设备 — 多媒体设备的根

n         其中第一个参数是指明设备的用途

n         第二个参数指明设备角色

m_pEnumerator->GetDefaultAudioEndpoint(eRender, eMultimedia, &m_pDeviceOut)

l         获取 IAudioEndpointVolume 指针:(我们需要控制系统音量所对应的对象)

m_pDeviceOut->Activate(__uuidof(IAudioEndpointVolume),CLSCTX_ALL,NULL,(void**)&m_AudioEndpointVolume)

l         根据需要调用该对象的 API ,进行操作。

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Audio can affect the human brain in the most powerful and profound ways. Using Apple,s Core Audio, you can leverage all that power in your own Mac and iOS software, implementing features ranging from audio capture to real-time effects, MP3 playback to virtual instruments, web radio to VoIP support. The most sophisticated audio programming system ever created, Core Audio is not simple. In Learning Core Audio, top Mac programming author Chris Adamson and legendary Core Audio expert Kevin Avila fully explain this challenging framework, enabling experienced Mac or iOS programmers to make the most of it. In plain language, Adamson and Avila explain what Core Audio can do, how it works, and how it builds on the natural phenomena of sound and the human language of audio. Next, using crystal-clear code examples, they guide you through recording, playback, format conversion, Audio Units, 3D audio MIDI connectivity, and overcoming unique challenges of Core Audio programming for iOS. Coverage includes: mastering Core Audio,s surprising style and conventions; recording and playback with Audio Queue; synthesizing audio; perform effects on audio streams; capturing from the mic; mixing multiple streams; managing file streams; converting formats; creating 3D positional audio; using Core MIDI on the Mac; leveraging your Cocoa and Objective-C expertise in Core Audio,s C-based environment, and much more. When you,ve mastered the "black arts" of Core Audio, you can do some serious magic. This book will transform you from an acolyte into a true Core Audio wizard.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值