i am new in cocos2d and facing hard time to find the best file format which is supported in cocos2d ?
and can i use ogg file format if Yes then please any link how to use it is cocos2d
No ogg on iOS. Here's the AVAudioPlayer supported audio formats list.
You also have to differentiate between background audio (streaming audio) and audio effects. For the former you should use mp3 and play only one mp3 at a time because the iOS devices can only decode one mp3 at a time using hardware. Additional mp3 are decoded with the CPU.
For audio effects uncompressed .caf and .wav files are standard. You want them to be 16-bit, mono and using a sample rate of 11, 22 or 44 kHz depending on the quality you need. Personally I would default to 22 kHz.
Here is the way to convert audio to best iOS formate: Click HERE
Open terminal and run this command:
afconvert -f caff -d LEI16 sound.wav
Any file that are supported in iPhone but for me .wav files are better.
Related
i will like to convert itunes music files in to a low bandwidth PCM for uploading.
How to convert m4a file to aac adts file in Xcode?
Real-time converting the PCM buffer to AAC data for iOS using Remote IO and Audio Convert Service
iOS: Create an MP3 on device
i saw a few threads but not too sure how do i go about it. Could anyone provide me a tutorial link please ?
any comment are greatly appreciated.
The easiest way to convert your audio files is by using the EXTAudioFileConvert API from Apple.
Tutorial on using the EXTAudioFileConvert can be found at: Easy AAC compressed audio conversion on iOS.
I am working on a iPhone IM app, which support audio message. I've tried caf and wav format follow "Speak Here", but the files are too large to be send through the internet. So I'm wondering if I can convert any of them to some small format, like mp3 or amr.
Thank you for you help in advance.
CoreAudio has som great built-in datatypes for just this Core Audio Data Types
Use iLBC, short for Internet Low Bitrate Codec, to record your audio. Limit your sample rate to 8kHz.
If you insist on mp3, use LAME - the open source MP3 encoder library to convert your audio.
After you've recorded the audio file, the iOS AVFoundation AVAsset Reader/Writer APIs can be used to convert the file by, say, reading a .wav and writing AAC or other compressed file type.
I'm having a hard time trying to record something other than linear PCM on the iPhone :-(
The samples I've found (SDK's SpeakHere, Zdziarski's and Sadun's books and the one at trailsinthesand.com) all use linear PCM but I'd like a commonly used compressed format instead (no ima4 or whatever the name is...).
I just cannot figure out how to tweak the sample code to be used with, for example AAC, MP3 or AMR instead. Any suggestions and hints for how to do that are much appreciated!
(Btw, I do not think an MP3-encoder nor AMR-encoder are available due to licensing issues, but AAC does exist, or???)
Edit/Update: I stumbled upon the following text in Apple's "iPhone Application Programming Guide", 2009-01-06, page 137, section: Recording Audio:
"You can record audio in any of the formats listed in “Preferred Audio Formats in iPhone OS” (page 140)", and as preferred audio formats on page 140 are: "For compressed audio when playing one sound at a time, and when you don’t need to play audio simultaneously with the iPod application, use the AAC format packaged in a CAF or m4a file."
Thus, I interpret that as a clear indication that it is indeed, not only possible, but even preferable, to record audio in AAC format wrapped up in a m4a file, which is just what I want. But still, I am not able to achieve that?!
Thanks,
/John
Keep looking at those docs. In "Core Audio Essentials", the section "Core Audio Plug-ins: Audio Units and Codecs" notes that:
iPhone OS contains the recording
codecs listed in Table 2-5. As you can
see, neither MP3 nor AAC recording is
available. This is due to the high CPU
overhead, and consequent battery
drain, of these formats.
Table 2-5 lists several formats, but as the text notes does not include the ones you're looking for. If you want those formats you'll have to bring your own encoder.
It is possible in iPhone 3GS and iPod 2nd generation and above. They have a hardware enconder for AAC.
There is an Apple example project for this that does exactly what you want to do:
iPhoneExtAudioFileConvertTest
A tip for using faac to convert from iPhone-output linear pcm files to aac format:
I found by experimentation that you have to use the -X flag on the command-line version of faac (running on Mac OS X), which "swaps the input bytes." (I guess it changes the endian-ness.)
So, for example, if you audio recorded the file linear.pcm on your iPhone, you could then run:
faac -XP linear.pcm
on your mac to convert that into the aac file linear.aac.
I'm guessing this means you might be able to use faac within your app to do the conversion, if you wanted to, since it's a C library.
Also note that, technically, the files output by iPhone's audio services are usually CAF files, Core Audio Format, which is sort of a wrapper format around a bunch of possible encodings: Apple's docs on CAF. The above command line works fine for me even though linear.pcm starts with the caff header.
Have you tried Lame mp3 encoder? Or faac/faad AAC codecs? You can embed them in ffmpeg for even more audio codecs.
Why don't try TPAACAudioConverter written by the legendary Michael Tyson ?
TPAACAudioConverter is a simple Objective-C class that performs the
conversion of any audio file to an AAC-encoded m4a, asynchronously
with a delegate, or converts any audio provided by a data source class
(which provides for recording straight to AAC).
Can audio being recorded be compressed on the fly?
or are there any libraries to take a .caf file, and convert to a compressed format?
The Core Audio APIs (which is what you'll be using to record audio) allow you to choose format, bitrate, etc. You can choose a low bitrate to keep the filesize down. In most cases with the iPhone, you're recording voice audio, and a low bitrate is fine.
The Audio Queue Services can record and encode audio. These are available on the iPhone. The documentation includes saving to a file of arbitrary format. I don't know if it's a perfect match for transcoding a .caf file but it's definitely worth a look.
The 2.x SDK does not have support for compressing audio.
You'll probably have to compile and link a 3rd party library.
Watch the CPU usage, it obviously won't be hardware
accelerated like the built-in decompression.
Can iphone mix two sound files or build custom equalizer?
I have studied for weeks about this problem,
and it seems unable to use iphone-sdk to mix two or more sound files or to build custom equalizer.
Is anyone have the experience to do this?
Yes you can. AVAudioPlayer can play multiple sounds and you can control the volume for each. Or you can use Audio Units and have more control over the audio data.
aurioTouch is a good sample app for what you are thinking of.
For simple playback of sound files you can use the AVAudioPlayer class introduced in the 2.2 SDK. It provides playback and volume controls for playing any audio file. As far as I am aware, there are no restrictions on the number of sound files you can play on the iPhone. The only restriction on playing sound files is that you may only play one AAC or MP3 compressed file at a time, the rest of the files must be either uncompressed or in the IMA4 format.
If your needs are more low-level (If you need to do DSP) you might want to look at AudioQueue Services or AudioUnits - two Mac OS X audio processing APIs that are also available on the iPhone.