iPad 1 unable to record MPEG4AAC recording? - ipad

I have been trying to record kAudioFormatMPEG4AAC format on iPad app, the recording is working fine on iPad2 & iPad3, but not on iPad1. Here iPad1 & iPad3 have iOS 5.1, and iPad2 has iOS 5.0.1.
The code for recording is like..
if(recordEncoding == ENC_PCM)
{
[recordSettings setObject:[NSNumber numberWithInt: kAudioFormatLinearPCM] forKey: AVFormatIDKey];
[recordSettings setObject:[NSNumber numberWithFloat:44100.0] forKey: AVSampleRateKey];
[recordSettings setObject:[NSNumber numberWithInt:2] forKey:AVNumberOfChannelsKey];
[recordSettings setObject:[NSNumber numberWithInt:16] forKey:AVLinearPCMBitDepthKey];
[recordSettings setObject:[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsBigEndianKey];
[recordSettings setObject:[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsFloatKey];
}
else
{
NSNumber *formatObject;
switch (recordEncoding) {
case (ENC_AAC):
formatObject = [NSNumber numberWithInt: kAudioFormatMPEG4AAC];
break;
case (ENC_ALAC):
formatObject = [NSNumber numberWithInt: kAudioFormatAppleLossless];
break;
case (ENC_IMA4):
formatObject = [NSNumber numberWithInt: kAudioFormatAppleIMA4];
break;
case (ENC_ILBC):
formatObject = [NSNumber numberWithInt: kAudioFormatiLBC];
break;
case (ENC_ULAW):
formatObject = [NSNumber numberWithInt: kAudioFormatULaw];
break;
default:
formatObject = [NSNumber numberWithInt: kAudioFormatAppleIMA4];
}
[recordSettings setObject:formatObject forKey: AVFormatIDKey];
[recordSettings setObject:[NSNumber numberWithFloat:44100.0] forKey: AVSampleRateKey];
[recordSettings setObject:[NSNumber numberWithInt:2] forKey:AVNumberOfChannelsKey];
[recordSettings setObject:[NSNumber numberWithInt:12800] forKey:AVEncoderBitRateKey];
[recordSettings setObject:[NSNumber numberWithInt:16] forKey:AVLinearPCMBitDepthKey];
[recordSettings setObject:[NSNumber numberWithInt: AVAudioQualityHigh] forKey: AVEncoderAudioQualityKey];
}
Can anyone help me with this problem. One this is for sure, MPEG4AAC works on iPAD 1 as this post suggests

Try to comment AVEncoderBitRateKey line. Also AVLinearPCMBitDepthKey is not needed for AAC.

Related

How to remove background noise while recording a audio sessions?

I am Using AVAudioRecorder for Recording human voice and after that need to change pitch for applying some effects.For this i am using AVAudioPlayerNode.But it also records background noise .I searched alot but I couldn't found a perfect solutions.below is the code how I am recording that audio.I found some where that we need to do DSP(Digital Signature process) for this.
recordSetting = [[NSMutableDictionary alloc] init];
[recordSetting setValue :[NSNumber numberWithInt:kAudioFormatLinearPCM] forKey:AVFormatIDKey];
[recordSetting setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey];
[recordSetting setValue:[NSNumber numberWithInt: 1] forKey:AVNumberOfChannelsKey];
[recordSetting setValue:[NSNumber numberWithInt:16] forKey:AVLinearPCMBitDepthKey];
[recordSetting setValue:[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsBigEndianKey];
[recordSetting setValue:[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsFloatKey];
[recordSetting setValue:[NSNumber numberWithInt: AVAudioQualityHigh]forKey:AVEncoderAudioQualityKey];
NSArray* documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString* fullFilePath = [[documentPaths objectAtIndex:0] stringByAppendingPathComponent: #"in.caf"];
inUrl = [NSURL fileURLWithPath:fullFilePath];
voiceRecorder = [[ AVAudioRecorder alloc] initWithURL: inUrl settings:recordSetting error:&error];
//[audioRecorder setMeteringEnabled:YES];
[voiceRecorder setDelegate: self];
[voiceRecorder prepareToRecord];
can someone please help me in removing background noises so that I can get clear recording.

iOS app - user defaults using NSUserDefaults, saving on Simulator but not on device

I have an iOS app , that has been saving user defaults using NSUserDefaults, however, all of a sudden , the app is no longer saving defaults on the device , but it works perfectly in the simulator.
Here are the methods I am calling to save settings
-(void)saveSettings{
defaults = [NSUserDefaults standardUserDefaults];
settingsData = [defaults objectForKey:(NSString *)#"SettingsKey"];
settingsDict = [NSKeyedUnarchiver unarchiveObjectWithData:settingsData];
NSMutableDictionary * settingsMutableDictionary = [settingsDict mutableCopy];
[settingsMutableDictionary setValue: [NSNumber numberWithBool:_dawnAlarmSwitch.on] forKey: #"dawnAlarmSwitch"];
[settingsMutableDictionary setValue:[NSNumber numberWithBool:_sunriseAlarmSwitch.on] forKey: #"sunriseAlarmSwitch"];
[settingsMutableDictionary setValue:[NSNumber numberWithBool:_noonAlarmSwitch.on] forKey: #"noonAlarmSwitch"];
[settingsMutableDictionary setValue:[NSNumber numberWithBool:_afternoonAlarmSwitch.on] forKey: #"afternoonAlarmSwitch"];
[settingsMutableDictionary setValue:[NSNumber numberWithBool:_sunsetAlarmSwitch.on] forKey: #"sunsetAlarmSwitch"];
[settingsMutableDictionary setValue:[NSNumber numberWithBool:_nightAlarmSwitch.on] forKey: #"nightAlarmSwitch"];
[settingsMutableDictionary setValue:[NSNumber numberWithInt:_dawnAlarmDelaySlider.value] forKey: #"dawnAlarmDelaySlider"];
[settingsMutableDictionary setValue:[NSNumber numberWithInt:_noonAlarmDelaySlider.value] forKey: #"noonAlarmDelaySlider"];
[settingsMutableDictionary setValue:[NSNumber numberWithInt:_afternoonAlarmDelaySlider.value] forKey: #"afternoonAlarmDelaySlider"];
[settingsMutableDictionary setValue:[NSNumber numberWithInt:_sunsetAlarmDelaySlider.value] forKey: #"sunsetAlarmDelaySlider"];
[settingsMutableDictionary setValue:[NSNumber numberWithInt:_nightAlarmDelaySlider.value] forKey: #"nightAlarmDelaySlider"];
[settingsMutableDictionary setValue:[NSNumber numberWithInt:_dawnSnoozeIntervalSlider.value] forKey: #"dawnSnoozeIntervalSlider"];
[settingsMutableDictionary setValue:[NSNumber numberWithInt:_noonSnoozeIntervalSlider.value] forKey: #"noonSnoozeIntervalSlider"];
[settingsMutableDictionary setValue:[NSNumber numberWithInt:_afternoonSnoozeIntervalSlider.value] forKey: #"afternoonSnoozeIntervalSlider"];
[settingsMutableDictionary setValue:[NSNumber numberWithInt:_sunsetSnoozeIntervalSlider.value] forKey: #"sunsetSnoozeIntervalSlider"];
[settingsMutableDictionary setValue:[NSNumber numberWithInt:_nightSnoozeIntervalSlider.value] forKey: #"nightSnoozeIntervalSlider"];
// CFShow((__bridge CFTypeRef)(settingsDict));
settingsDict = [settingsMutableDictionary copy];
settingsData = [NSKeyedArchiver archivedDataWithRootObject:settingsDict];
[defaults setObject:settingsData forKey:(NSString *)#"SettingsKey"];
[defaults synchronize];
kvStore = [NSUbiquitousKeyValueStore defaultStore];
[kvStore setObject:settingsData forKey:(NSString *)#"SettingsKey"];
[kvStore synchronize];
}
and here is the method for retrieving settings:
-(void)getSettings{
kvStore = [NSUbiquitousKeyValueStore defaultStore];
settingsData = [kvStore objectForKey:(NSString *)#"SettingsKey"];
if (!settingsData){
defaults= [NSUserDefaults standardUserDefaults];
settingsData = [defaults objectForKey:(NSString *)#"SettingsKey"];
}
if (!settingsData)
[self createSettings];
if (settingsData){
settingsDict = [NSKeyedUnarchiver unarchiveObjectWithData:settingsData];
_showArabicQuranSwitch.on= [[settingsDict objectForKey:#"showArabicQuranSwitch"] boolValue];
_dawnAlarmSwitch.on= [[settingsDict objectForKey:#"dawnAlarmSwitch"] boolValue];
_sunriseAlarmSwitch.on= [[settingsDict objectForKey:#"sunriseAlarmSwitch"] boolValue];
_noonAlarmSwitch.on= [[settingsDict objectForKey:#"noonAlarmSwitch"] boolValue];
_afternoonAlarmSwitch.on= [[settingsDict objectForKey:#"afternoonAlarmSwitch"] boolValue];
_sunsetAlarmSwitch.on= [[settingsDict objectForKey:#"sunsetAlarmSwitch"] boolValue];
_nightAlarmSwitch.on= [[settingsDict objectForKey:#"nightAlarmSwitch"] boolValue];
_dawnAlarmDelaySlider.value= [[settingsDict objectForKey:#"dawnAlarmDelaySlider"] intValue];
_noonAlarmDelaySlider.value= [[settingsDict objectForKey:#"noonAlarmDelaySlider"] intValue];
_afternoonAlarmDelaySlider.value= [[settingsDict objectForKey:#"afternoonAlarmDelaySlider"] intValue];
_sunsetAlarmDelaySlider.value= [[settingsDict objectForKey:#"sunsetAlarmDelaySlider"] intValue];
_nightAlarmDelaySlider.value= [[settingsDict objectForKey:#"nightAlarmDelaySlider"] intValue];
_dawnSnoozeIntervalSlider.value= [[settingsDict objectForKey:#"dawnSnoozeIntervalSlider"] intValue];
if(self.dawnAlarmDelaySlider.value <0.0f)
_dawnAlarmDelayLabel.text = [NSString stringWithFormat:#"%.0f mins before", _dawnAlarmDelaySlider.value*-1];
else
_dawnAlarmDelayLabel.text = [NSString stringWithFormat:#"%.0f mins after", _dawnAlarmDelaySlider.value];
_noonSnoozeIntervalSlider.value= [[settingsDict objectForKey:#"noonSnoozeIntervalSlider"] intValue];
if(self.noonAlarmDelaySlider.value<0.0f)
_noonAlarmDelayLabel.text = [NSString stringWithFormat:#"%.0f mins before", _noonAlarmDelaySlider.value*-1];
else
_noonAlarmDelayLabel.text = [NSString stringWithFormat:#"%.0f mins after", _noonAlarmDelaySlider.value];
_afternoonSnoozeIntervalSlider.value= [[settingsDict objectForKey:#"afternoonSnoozeIntervalSlider"] intValue];
if(self.afternoonAlarmDelaySlider.value<0.0f)
_afternoonAlarmDelayLabel.text = [NSString stringWithFormat:#"%.0f mins before", _afternoonAlarmDelaySlider.value*-1];
else
_afternoonAlarmDelayLabel.text = [NSString stringWithFormat:#"%.0f mins after", _afternoonAlarmDelaySlider.value];
_sunsetSnoozeIntervalSlider.value= [[settingsDict objectForKey:#"sunsetSnoozeIntervalSlider"] intValue];
if(self.sunsetAlarmDelaySlider.value<0.0f)
_sunsetAlarmDelayLabel.text = [NSString stringWithFormat:#"%.0f mins before", _sunsetAlarmDelaySlider.value*-1];
else
_sunsetAlarmDelayLabel.text = [NSString stringWithFormat:#"%.0f mins after", _sunsetAlarmDelaySlider.value];
_nightSnoozeIntervalSlider.value= [[settingsDict objectForKey:#"nightSnoozeIntervalSlider"] intValue];
if(self.nightAlarmDelaySlider.value<0.0f)
_nightAlarmDelayLabel.text = [NSString stringWithFormat:#"%.0f mins before", _nightAlarmDelaySlider.value*-1];
else
_nightAlarmDelayLabel.text = [NSString stringWithFormat:#"%.0f mins after", _nightAlarmDelaySlider.value];
_dawnSnoozeIntervalLabel.text = [NSString stringWithFormat:#"%.0f mins", _dawnSnoozeIntervalSlider.value];
_noonSnoozeIntervalLabel.text = [NSString stringWithFormat:#"%.0f mins", _noonSnoozeIntervalSlider.value];
_afternoonSnoozeIntervalLabel.text = [NSString stringWithFormat:#"%.0f mins", _afternoonSnoozeIntervalSlider.value];
_sunsetSnoozeIntervalLabel.text = [NSString stringWithFormat:#"%.0f mins", _sunsetSnoozeIntervalSlider.value];
_nightSnoozeIntervalLabel.text = [NSString stringWithFormat:#"%.0f mins", _nightSnoozeIntervalSlider.value];
}
// CFShow((__bridge CFTypeRef)(settingsDict));
}
-(void)createSettings{
settingsDict = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], #"showArabicQuranSwitch",
[NSNumber numberWithBool:NO], #"showArabicQuranSwitch",
[NSNumber numberWithBool:YES], #"dawnAlarmSwitch",
[NSNumber numberWithBool:NO], #"sunriseAlarmSwitch",
[NSNumber numberWithBool:YES], #"noonAlarmSwitch",
[NSNumber numberWithBool:YES], #"afternoonAlarmSwitch",
[NSNumber numberWithBool:YES], #"sunsetAlarmSwitch",
[NSNumber numberWithBool:YES], #"nightAlarmSwitch",
[NSNumber numberWithInt:10], #"dawnSnoozeIntervalSlider",
[NSNumber numberWithInt:10], #"noonSnoozeIntervalSlider",
[NSNumber numberWithInt:10], #"afternoonSnoozeIntervalSlider",
[NSNumber numberWithInt:10], #"sunsetSnoozeIntervalSlider",
[NSNumber numberWithInt:10], #"nightSnoozeIntervalSlider",
[NSNumber numberWithInt:0], #"dawnAlarmDelaySlider",
[NSNumber numberWithInt:0], #"noonAlarmDelaySlider",
[NSNumber numberWithInt:0], #"afternoonAlarmDelaySlider",
[NSNumber numberWithInt:0], #"sunsetAlarmDelaySlider",
[NSNumber numberWithInt:0], #"nightAlarmDelaySlider",
nil];
settingsData = [NSKeyedArchiver archivedDataWithRootObject:settingsDict];
[defaults setObject:settingsData forKey:(NSString *)#"SettingsKey"];
[defaults synchronize];
}
Thanks in advance.
I changed this line
if (!settingsData)
[self createSettings];
to
settingsDict = [NSKeyedUnarchiver unarchiveObjectWithData:settingsData];
if (!settingsData || !settingsDict)
[self createSettings];
and everything worked.

Getting sound in decibel

I want the sound which i am recording from my iPhone mic in decibels. I am using
[recorder peakPowerForChannel:]
but it giving in -160 to 0 range and i have requirement of taking 140 dBs as
a threshold. Can anyone help me with the same…?
Here is the Below sample code which i am trying :
NSMutableDictionary *recordSettings = [[NSMutableDictionary alloc] init];
[recordSettings setObject:[NSNumber numberWithInt:kAudioFormatAppleLossless] forKey: AVFormatIDKey];
[recordSettings setObject:[NSNumber numberWithFloat:22050.0] forKey: AVSampleRateKey];
// [recordSettings setObject:[NSNumber numberWithInt:2] forKey:AVNumberOfChannelsKey];
[recordSettings setObject:[NSNumber numberWithInt:12800] forKey:AVEncoderBitRateKey];
[recordSettings setObject:[NSNumber numberWithInt:16] forKey:AVLinearPCMBitDepthKey];
[recordSettings setObject:[NSNumber numberWithInt: AVAudioQualityLow] forKey: AVEncoderAudioQualityKey];
NSError* error = nil;
recorder = [[AVAudioRecorder alloc] initWithURL:recordedFile settings:recordSettings error:&error];
[recorder prepareToRecord];
recorder.meteringEnabled = YES;
[recorder record];
NSTimer *blowTimer=[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:#selector(timerTask) userInfo:nil repeats:YES];
[[NSRunLoop currentRunLoop] addTimer: blowTimer
forMode: NSDefaultRunLoopMode];
-(void)timerTask
{
[recorder updateMeters];
float averagePower = [recorder averagePowerForChannel:0];
}

is it possible recording through the 3.5mm headphone jack in iphone sdk

I am making an app and i have created a functionality to record voice with iPhone but recording is not possible with 3.5mm headphone jack, its only working with iPhone mic. So please Suggest me what should i do.
My Recording code is:
-(void)recording
{
[recordBtn setImage:[UIImage imageNamed:#"green_btn.png"] forState:UIControlStateNormal];
NSLog(#"startRecording");
inc_Bar=0.0;
// [self performSelector:#selector(stopRecording) withObject:nil afterDelay:10.0f];
[self increaseProgressBar];
progressBarTimer = [NSTimer scheduledTimerWithTimeInterval:recordingLength/1000.0f target:self selector:#selector(increaseProgressBar) userInfo:nil repeats:YES];
audioRecorder = nil;
// Init audio with record capability
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory:AVAudioSessionCategoryRecord error:nil];
NSMutableDictionary *recordSettings = [[NSMutableDictionary alloc] initWithCapacity:10];
if(recordEncoding == ENC_PCM)
{
[recordSettings setObject:[NSNumber numberWithInt: kAudioFormatLinearPCM] forKey: AVFormatIDKey];
[recordSettings setObject:[NSNumber numberWithFloat:sampleRateFloat] forKey: AVSampleRateKey];
[recordSettings setObject:[NSNumber numberWithInt:2] forKey:AVNumberOfChannelsKey];
[recordSettings setObject:[NSNumber numberWithInt:16] forKey:AVLinearPCMBitDepthKey];
[recordSettings setObject:[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsBigEndianKey];
[recordSettings setObject:[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsFloatKey];
}
else
{
NSNumber *formatObject;
switch (recordEncoding) {
case (ENC_AAC):
formatObject = [NSNumber numberWithInt: kAudioFormatMPEG4AAC];
break;
case (ENC_ALAC):
formatObject = [NSNumber numberWithInt: kAudioFormatAppleLossless];
break;
case (ENC_IMA4):
formatObject = [NSNumber numberWithInt: kAudioFormatAppleIMA4];
break;
case (ENC_ILBC):
formatObject = [NSNumber numberWithInt: kAudioFormatiLBC];
break;
case (ENC_ULAW):
formatObject = [NSNumber numberWithInt: kAudioFormatULaw];
break;
default:
formatObject = [NSNumber numberWithInt: kAudioFormatAppleIMA4];
}
[recordSettings setObject:formatObject forKey: AVFormatIDKey];
[recordSettings setObject:[NSNumber numberWithFloat:sampleRateFloat] forKey: AVSampleRateKey];
[recordSettings setObject:[NSNumber numberWithInt:2] forKey:AVNumberOfChannelsKey];
// [recordSettings setObject:[NSNumber numberWithInt:12800] forKey:AVEncoderBitRateKey];
[recordSettings setObject:[NSNumber numberWithInt:16] forKey:AVLinearPCMBitDepthKey];
[recordSettings setObject:[NSNumber numberWithInt: AVAudioQualityHigh] forKey: AVEncoderAudioQualityKey];
}
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *recDir = [paths objectAtIndex:0];
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:#"%#/recordTest.caf", recDir]];
NSError *error = nil;
audioRecorder = [[ AVAudioRecorder alloc] initWithURL:url settings:recordSettings error:&error];
if ([audioRecorder prepareToRecord] == YES){
[audioRecorder record];
}else {
int errorCode = CFSwapInt32HostToBig ([error code]);
NSLog(#"Error: %# [%4.4s])" , [error localizedDescription], (char*)&errorCode);
}
NSLog(#"recording");
}
Thanks. Please Help.
Based on documentation:
If a headset is plugged in at the time you set this property’s value tokAudioSessionOverrideAudioRoute_Speaker, the system changes the audio routing for input as well as for output: input comes from the built-in microphone; output goes to the built-in speaker.

After record sound file, this can't heard in iPad Air only

I have an app in the Apple Store with voice recording capability. I migrate to Xcode 5.0.2 and SDK 7.
I have no problem with this feature in devices with iOS 6 or 7 except with iPad Air.
This is my record Sound routine:
+(void) startRecording:(NSString *)fileName :(NSString *)fileType
{ NSError* theError = nil;
BOOL result = YES;
// Init audio with record capability
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
result = [audioSession setCategory:AVAudioSessionCategoryRecord error:&theError];
if (!result)
{
NSLog(#"setCategory failed %#", theError);
}
result = [audioSession setActive:YES error:nil];
if (!result)
{
NSLog(#"setActive failed %#", theError);
}
// Verify if you have granted to use microphone. iOS 7 or later
if ([audioSession respondsToSelector:#selector(requestRecordPermission:)]) {
[audioSession requestRecordPermission:^(BOOL granted) {
if (granted) {
// Record Sound
[self recordNow:fileName :fileType];
}
else {
// Microphone disabled code
NSLog(#"Microphone is disabled..");
// We're in a background thread here, so jump to main thread to do UI work.
dispatch_async(dispatch_get_main_queue(), ^{
[[[UIAlertView alloc] initWithTitle:#"Microphone Access Denied"
message:#"This app requires access to your device's Microphone.\n\nPlease enable Microphone access for this app in Settings / Privacy / Microphone"
delegate:nil
cancelButtonTitle:#"Dismiss"
otherButtonTitles:nil] show];
});
}
}];
}
else { // iOS 6
// Record sound
[self recordNow:fileName :fileType];
}
}
// Record Sound
+(void) recordNow:(NSString *)fileName :(NSString *)fileType {
recordEncoding = ENC_AAC;
// Microphone enabled code
if (kDebugMode) {
NSLog(#"Microphone is enabled..");
}
NSMutableDictionary *recordSettings = [[NSMutableDictionary alloc] initWithCapacity:10];
if(recordEncoding == ENC_PCM)
{
[recordSettings setObject:[NSNumber numberWithInt: kAudioFormatLinearPCM] forKey: AVFormatIDKey];
[recordSettings setObject:[NSNumber numberWithFloat:44100.0] forKey: AVSampleRateKey];
[recordSettings setObject:[NSNumber numberWithInt:2] forKey:AVNumberOfChannelsKey];
[recordSettings setObject:[NSNumber numberWithInt:16] forKey:AVLinearPCMBitDepthKey];
[recordSettings setObject:[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsBigEndianKey];
[recordSettings setObject:[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsFloatKey];
}
else
{
NSNumber *formatObject;
switch (recordEncoding) {
case (ENC_AAC):
formatObject = [NSNumber numberWithInt: kAudioFormatMPEG4AAC];
break;
case (ENC_ALAC):
formatObject = [NSNumber numberWithInt: kAudioFormatAppleLossless];
break;
case (ENC_IMA4):
formatObject = [NSNumber numberWithInt: kAudioFormatAppleIMA4];
break;
case (ENC_ILBC):
formatObject = [NSNumber numberWithInt: kAudioFormatiLBC];
break;
case (ENC_ULAW):
formatObject = [NSNumber numberWithInt: kAudioFormatULaw];
break;
default:
formatObject = [NSNumber numberWithInt: kAudioFormatAppleIMA4];
}
[recordSettings setObject:formatObject forKey: AVFormatIDKey];
[recordSettings setObject:[NSNumber numberWithFloat:44100.0] forKey: AVSampleRateKey];
[recordSettings setObject:[NSNumber numberWithInt:2] forKey:AVNumberOfChannelsKey];
[recordSettings setObject:[NSNumber numberWithInt:16] forKey:AVEncoderBitRateKey];
[recordSettings setObject:[NSNumber numberWithInt: AVAudioQualityHigh] forKey: AVEncoderAudioQualityKey];
}
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *recDir = [paths objectAtIndex:0];
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:#"%#/%#.%#", recDir, fileName, fileType]];
NSError *error = nil;
audioRecorder = [[ AVAudioRecorder alloc] initWithURL:url settings:recordSettings error:&error];
[audioRecorder recordForDuration:[[NSUserDefaults standardUserDefaults] integerForKey:kRecordForDuration]];
}
After a lot research inside this site, i found an excellent comment that saves my day here:
"Now that I've removed the AVEncoderBitRateKey and value, it also works on the 5S."
So, i just comment this row and fix it !!
[recordSettings setObject:[NSNumber numberWithInt:16] forKey:AVEncoderBitRateKey];
I can hear again the record sound in iPad Air !
Why happen this? I did not know yet, but its works and maybe you have the same problem and just want to leave a log about this case in this website.

Resources