What formats are supported in AVAudioRecorder for sound recording?

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

Audio Data Format Identifiers Audio format identifiers 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 do not think that we can use all the mentioned formats (for example, mp3).

Can someone help me with the formats that are supported for recording audio using AVAudioRecorder?

Thanks.

+5
source share
2 answers

According to apple docs, Apple Core Audio Format 1.0 specification should now support mp3, although I have not tested it, they support this current listing:

enum { kAudioFormatLinearPCM = 'lpcm', kAudioFormatAppleIMA4 = 'ima4', kAudioFormatMPEG4AAC = 'aac ', kAudioFormatMACE3 = 'MAC3', kAudioFormatMACE6 = 'MAC6', kAudioFormatULaw = 'ulaw', kAudioFormatALaw = 'alaw', kAudioFormatMPEGLayer1 = '.mp1', kAudioFormatMPEGLayer2 = '.mp2', kAudioFormatMPEGLayer3 = '.mp3', kAudioFormatAppleLossless = 'alac' }; 
+10
source

The list above is just

current values ​​for the mFormatID field

not supported for recording.

There are tested formats AVAudioRecorder (with sampling rate):

 "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 fooobar.com/questions/316889 / ...

0
source

Source: https://habr.com/ru/post/914123/


All Articles