最简单的方法来捕获实时处理音频输入原始音频在Mac [英] Simplest way to capture raw audio from audio input for real time processing on a mac
问题描述
这是捕获来自音频最简单的方式内置的音频输入和请求时,例如从插座读取。能够既来在读取原始采样值(如在一个.wav)实时
What is the simplest way to capture audio from the built in audio input and be able to read the raw sampled values (as in a .wav) in real time as they come in when requested, like reading from a socket.
这是使用苹果的框架(音频队列)中的一个希望code。文档也不是很清楚,我需要的是非常基本的。
Hopefully code that uses one of Apple's frameworks (Audio Queues). Documentation is not very clear, and what I need is very basic.
推荐答案
尝试AudioQueue框架这一点。你主要是必须执行的3个步骤:
Try the AudioQueue Framework for this. You mainly have to perform 3 steps:
- 设置的音频格式如何采样输入的模拟音频
- 开始AudioQueueNewInput一个新的记录AudioQueue()
- 注册一个回调例程用来处理传入音频数据包
在第3步你有机会来分析与AudioQueueGetProperty()
In step 3 you have a chance to analyze the incoming audio data with AudioQueueGetProperty()
这大致是这样的:
static void HandleAudioCallback (void *aqData,
AudioQueueRef inAQ,
AudioQueueBufferRef inBuffer,
const AudioTimeStamp *inStartTime,
UInt32 inNumPackets,
const AudioStreamPacketDescription *inPacketDesc) {
// Here you examine your audio data
}
static void StartRecording() {
// now let's start the recording
AudioQueueNewInput (&aqData.mDataFormat, // The sampling format how to record
HandleAudioCallback, // Your callback routine
&aqData, // e.g. AudioStreamBasicDescription
NULL,
kCFRunLoopCommonModes,
0,
&aqData.mQueue); // Your fresh created AudioQueue
AudioQueueStart(aqData.mQueue,
NULL);
}
我建议<一href=\"http://developer.apple.com/library/ios/#documentation/MusicAudio/Conceptual/AudioQueueProgrammingGuide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40005343\">Apple AudioQueue服务编程指南有关如何启动和停止AudioQueue以及如何正确设置所有疗法需要的对象的相关详细信息。
I suggest the Apple AudioQueue Services Programming Guide for detailled information about how to start and stop the AudioQueue and how to setup correctly all ther required objects.
您还可能有一个仔细看看苹果的演示PROG SpeakHere。但是,这是恕我直言,有点混乱的开始。
You may also have a closer look into Apple's demo prog SpeakHere. But this is IMHO a bit confusing to start with.
这篇关于最简单的方法来捕获实时处理音频输入原始音频在Mac的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!