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
Related
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
I have:
boardValue = [NSNumber numberWithInteger: 2];
NSDictionary * dict = [NSDictionary dictionaryWithValuesForKeys: #"sample", #"word", boardValue , #"value", nil];
This is very similar to the following example:
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: #"value1", #"key1", #"value2", #"key2", nil];
from Apple documentations at:
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/nsdictionary_Class/Reference/Reference.html
I get the error "too many arguments to method call, expect 1, have 5". What is the problem?
dictionaryWithValuesForKeys: takes an array as an argument, not a variable list of arguments.
(Also, I believe it's an instance method, not a class method, so [NSDictionary dictionaryWithValuesForKeys:args]` won't work.)
Notice your code compared to the documentation. You want to call...
boardValue = [NSNumber numberWithInteger: 2];
NSDictionary * dict = [NSDictionary dictionaryWithObjectsAndKeys: #"sample", #"word", boardValue , #"value", nil];
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.
I have a NSMutableArray with 30 dictionaries inside of it. Each contains a name and a value. I currently have the names sorted so that the show in a table view alphabetically. However, I'd like to make a UIButton to give the option of STILL DISPLAYING THE NAMES, but ordered by the value. The value doesn't need to be displayed. Also, where in the .m/.h files would these codes be placed? THANKS!
To be able to help you I need a test data to work with. Let's say your array with data looks like this:
NSMutableArray *aMutableArray = [NSMutableArray arrayWithObjects:
[NSDictionary dictionaryWithObjectsAndKeys:
#"A", #"name",
[NSNumber numberWithInt:6], #"value", nil],
[NSDictionary dictionaryWithObjectsAndKeys:
#"C", #"name",
[NSNumber numberWithInt:2], #"value", nil],
[NSDictionary dictionaryWithObjectsAndKeys:
#"B", #"name",
[NSNumber numberWithInt:4], #"value", nil], nil];
In this case case here's how you sort it by value:
NSSortDescriptor *aSortDescriptor = [[NSSortDescriptor alloc] initWithKey:#"value" ascending:YES];
[aMutableArray sortUsingDescriptors:[NSArray arrayWithObject:aSortDescriptor]];
As for where to place this code place it wherever you need the reordering to happen (in the implementation [.m] file of course).
HTH and if there will be any questions ask them in the comments.
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];