Question

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?

Était-ce utile?

La solution

Autres conseils

        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];

    }
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top