Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Native iPhone audio format

Tags:

iphone

audio

I've currently got my output audio on the iPhone setup as this :

AudioStreamBasicDescription audioFormat;

audioFormat.mSampleRate = 48000;

audioFormat.mFormatID   = kAudioFormatLinearPCM;

audioFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;

audioFormat.mFramesPerPacket = 1;

audioFormat.mChannelsPerFrame = 2;

audioFormat.mBitsPerChannel = 16;

audioFormat.mBytesPerPacket = 4;

audioFormat.mBytesPerFrame = 4;

However, when I examine my performance figures through shark I am seeing functions such as : SRC_Convert_table_i32_scalar_stereo

take a fair chunk of time.

This made me think - what is the ideal and suggested output format for the iPhone? The one that requires as little work for the device to play.

like image 498
Oliver Hume Avatar asked Mar 10 '09 23:03

Oliver Hume


People also ask

What format is iPhone audio?

Audio formats AAC (listed in the Finder with the .m4p filename extension) AIFF. CAF. MP3. MP4.

Which audio format is best for iPhone?

ALAC: Also known as “Apple Lossless”, this is an encoding that compresses the audio data without losing any quality. In practice, the compression is about 40-60% of the original data. The algorithm was designed so that data could be decompressed at high speeds, which is good for devices such as the iPod or iPhone.


2 Answers

Shark does work with the iPhone. You can enable iPhone profiling by selecting "Sampling > Network/iPhone Profiling..." in the menu.

Definitely try using a 44100 Hz sampling rate. With 48000 I see the same function that you posted appearing in the callstacks -- no such function shows up when using 44100. The canonical audio format for Audio Units on the iPhone is non-interleaved 8.24 linear PCM:

streamFormat.mFormatID         = kAudioFormatLinearPCM;
streamFormat.mFormatFlags      = 
                  kAudioFormatFlagIsSignedInteger
                | kAudioFormatFlagsNativeEndian
                | kLinearPCMFormatFlagIsNonInterleaved
                | (24 << kLinearPCMFormatFlagsSampleFractionShift);
streamFormat.mSampleRate       = mixing_rate;
streamFormat.mBitsPerChannel   = 32;
streamFormat.mChannelsPerFrame = 2;
streamFormat.mFramesPerPacket  = 1;
streamFormat.mBytesPerFrame    = ( streamFormat.mBitsPerChannel / 8 );
streamFormat.mBytesPerPacket   = streamFormat.mBytesPerFrame *
                                 streamFormat.mFramesPerPacket;
like image 148
dendryte Avatar answered Oct 13 '22 01:10

dendryte


From iphone dev centre (requires login) the hardware suppoorted codecs are

iPhone Audio Hardware Codecs

iPhone OS applications can use a wide range of audio data formats, as described in the next section. Some of these formats use software-based encoding and decoding. You can simultaneously play multiple sounds in these formats. Moreover, your application and a background application (notably, the iPod application) can simultaneously play sounds in these formats.

Other iPhone OS audio formats employ a hardware codec for playback. These formats are:

  • AAC
  • ALAC (Apple Lossless)
  • MP3
like image 21
hhafez Avatar answered Oct 13 '22 01:10

hhafez