iPhone/iPad开发札记 2012/03/10 音频:录音与混音


1. reading my code for recording 


* MyInputBufferHandler 

Q: 这里有Enqueue Buffer动作,这样,这个buffer有机会重新fill

   A: YES!. callback中总会有enqueue动作的,无论recording还是playback. 


Q: 参数含义

voidAQRecorder::MyInputBufferHandler(

void *inUserData,

AudioQueueRefinAQ,

AudioQueueBufferRefinBuffer,

constAudioTimeStamp *inStartTime,

UInt32 inNumPackets,

constAudioStreamPacketDescription* inPacketDesc)

关于inNumPackets,在文档中的描述如下:

inNumberPacketDescriptions is the number of packet descriptions in the inPacketDescs parameter. If you are recording to a VBR (variable bitrate) format, the audio queue supplies a value for this parameter to your callback, which in turn passes it on to the AudioFileWritePackets function. CBR (constant bitrate) formats don’t use packet descriptions. For a CBR recording, the audio queue sets this and the inPacketDescs parameter to NULL.


所以,似乎在这里这个值应该为NULL,但实际并非如此,why ?



* InitNewPlaybackQueue

Q: CFRunLoopGet?Current()等东东到底在干嘛? 似乎和thread的runloop有关 ? 2012/03/12


XThrowIfError(AudioQueueNewOutput(&mDataFormat,AQPlayer::AQBufferCallback,this

 CFRunLoopGetCurrent(),kCFRunLoopCommonModes, 0, &mQueue), "AudioQueueNew failed");


2. reading " Audio Queue Service Programming Guide " + "Audio Queue Service Reference" 


* multi queues

Audio Queue Services also supports scheduled playback and synchronization of multiple audio queues and synchronization of audio with video.

Q: could be used to do "mixing" ?


Q: 是否在我们这种类似voip的应用中,不应该使用Audio Queue Service,而应该使用Audio Unit ???


* callback invoking 

During recording or playback, an audio queue callback is invoked repeatedly by the audio queue that owns it. The time between calls depends on the capacity of the audio queue’s buffers and will typically range from half a secondto several seconds.

                                                           ^ too slow ???


enqueue buffer: always done by call back function.


* call back的作用

# 对于recording,

负责将Audio Queue从input device采集的放在buffer中的audio data发送给应用程序,如写入disk或放向network

将buffer入queue,等待Audio Queue再次fill

注:call back拿到的buffer是有audio data的,等待后续处理,如发送到network


# playback

负责将向audio buffer中fill audio data

将audio buffer推入audio queue,等待playback

注:call back拿到的buffer是空,等待被fill


3. reading "Audio Unit Hosting Guide for iOS"

Audio Units Provide Fast, Modular Audio Processing

The two greatest advantages of using audio units directly are:

  • Excellent responsiveness. Because you have access to a realtime priority thread in an audio unit render callback function, your audio code is as close as possible to the metal. Synthetic musical instruments and realtime simultaneous voice I/O benefit the most from using audio units directly.

  • Dynamic reconfiguration. The audio processing graph API, built around the AUGraph opaque type, lets you dynamically assemble, reconfigure, and rearrange complex audio processing chains in a thread-safe manner, all while processing audio. This is the only audio API in iOS offering this capability

Q: Does this mean for VOIP application, we can only use Audio Unit rather than Audio Queue Service ?




  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值