开发者

The iPhone simulator audio only works for 44100Hz, 22050Hz, and 11025Hz

Is anyon开发者_StackOverflowe out there using the simulator to handle 8kHz audio at the AudioUnit level?

The iPhone simulator audio only works for 44100Hz, 22050Hz, and 11025Hz. It fails strangely otherwise.

I am having trouble recording audio in the iPhone simulator. The code works fine on a hardare device but fails strangely in the simulator.

I am working on the AudioUnit level and I set the sampling rate (via audio session properties) to 8000Hz. Works fine on hardware, but on the simulator the render callback asks for one appropriately sized chunk of data and then calls back every 11.6ms asking for a single byte.

I tried setting the sample rate to 44100/4 (11025Hz) and it worked fine. So I tried setting the audio session sample rate to 11024 and it broke. Same with 11026. 11025 works.

My supposition is that there is a bug in the simulator's audio code. I think it internally must have a buffer that is a quarter second long and it can't handle situations where the sample rate is not some multiple of that.

Can anyone try this in their own code in the simulator? Try sampling rates of 11024, 11025, and 11026, and see if only 11025 works?

UPDATE: If I ask for 11024 it gives me 8000, but the render callback keeps delivering ioData asking for only a single frame (1 byte). Same behavior when I ask for 8000Hz.

UPDATE2: The simulator also works fin when I program at the AudioQueue API level. It handles 8kHz there. It just seems to screw up at the AudioUnit API level.


As near as I can tell, the simulator goes into a dysfunctional mode when you ask its Remote I/O unit to work in 8kHz mode. Or any mode other than a multiple of 44100/4.

Once again, it's not that it was rejecting my format or suggesting a better one. The problem is that it pretends to agree, then goes into a weird mode asking for one or two bytes at a time, probably because of some fencepost error.

If I set the unit subtype to VoiceProcessingIO, 8kHz works fine, thought the microphone side gets a little fussy every few reads.

So the problem is that the Simulator's Remote I/O unit claims to support 8kHz, but it only works if you configure it as a VoiceProcessing subtype.


The simulator is named so because it is not a emulator.


First of all, there are a few "canonical" sample rates. The ones I know are 8000, 11025, 22050, 41000, 48000 and 96000 Hz. I wouldn't expect any audio system to work with arbitrary value except those canonical ones.

That being said, the simulator is known to not behave exactly like an actual iDevice, especially the audio subsystem. For example, IIRC the simulator is not able to play all the audio formats an iOS device is able to play. As @JustSid said, it is a simulator and not an emulator. Nothing replaces testing on an actual device.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜