A voice recorder doesn't need uncompressed Linear PCM audio. Compressed AMR
would do fine. The iPhone framework built for recording audio is simple enough, but the only examples I've found for setting up the audio format (which come from Apple) use LinearPCM. I've tried various other combinations of values, but can't seem to get anything to work.
Does anybody have any code that actually records AMR
?
Edit: The AMR format is one of the options for setting the data type, but the other options (packet size, frame size, etc.) don't seem to match up no matter what I set them to.
Edit: Here's what I have for the PCM version:
/*
If we want to use AMR instead of PCM:
AMR Format:
Sampling Frequency: 8 kHz/13-bit (160 samples for 20 ms frames), filtered to 200-3400 Hz
eight source codecs : 12.2, 1.2, 7.95, 7.40, 6.70, 5.90, 5.15, 4.75 kbit/s
generated frame length: 244, 204, 159, 148, 134, 118, 103, 95 bits per frame
*/
format->mFormatID = kAudioFormatLinearPCM;
format->mSampleRate = 8000.0; //8 kHz
format->mFramesPerPacket = 1; //1 frame per packet
format->mChannelsPerFrame = 1; //Mono
format->mBytesPerFrame = 2; //8/bits per frame (round up)
format->mBytesPerPacket = 2; //Same as bytes per frame
format->mBitsPerChannel = 16; //16-bit audio
format->mReserved = 0; //always 0
format->mFormatFlags = kLinearPCMFormatFlagIsBigEndian |
kLinearPCMFormatFlagIsSignedInteger |
kLinearPCMFormatFlagIsPacked;
The AMR format is a compressed audio format used by a lot of 3G cell phones for voice recording. You can find audio files in AMR formats on phones running Android OS, but not on iPhone because it's no longer supported by iOS since iOS 4.3.
You can open and play an AMR file in VideoLAN VLC media player (multiplatform), Microsoft Groove Music (Windows), or Apple QuickTime Player (Mac). You can edit the audio an AMR file contains in Audacity (multiplatform), provided you have Audacity's optional FFmpeg library installed.
What are AMR audio files? Adaptive Multi-Rate (AMR) is a compressed audio file type designed to optimize human speech data. AMR audio files were originally created for use on 3G phones. This file format has been around for a while; it was developed by Ericsson in the 1990s.
The MPEG-4 codec used to record and play back audio files in the iPhone's Voice Memo app is compressed using the Advanced Audio Coding (AAC) codec or the Apple Lossless Audio Codec (ALAC). Because the Voice Memo app only records audio data, the ". M4A" file extension is used, rather than the ". MP4" file extension.
AMR codec is NOT supported for encoding/recording on the iPhone, albeit it is supported for playback: this is the reason the kAudioFormatAMR constant exists.
Official api says that supported encoding formats are:
You may try one of these formats or use an open source AMR encoder as goldenmean suggests.
edit: Updated Official api link
To update olegueret's link to the official documentation (why do they hide this stuff?)
http://developer.apple.com/library/ios/#qa/qa2008/qa1615.html
I guess AMR codec format is not supported my iPhone voice recorder app.
May be one can try integrating some open-source, implementation of AMR encoder into the apples' iPhone application framework and try making the voice recorder store the audio in AMR encoded format. (i dont know if thats allowed by apple by their NDA/license).
-AD
You can record audio to a uncompressed Linear PCM buffer (circular or ring), and, in another thread, convert data in this buffer, using your own AMR (or other) compression engine, before saving the compressed audio data to a file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With