是否有任何高级音频队列记录服务库的iOS? [英] Is there any high level Audio Queue Record Service Library for iOS?
本文介绍了是否有任何高级音频队列记录服务库的iOS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发一个关于VOIP的应用程序,
I'm trying to develop an application which about VOIP,
是否有适用于iOS的高级音频队列服务库?
is there any high level audio queue service library for iOS ?
因为我不是很擅长使用扩展名文件名.mm,
because I'm not very good at for working on extension filename ".mm",
使用开源将是一个更好的选择。
using an open source would be a better option.
或者有人可以给我一些提示,说明如何从AudioQueueBufferRef获取缓冲区?
or someone could give me some hints for how to fetch the buffer from AudioQueueBufferRef ?
像代理:
- (void)audioRecorderDidReceivedBuffer:(Buffer) {
do something for other operations
}
- p> 更新
我发现了一篇关于的文章使用RemoteIO音频单元也许输入回调是我需要的。
maybe the input callback is what I need.
Overvier
Overvier
- 识别音频组件(kAudioUnitType_Output / kAudioUnitSubType_RemoteIO / kAudioUnitManufacturerApple)
- 使用AudioComponentFindNext(NULL,& descriptionOfAudioComponent)获取AudioComponent,
获取音频单元 - 使用AudioComponentInstanceNew(ourComponent,& audioUnit)创建音频单元的实例
- 描述AudioStreamBasicDescription结构中的音频格式,并使用AudioUnitSetProperty应用格式
- 提供录音回调,
- 分配一些缓冲区
- 初始化音频单元
- 启动音频单位
- 欢喜
- Identify the audio component (kAudioUnitType_Output/ kAudioUnitSubType_RemoteIO/ kAudioUnitManufacturerApple)
- Use AudioComponentFindNext(NULL, &descriptionOfAudioComponent) to obtain the AudioComponent, which is like the factory with which you obtain the audio unit
- Use AudioComponentInstanceNew(ourComponent, &audioUnit) to make an instance of the audio unit
- Enable IO for recording and possibly playback with AudioUnitSetProperty
- Describe the audio format in an AudioStreamBasicDescription structure, and apply the format using AudioUnitSetProperty
- Provide a callback for recording, and possibly playback, again using AudioUnitSetProperty
- Allocate some buffers
- Initialise the audio unit
- Start the audio unit
- Rejoice
// Enable IO for recording
UInt32 flag = 1;
status = AudioUnitSetProperty(audioUnit,
kAudioOutputUnitProperty_EnableIO,
kAudioUnitScope_Input,
kInputBus,
&flag,
sizeof(flag));
// Set input callback
AURenderCallbackStruct callbackStruct;
callbackStruct.inputProc = recordingCallback;
callbackStruct.inputProcRefCon = self;
status = AudioUnitSetProperty(audioUnit,
kAudioOutputUnitProperty_SetInputCallback,
kAudioUnitScope_Global,
kInputBus,
&callbackStruct,
sizeof(callbackStruct));
//recordingCallback
static OSStatus recordingCallback(void *inRefCon,
AudioUnitRenderActionFlags *ioActionFlags,
const AudioTimeStamp *inTimeStamp,
UInt32 inBusNumber,
UInt32 inNumberFrames,
AudioBufferList *ioData) {
// TODO: Use inRefCon to access our interface object to do stuff
// Then, use inNumberFrames to figure out how much data is available, and make
// that much space available in buffers in an AudioBufferList.
AudioBufferList *bufferList; // <- Fill this up with buffers (you will want to malloc it, as it's a dynamic-length list)
// Then:
// Obtain recorded samples
OSStatus status;
status = AudioUnitRender([audioInterface audioUnit],
ioActionFlags,
inTimeStamp,
inBusNumber,
inNumberFrames,
bufferList);
checkStatus(status);
// Now, we have the samples we just read sitting in buffers in bufferList
DoStuffWithTheRecordedAudio(bufferList);
return noErr;
}
推荐答案
从记录中提取音频缓冲区
Here is the method that how to fetch Audio Buffer from recording
(引用来自: http://atastypixel.com/blog/using-remoteio-audio-unit/ )
static OSStatus recordingCallback(void *inRefCon,
AudioUnitRenderActionFlags *ioActionFlags,
const AudioTimeStamp *inTimeStamp,
UInt32 inBusNumber,
UInt32 inNumberFrames,
AudioBufferList *ioData) {
// TODO: Use inRefCon to access our interface object to do stuff
// Then, use inNumberFrames to figure out how much data is available, and make
// that much space available in buffers in an AudioBufferList.
AudioBufferList *bufferList; // <- Fill this up with buffers (you will want to malloc it, as it's a dynamic-length list)
// Then:
// Obtain recorded samples
OSStatus status;
status = AudioUnitRender([audioInterface audioUnit],
ioActionFlags,
inTimeStamp,
inBusNumber,
inNumberFrames,
bufferList);
checkStatus(status);
// Now, we have the samples we just read sitting in buffers in bufferList
DoStuffWithTheRecordedAudio(bufferList);
return noErr;
}
这篇关于是否有任何高级音频队列记录服务库的iOS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文