2011-12-08 61 views
1

我正在使用音頻單元進行音頻播放。我已經從http://cocoawithlove.com/2010/10/ios-tone-generator-introduction-to.html下載音源,並嘗試使用它。出於某種原因,我需要使用ulaw而不是線性PCM。這裏是我的音頻格式設置:iOS音頻單元以恆定噪音播放

AudioStreamBasicDescription streamFormat; 
streamFormat.mSampleRate = 8000; 
streamFormat.mFormatID = kAudioFormatULaw; 
streamFormat.mFormatFlags = 0; 
streamFormat.mFramesPerPacket = 1; 
streamFormat.mBytesPerFrame = 2; 
streamFormat.mBytesPerPacket = streamFormat.mBytesPerFrame; 
streamFormat.mChannelsPerFrame = 1; 
streamFormat.mBitsPerChannel = 16; 

當我運行示例代碼,我得到一個恆定的噪音。有沒有人可以幫助解決這個問題?非常感謝。

回答

0

如果你想使用另一種編解碼器不同於線性PCM,則需要避免音頻單元,因爲它們只支持線性PCM。

但是,您可以使用音頻隊列,它們支持ULaw,ALaw等等。如果延遲不是問題,請使用音頻隊列。