views:

170

answers:

1

Hi everybody,

I want to initialize a AVAudioRecorder with a aac file format, but it doesnt work...

Whats wrong with the following code?

soundFilePath = [soundFilePath stringByAppendingPathExtension:@"aac"];
NSURL *url = [NSURL fileURLWithPath:soundFilePath isDirectory:FALSE];
NSMutableDictionary *recordSetting = [[NSMutableDictionary alloc] init];
[recordSetting setValue:[NSNumber numberWithInt: 'aac '] forKey:AVFormatIDKey];                                     //General Audio Format Settings 
[recordSetting setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey];                                 //          "
[recordSetting setValue:[NSNumber numberWithInt: 2] forKey:AVNumberOfChannelsKey];                                  //          "
[recordSetting setValue:[NSNumber numberWithInt: 32] forKey:AVLinearPCMBitDepthKey];                                //Linear PCM Format Settings 
[recordSetting setValue:[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsBigEndianKey];                             //          "
[recordSetting setValue:[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsFloatKey];                                 //          "
[recordSetting setValue:[NSNumber numberWithInt:AVAudioQualityLow] forKey:AVEncoderAudioQualityKey];                //Encoder Settings 
[recordSetting setValue:[NSNumber numberWithInt:96] forKey:AVEncoderBitRateKey];                                    //          "
[recordSetting setValue:[NSNumber numberWithInt:16] forKey:AVEncoderBitDepthHintKey];                               //          "
[recordSetting setValue:[NSNumber numberWithInt:AVAudioQualityLow] forKey:AVSampleRateConverterAudioQualityKey];    //Sample Rate Conversion Settings

_recorder = [[AVAudioRecorder alloc] initWithURL:url settings:recordSetting error:nil];

this allocation just returns nil...

Any help will be appreciated...!

A: 

[recordSetting setValue :[NSNumber numberWithInt:kAudioFormatMPEG4AAC_HE_V2] forKey:AVFormatIDKey]; The format for this is an enumeration. Try to look into the enumerations. There is no formatIDKey for 'aac' . It has aacp and others.

Nareshkumar