How to convert a wav or caf audio file on iPhone - iphone

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.

Related

How to convert itunes music files in to a low bandwidth PCM for uploading

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.

Video Karaoke Development on iPhone

I have a karaoke app that takes mp3+g files and mixes in the mic (using audio units)... and is able to record the final results to a raw pcm file.
I have potential clients asking me if I can do the same with a karaoke video file. So, can I...
1) playback a video and mix in the microphone audio?
2) take #1 and record it to a video file?
3) possibly even take the video camera and microphone inputs, and video audio... and save this to a file?
Thinking about this can I... take an mp3, camera and microphone inputs and mix all of these to a video file?
Thanks for any feedback!
Brian
Yes, all of these are possible. With the CD+G format, you will be a lot better off converting those to h.264 on the desktop and then loading them as movies with an AAC audio track. Attempting to write a CD+G parser for iOS would be a nightmare since so many CD+G files are badly broken. Also, CD+G files are shocking large, much larger than the MP3 files because CD+G is dumb uncompressed video from the 80's. It is a silly format.

iOS: Record audio in other format than caf

I am working on audio recording. I am able to record my audio in caf (Core audio format). Now I want to record sound in .mp3 or .amr.
I tried a lot of google but didn't found anything. I am not sure if my steps following work:
Write that Audio with .caf extention to document dir
Read data from that file
write the file again with .mp3 or .amr extention
I have 100% doubt that this will not going to work as this will just re save file with some other extension. This won't change audio codec.
I thought that for converting any format whether it is audio or video we need to change its codecs and data sequence.
Please also suggest me any player which don't play .caf files not anything else. So I can make sure that my files are converted successfully.
UPDATE Please also let me know that the way I am re-writing data with different extension is correct in the way I am needed?
You might be interested in the iPhoneExtAudioFileConvertTest example.
The MP3 format is however not available due to patents, maybe you can use LAME.
From the Document The Basics: Audio Codecs, Supported Audio Formats, and Audio Sessions

How can I Access/extract raw(headless) audio data from a caf file on iPhone?

I am working on a project that requires me to send raw headerless ulaw or linear pcm data to a server.
I am using the AVAudioRecorder and I can save out audio files to the phone quite easily, but the problem is that it no matter what I try and do, they get wrapped in a caf file or stamped with some kind of header.
It's my understanding that a caf file is just a wrapper file for raw audio data and that this audio data can be in various formats including linear pcm and ulaw.
So my questions are, how can I generate a raw audio file without the caf wrapper to begin with (ie just the headerless raw audio stuffed into a file) or if I record a caf that contains the raw Ulaw or linear pcm audio data, how can I easily go in and extract just the raw audio data from the caf file and leave everything else behind.
If the audio data in the CAF is already in the format you need it in, I'd use the AudioFile API to grab the caf file's audio data and write them to a headerless/RAW file before uploading to my server.
If you need to convert the CAF's data, use the ExtAudioFile API instead. Either way, pretty straightforward.
http://developer.apple.com/library/ios/#documentation/MusicAudio/Reference/AudioFileConvertRef/Reference/reference.html
http://developer.apple.com/library/ios/#documentation/MusicAudio/Reference/ExtendedAudioFileServicesReference/Reference/reference.html
If you use the Audio Queue API for recording, instead of AVAudioRecorder, you will have access to raw PCM sample buffers, and can write those out to a flat file for later sending to your server.

Recording sound as WAV on iphone

I am making an iPhone recording app that needs to submit the sound file as a .wav to an external server.
Starting from the SpeakHere example, I am able to record sound as a file, but only as .caf
Does anyone know how to record it as a wav instead? Or how to convert from .caf to .wav on the iphone? (The conversion must happen on the phone)
EDIT:
I'm wondering if anything can be done with using kAudioFileWAVEType instead of kAudioFileCAFType in AudioFileCreateWithURL
Yup, the key is kAudioFileWAVEType
AudioFileCreateWithURL (
audioFileURL,
kAudioFileWAVEType,
&audioFormat,
kAudioFileFlags_EraseFile,
&audioFileID
);
Changing to WAVE from CAF in the SpeakHere example causes the recording to be as wav. I also edit the same thing in the playback class, and changed the filename to be Recording.wav
Have a look at libsndfile. It is a well used (including by Audacity) C library for working with lots of file formats. It supports read and write of a variety of CAF and WAV formats.
The CAF File structure and WAV format are fairly similar. If the worst comes to the worst, converting shouldn't be too hard.
It would involve taking the Audio data chunk, and copying as is into the WAV file, and using the information in the Audio Description Chunk to add an equivalent fmt subchunk for the WAV file. It is fairly simple byte copying.
However, be aware (as Eric pointed out) there are licensing issues, see: Can the Libsndfile library be used on the iPhone iOS?