I want to do something like speaker verification on iPhone (as a course project). And I'm wondering how to get linear PCM from the speaker. I read about the documentation about queue services, and it seems that it records the sound and then store it to a file. Is there a way to get the linear PCM directly from this? The documentation mentioned something about the buffer, but I don't quite understand that. Maybe it's the key to doing this?
Asked
Active
Viewed 2,731 times
2 Answers
1
Audio Queue Services is for doing this. Just type in the code you need in the call back function. http://developer.apple.com/library/ios/#documentation/MusicAudio/Conceptual/AudioQueueProgrammingGuide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40005343

yoyosir
- 458
- 2
- 11
- 27
0
AVAudioRecorder *audioRecorder = [[AVAudioRecorder alloc]
initWithURL:soundFileURL
settings:recordSettings
error:&error];
audioRecorder.delegate = self;
audioRecorder.meteringEnabled = YES;
then start recording using a NSTimer such as invoke the timer when you click the record button
-(IBAction)record:(id)sender{
NSTimer *recordTimer = [NSTimer scheduledTimerWithTimeInterval:.01 target:self
selector:@selector(recordTimerAction:) userInfo:nil repeats:YES];
}
-(void)recordTimerAction:(id)sender {
[audioRecorder updateMeters];
const double ALPHA = 0.05;
double peakPowerForChannel = pow(10, (0.05 * [audioRecorder peakPowerForChannel:0]));
lowPassResults = ALPHA * peakPowerForChannel + (1.0 - ALPHA) * lowPassResults;
NSLog(@"The Amplitude of the recording Sound is %f",lowPassResults);
NSLog(@"The Normal Linear PCM Value is %f",[audioRecorder peakPowerForChannel:0]);
}
// Delegate method
-(void)audioRecorderDidFinishRecording: (AVAudioRecorder *)recorder successfully:(BOOL)flag{
[recordTimer invalidate];
}

Rafael Ruiz Muñoz
- 5,333
- 6
- 46
- 92

Bala
- 2,895
- 1
- 19
- 60
-
that the amplitude will be in the range from 0 to 1 ., that could be helpful – Bala Apr 26 '12 at 11:32
-
I found that apple has its built-int API for this which is called Audio Queue Services. I think your answer is correct, but the built-in API will be better. – yoyosir May 04 '12 at 04:47
-
@user1214321 Oh, That's Great if that is the better way!! – Bala May 04 '12 at 05:23