.caf vs .wav in iOS application - iphone

I'm using cocos2d and it is possible to play both formats using SimpleAudioEngine (obviously did not tried .caf) What format is preferable and why ?

I recommend you to use caf format with IMA4 compression for sound effects and aac for BGM.
CocosDenshion FAQ - What sound formats can I use?
For sound effects played with
CDSoundEngine it is recommended to use
16 bit mono wave files for
uncompressed audio and IMA4 for lossy
compressed audio. IMA4 sounds are
around one quarter the size of the
corresponding wave file.
How do I choose the best audio formats in iPhone OS?

Related

how to use simpleaudioengine to play audio in a specified duration

i want to use SimpleAudioEngine to play a 2s mp3, but not so simple. I want to this audio plays 4s, that it, this mp3's duration should be 4s. Any good idea can solve this problem, Thank u very much
Edit the file to be 4 seconds using audacity audio editor. You can extend the file without changing the pitch of the audio. Then export the file as a separate mp3 file. Then just pay the file normally.

Record audio on iPhone with smallest file size

I want to record audio with iPhone and then upload it to server.
I could record the audio, but my question is about which format should I use to record audio, so that the Recorder will result a file with smallest file size.
Here are the results for few encoding supported by iPhone. Size of audio file in KB of duration 10 sec.
kAudioFormatMPEG4AAC : 164,
kAudioFormatAppleLossless : 430,
kAudioFormatAppleIMA4 : 475,
kAudioFormatULaw : 889,
kAudioFormatALaw : 889,
Among these kAudioFormatMPEG4AAC is having smallest size.
Apple iOS supports playback audio in these formats:
AAC (MPEG-4 Advanced Audio Coding)
ALAC (Apple Lossless)
HE-AAC (MPEG-4 High Efficiency AAC)
iLBC (internet Low Bitrate Codec, another format for speech)
IMA4 (IMA/ADPCM)
Linear PCM (uncompressed, linear pulse code modulation)
MP3 (MPEG-1 audio layer 3)
µ-law and a-law
For recording following formats are possible:
AAC (MPEG-4 Advanced Audio Coding)
ALAC (Apple Lossless)
iLBC (internet Low Bitrate Codec, for speech)
IMA4 (IMA/ADPCM)
Linear PCM (uncompressed, linear pulse-code modulation)
µ-law and a-law
while only AAC supports hardware-assisted encoding (see Apple iOS SDK documentation)
For the universality in availability I prefer MP3.
Check these links to find exact code to record audio - Recording Audio on an iPad with AVAudioRecorder
It depends on the type of audio you are recording and the audio quality you want.
If for example, you are recording voice with the built in mic, iLBC will give you the smallest audio file (15.2 kbit/s for 20 ms frames, 13.33 kbit/s for 30 ms frames).

iPhone game audio and background music

Have a few questions related to adding sounds to my game, specifically intro music (for splash), background music (loop) and button event sounds. Hope you can share your knowledge on this.
1) Should I use compressed sounds or uncompressed sounds? Or perhaps a combination of the two? Are there any limitations on the iPhone hardware that I should be aware of -- for example, the ability to play multiple compressed sounds?
2) What's the best audio format for my purpose?
3) For background music, I am thinking of using AVAudioPlayer. For button event sounds, I am thinking of using AudioServicesPlaySystemSound, what do you think?
4) Any other issues I should be aware of?
Thank you!
1) According to the iPhone Application Programming Guide: "Starting in iPhone OS 3.0, nearly all supported audio formats can be used for simultaneous playback—namely, all those that can be played using software decoding, as described in Table 7-1. For the most processor-efficient multiple playback, use linear PCM (uncompressed) or IMA4 (compressed) audio."
But if you're going to be playing a lot of sounds at the same time, you should use either uncompressed or IMA4.
2) You should use the CAF file format because it gives you the most flexibility in what data format to use. You can put MP3, AAC, PCM, IMA4, and pretty much any compressed or uncompressed data in a CAF file (.caf). I typically use CAF files with IMA4 compression at mono, 16-bit, 44.1kHz.
3) That's how I do it in my apps: AVAudioPlayer for voice cues that cause the music levels to duck, and AudioServicesPlaySystemSound for buttons and other UI sound effects.
4) If you use uncompressed PCM data, the file sizes can be huge, but IMA4 is a fairly noisy compression scheme. You can use AAC but then you might be limited by how many AAC sounds you can play at once. Before iPhone OS 3.0, you could only play one AAC or MP3 sound at a time.

Decrease the volume of sound played by AudioToolbox

If i play my sounds on the iPhone on max ringer volume it plays fine But when i reduce it to some extend ma AudioToolbox sounds are playing at the same volume But my AVAudioPlayer sounds are playing fine. Is there any way to decrease the volume of sounds played by AudioToolbox...
From: iPhone Application Programming Guide
The AudioServicesPlaySystemSound function lets you very simply play short sound files. The simplicity carries with it a few restrictions. Your sound files must be:
Shorter than 30 seconds in duration
In linear PCM or IMA4 (IMA/ADPCM)
format Packaged in a .caf, .aif, or
.wav file
In addition, when you use the AudioServicesPlaySystemSound function:
Sounds play at the current system
audio level, with no level control
available
Sounds play immediately
Looping and stereo positioning are
unavailable

Which format support the audio file with a playing video?

i am playing the video and in the background i have to play the audio file and if i do this audio is not playing its sound as it just play video is it a extension problem i am using the .mp3 for the audio and .mp4 for the video .
how can we do this we have to play simultanisouly .both the file
balraj verma
Have a look at this:
http://developer.apple.com/iphone/library/documentation/MusicAudio/Conceptual/CoreAudioOverview/CoreAudioEssentials/CoreAudioEssentials.html#//apple_ref/doc/uid/TP40003577-CH10-SW67
"To play multiple sounds simultaneously, create one playback audio queue object for each sound. For each audio queue, schedule the first buffer of audio to start at the same time using the AudioQueueEnqueueBufferWithParameters function.
Audio format is critical when you play sounds simultaneously on iPhone or iPod touch. This is because playback of certain compressed formats in iPhone OS employs an efficient hardware codec. Only a single instance of one of the following formats can play on the device at a time:
AAC
ALAC (Apple Lossless)
MP3"