Reputation: 3473
I want to record the sound and play the same sound through my application at same time.
Had recorded the sound :-
NSString *soundFilePath = [docsDir
stringByAppendingPathComponent:@"sound.caf"];
NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];
NSDictionary *recordSettings = [NSDictionary
dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:AVAudioQualityMin],
AVEncoderAudioQualityKey,
[NSNumber numberWithInt:16],
AVEncoderBitRateKey,
[NSNumber numberWithInt: 2],
AVNumberOfChannelsKey,
[NSNumber numberWithFloat:44100.0],
AVSampleRateKey,
nil];
NSError *error = nil;
audioRecorder = [[AVAudioRecorder alloc]
initWithURL:soundFileURL
settings:recordSettings
error:&error];
if (error)
{
NSLog(@"error: %@", [error localizedDescription]);
} else {
[audioRecorder prepareToRecord];
[audioRecorder record];
}
-(void)StopRecord{
[audioRecorder stop];
NSString *soundFilePath = [docsDir stringByAppendingPathComponent:@"sound.caf"];
NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];
AVAudioPlayer *newPlayer =
[[AVAudioPlayer alloc] initWithContentsOfURL:soundFileURL error: nil];
if([soundFileURL isFileURL]){
printf("isFileURL\n");
}
[newPlayer prepareToPlay];
[newPlayer setDelegate: self];
[newPlayer play];
}
Now by this..i record the sound and when i click some method the recording get stop and start playing..What should i do..that it play the sound the same moment i start recording..
Upvotes: 2
Views: 524
Reputation: 3473
I got the solution by using SC_listner.
[[SCListener sharedListener] listen];
if ([SCListener sharedListener] != nil)
{
Float32 percentage = [[SCListener sharedListener] peakPower];
}
By doing this..i get the detect the pitch of the real time
Upvotes: 2