在 Cocoa 中从 Mac 捕获音频并保存到文件的代码示例? [英] Code sample for capturing audio from a Mac in Cocoa and saving to file?

查看:33
本文介绍了在 Cocoa 中从 Mac 捕获音频并保存到文件的代码示例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要开发一个小型应用程序,该应用程序从 Mac 的音频队列中捕获音频,并需要以某种合理的音频格式将其保存到磁盘.

I'm due to work on a small application that captures audio from the Mac's Audio Queue and needs to save it to disk in some reasonable audio format.

有人可以分享一些不错的示例代码(Cocoa/Objective-C)吗?

Does anyone have a some decent sample code (Cocoa / Objective-C) that they can share?

我特别需要捕获传递到内置输出设备的音频以进行记录.任何见解?到目前为止的答案很有帮助,但并没有帮助我理解如何捕获进入输出的数据,与输入源无关.

I specifically need to capture the audio that is being passed to the Built-in Output device in order to record it. Any insights? The answers so far have been helpful, but have not helped me understand how the data going to the output can be captured, agnostic of the input source.

推荐答案

在 Mac OS X 中处理音频涉及与 Core Audio 交互.如需快速概览,请查看 核心音频概述.

Working with audio in Mac OS X involves interfacing with Core Audio. For a quick overview, take a look at the Core Audio Overview.

您将需要与 AUHAL 交互以执行输入和输出;技术说明 详细说明了这样做所需的步骤.这段代码似乎通常是用 C++ 编写的,因为这是在 SimplePlayThru 演示中采用的过程一>.

You will need to interface with the AUHAL to perform input and output; a technical note exists detailing the steps required to do so. This code seems to usually be written in C++, as that is the procedure taken in the SimplePlayThru demo.

这不包括捕获该音频输入所需的实际步骤.但是,这些链接应该为您提供足够的示例代码来开始与您的输入设备交互.如果我遇到这些链接,我会在这个答案中发布更多链接.

This doesn't cover the actual steps required to capture that audio input. However, these links should provide you with enough sample code to begin interfacing with your input device. I'll post more links in this answer if I happen across them.

查看/Developer/Example/CoreAudio/Services/AudioFileTools.具体看afrecord.cpp.不可否认,这不是可可本身;Cocoa 本身似乎没有任何特定的录音功能.如果您想在那里与 C++ 文件交互,您可能需要像 SimplePlayThru 一样编写一些 Objective C++.

Take a look at /Developer/Example/CoreAudio/Services/AudioFileTools. Specifically, look at afrecord.cpp. Admittedly, this is not Cocoa per se; Cocoa itself doesn't seem to have any specific capabilities for recording. If you'll want to interface with the C++ file there, you'll likely need to write some Objective C++ like in SimplePlayThru.

这篇关于在 Cocoa 中从 Mac 捕获音频并保存到文件的代码示例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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