Problem in recordsetting of AvAudioRecord in Iphone sdk - objective-c

Here I am getting the Exception when I am setting the recordsetting in AvAudioRecord.
The code I written is as:
I created a button named Record and in the action I used the code as...
I imported the audio file sound.caf
[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryRecord error: nil];
NSDictionary *recordSettings; =[[NSDictionary alloc] initWithObjectsAndKeys:
[NSNumber numberWithFloat: 44100.0], AVSampleRateKey,
[NSNumber numberWithInt: kAudioFormatAppleLossless], AVFormatIDKey,
[NSNumber numberWithInt: 1], AVNumberOfChannelsKey,
[NSNumber numberWithInt: AVAudioQualityMax],
AVEncoderAudioQualityKey,nil];
AVAudioRecorder *newRecorder =[[AVAudioRecorder alloc] initWithURL: soundFileURL settings: recordSettings error: nil];
[recordSettings release];
self.soundRecorder = newRecorder;
[newRecorder release];
Anyone's help will be much appreciated.
Thank you,
Monish Calapatapu.

Remove the line
[newRecorder release];

Related

Strange Error when using AVAudioRecorder with MPEG4AAC

I have tested this on two different iPad3s and on one I can record and playback both .m4a and .caf files on the other I can only playback .caf files.
What I do is record a .m4a-file using the setting
AVFormatIDKey set to kAudioFormatMPEG4AAC
On the one iPad it works fine. If I test it on the other iPad I get the error "OSStatus error 1685348671" when I try to play the file recorded.
However if I comment out that setting and record as a .caf-file it works flawlessly.
Here the relevant code snippets:
NSDictionary *recorderSettings = [NSDictionary dictionaryWithObjectsAndKeys:
//[NSNumber numberWithInt:kAudioFormatMPEG4AAC], AVFormatIDKey,
[NSNumber numberWithInt:AVAudioQualityMin], AVEncoderAudioQualityKey,
[NSNumber numberWithInt:16], AVEncoderBitRateKey,
[NSNumber numberWithInt:1], AVNumberOfChannelsKey,
[NSNumber numberWithFloat:16000.0], AVSampleRateKey, nil];
I then go and call a simple
AudioRecorder *audioRecorder = [[AVAudioRecorder alloc] initWithURL:soundFileURL settings:recorderSettings error:&error];
To play back I call
AudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:soundFileURL error:&error];
[audioPlayer play];
Thanks

AVAudioRecorder error "playback data format is unsupported" on iOS?

The code below is throwing an OSStatus error 1718449215 which, according to the Audio Queue Reference, represents "The playback data format is unsupported."
The code works correctly if I change the AVFormatKey to be kAudioFormatiLBC or kAudioFormatLinearPCM. Is recording using kAudioFormatMPEG4AAC_HE supported on iOS?
NSDictionary *settings =
[NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithFloat: 32000.0], AVSampleRateKey,
[NSNumber numberWithInt: kAudioFormatMPEG4AAC_HE], AVFormatIDKey,
[NSNumber numberWithInt: 1], AVNumberOfChannelsKey,
[NSNumber numberWithInt: AVAudioQualityMedium], AVEncoderAudioQualityKey,
nil];
NSError *error = nil;
AVAudioRecorder *avRecorder = [[AVAudioRecorder alloc]
initWithURL:url
settings:settings
error:&error];
NSAssert(error.code != 1718449215, #"The playback data format is unsupported.");
The Apple docs, specifically the Multimedia Programming Guide ( http://developer.apple.com/library/ios/#documentation/AudioVideo/Conceptual/MultimediaPG/UsingAudio/UsingAudio.html ), only lists the HE-AAC as a playback format. Regular AAC is listed for both playback and recording. So, it looks like HE-AAC only has partial support.

Objective C - record audio noise

I'm making an app that allows user to record audio.
I got it to work but when I playback the audio, the audio has a lot of static background noise. (like "sssssttttt").
Is there any property I can use to reduce that "sssssttttt" static background noise?
Below is the setting that I'm currently using
NSDictionary *settings = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithFloat: 44100.0], AVSampleRateKey,
[NSNumber numberWithInt: kAudioFormatAppleLossless], AVFormatIDKey,
[NSNumber numberWithInt: 1], AVNumberOfChannelsKey,
[NSNumber numberWithInt: AVAudioQualityMax], AVEncoderAudioQualityKey,
nil];
Thanks,
Tee

IOS AVAudioRecorder updatemeters seems not update on device, works on simulator

bool b;
NSLog(#"url");
NSURL *url = [NSURL fileURLWithPath:#"/dev/null"];
NSLog(#"dizionario");
NSDictionary *audioSettings = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithFloat: 44100.0], AVSampleRateKey,
[NSNumber numberWithInt: kAudioFormatAppleLossless], AVFormatIDKey,
[NSNumber numberWithInt: 1], AVNumberOfChannelsKey,
[NSNumber numberWithInt: AVAudioQualityMax], AVEncoderAudioQualityKey,
nil];
NSError *error;
recorder = [[AVAudioRecorder alloc] initWithURL:url settings:audioSettings error:&error];
NSLog(#"audio");
if (recorder) {
[recorder prepareToRecord];
recorder.meteringEnabled = YES;
b=[recorder record];
} else {
NSLog(#"ERRORE:");
NSLog([error description]);
}
and
[recorder updatemeters];
NSLog(#"%f",[recorder peakPowerForChannel:0]);
the mic detects the firs found (i think) because every new runs the value displayed is different, but on the same run the value is not changing at all
any ideas?
found the solution. with audioSession = [[AVAudioSession sharedInstance] retain];
[audioSession setCategory:AVAudioSessionCategoryRecord error: nil];
[audioSession setActive:YES error: nil];

Insert NSMutableDictionary with NSDictionaries

I tried to insert NSDictionary's in a NSMutableDictionary. There is no error but it won't work, it remains empty.
Here's my code:
NSMutableDictionary *einnahmen = [[NSMutableDictionary alloc] initWithCapacity:20];
NSArray *objects = [NSArray arrayWithObjects:
name,
[NSNumber numberWithInt: x],
[NSNumber numberWithInt: y],
[NSNumber numberWithInt: z],
nil];
NSArray *keys = [NSArray arrayWithObjects:
#"name",
#"startJahr",
#"zins",
#"entnahmefaehig",
nil];
NSDictionary *entry = [NSDictionary dictionaryWithObjects:objects forKeys:keys];
[einnahmen setObject:entry forKey:#"name"]; //seems not to work
After [einnahmen setObject:entry the Debugger shows this:
I have solved this problem. The following code was in the wrong init-method:
NSMutableDictionary *einnahmen =
[[NSMutableDictionary alloc] initWithCapacity:20];
The compiler should show a error.