ios 音頻:錄音與混音-問答

來源:互聯網
上載者:User

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 ?

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.