How can i save recorded sounds?(imagine the path of recorded sound is NSUrl *url)
The SpeakHere sample code is quite old, nowadays you can accomplish the same thing much easier using AVFoundation.
zoul
2010-10-24 09:35:07
A:
See the AVAudioRecorder class from the AVFoundation framework. The basic code looks like this:
NSURL *url = [NSURL fileURLWithPath:…];
NSDictionary *settings = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithFloat:44100], AVSampleRateKey,
[NSNumber numberWithInt:1], AVNumberOfChannelsKey,
[NSNumber numberWithInt:16], AVLinearPCMBitDepthKey,
[NSNumber numberWithBool:NO], AVLinearPCMIsBigEndianKey,
[NSNumber numberWithBool:NO], AVLinearPCMIsFloatKey,
nil];
AVAudioRecorder *recorder = [[AVAudioRecorder alloc] initWithURL:url
settings:settings error:NULL];
[recorder record];
You should add error handling and implement the delegate callbacks, see the documentation.
zoul
2010-10-24 09:30:52
I know that ,now i recorded sound and want to save it and use it in future
SajjadZare
2010-10-24 10:15:40
If you created a recording this way, there’s already a sound file sitting on the file system. What do you want to save?
zoul
2010-10-24 10:18:26
I just test it on simulator then if a sound file sitting on the file system my problem solved.Thank you. just one question this code record every sound that play around device How can i change it that just record sound that play with AVAudioPlayer in the app?
SajjadZare
2010-10-24 11:24:32