Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what are the formats supported in AVAudioRecorder for recording sound?

I have found a list of the different values (Audio Data Format) at http://developer.apple.com/library/ios/#documentation/MusicAudio/Reference/CoreAudioDataTypesRef/Reference/reference.html#//apple_ref/doc/uid/TP40004488

Audio Data Format Identifiers Identifiers for audio data formats, used in the AudioStreamBasicDescription structure.

kAudioFormatLinearPCM = 'lpcm',

kAudioFormatAC3 = 'ac-3',

kAudioFormat60958AC3 = 'cac3',

kAudioFormatAppleIMA4 = 'ima4',

kAudioFormatMPEG4AAC = 'aac ',

kAudioFormatMPEG4CELP = 'celp',

kAudioFormatMPEG4HVXC = 'hvxc',

kAudioFormatMPEG4TwinVQ = 'twvq',

kAudioFormatMACE3 = 'MAC3',

kAudioFormatMACE6 = 'MAC6',

kAudioFormatULaw = 'ulaw',

kAudioFormatALaw = 'alaw',

kAudioFormatQDesign = 'QDMC',

kAudioFormatQDesign2 = 'QDM2',

kAudioFormatQUALCOMM = 'Qclp',

kAudioFormatMPEGLayer1 = '.mp1',

kAudioFormatMPEGLayer2 = '.mp2',

kAudioFormatMPEGLayer3 = '.mp3',

kAudioFormatTimeCode = 'time',

kAudioFormatMIDIStream = 'midi',

kAudioFormatParameterValueStream = 'apvs',

kAudioFormatAppleLossless = 'alac'

kAudioFormatMPEG4AAC_HE = 'aach',

kAudioFormatMPEG4AAC_LD = 'aacl',

kAudioFormatMPEG4AAC_ELD = 'aace',

kAudioFormatMPEG4AAC_HE_V2 = 'aacp',

kAudioFormatMPEG4AAC_Spatial = 'aacs',

kAudioFormatAMR = 'samr',

kAudioFormatAudible = 'AUDB',

kAudioFormatiLBC = 'ilbc',

kAudioFormatDVIIntelIMA = 0x6D730011,

kAudioFormatMicrosoftGSM = 0x6D730031,

kAudioFormatAES3 = 'aes3'

However, I dont think we can use all the formats mentioned (e.g. mp3).

Can anyone help me out with the formats that are supported for recording sound using AVAudioRecorder ?

Thanks.

like image 402
Ahsan Avatar asked Jul 29 '11 02:07

Ahsan


2 Answers

As per apple docs Apple Core Audio Format Specification 1.0 it should now support mp3 although I haven't tested it, this is the current enumeration they support:

enum {
    kAudioFormatLinearPCM      = 'lpcm',
    kAudioFormatAppleIMA4      = 'ima4',
    kAudioFormatMPEG4AAC       = 'aac ',
    kAudioFormatMACE3          = 'MAC3',
    kAudioFormatMACE6          = 'MAC6',
    kAudioFormatULaw           = 'ulaw',
    kAudioFormatALaw           = 'alaw',
    kAudioFormatMPEGLayer1     = '.mp1',
    kAudioFormatMPEGLayer2     = '.mp2',
    kAudioFormatMPEGLayer3     = '.mp3',
    kAudioFormatAppleLossless  = 'alac'
};
like image 64
Oscar Gomez Avatar answered Nov 07 '22 12:11

Oscar Gomez


List above just

currently defined values for the mFormatID field

not supported for recording.

There are tested with AVAudioRecorder formats (with sample rates):

"MPEG4AAC (8000, 11025, 22050, 32000, 44100, 48000)",
"AppleLossless (8000, 11025, 22050, 32000, 44100, 48000)",
"MPEG4AAC_HE (32000, 44100, 48000)",
"MPEG4AAC_LD (22050, 32000, 44100, 48000)",
"MPEG4AAC_ELD (22050, 32000, 44100, 48000)",
"MPEG4AAC_ELD_SBR (22050, 32000, 44100, 48000)",
"MPEG4AAC_ELD_V2 (22050, 32000, 44100, 48000)"

Example:

[[AVAudioRecorder alloc] initWithURL:outputFileURL
                            settings:@{
                                       AVFormatIDKey : @(kAudioFormatMPEG4AAC),
                                       AVSampleRateKey : @(44100.0),
                                       AVNumberOfChannelsKey : @(2)
                                       }
                               error:&error];

also Supported Audio file formats

like image 33
Stanislav P. Avatar answered Nov 07 '22 11:11

Stanislav P.