views:

26

answers:

2

How can i save recorded sounds?(imagine the path of recorded sound is NSUrl *url)

A: 

Look for SpeakHere example...

nacho4d
The SpeakHere sample code is quite old, nowadays you can accomplish the same thing much easier using AVFoundation.
zoul
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
I know that ,now i recorded sound and want to save it and use it in future
SajjadZare
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
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