开发者

iPhone SDK measure frequency over iphone mic

I need a way to get the frequency from the microphone and determine the average frequency. Is there a library or something to handle this?

开发者_JAVA技巧

Thanks


If you're targeting iOS 4 and above, Apple now includes the Accelerate framework. From Apple's "What's new" page:

http://developer.apple.com/technologies/iphone/whats-new.html#api

Accelerate

Accelerate provides hundreds of mathematical functions optimized for iPhone and iPod touch, including signal-processing routines, fast Fourier transforms, basic vector and matrix operations, and industry-standard functions for factoring matrices and solving systems of linear equations.


You'll want to use an FFT, so I'd recommend looking at this Q&A:

Do you know a good and efficient FFT?


You can use the EZAudio Class to get the Frequency Download the Demo Here and use this method to get Frequency

- (void) fft:(EZAudioFFT *)fft updatedWithFFTData:(float *)fftData bufferSize:(vDSP_Length)bufferSize
 {
     float maxFrequency = [fft maxFrequency];

       NSString *noteName = [EZAudioUtilities noteNameStringForFrequency:maxFrequency
                                                                includeOctave:YES];
            dispatch_async(dispatch_get_main_queue(), ^{
                [audioPlotFreq updateBuffer:fftData withBufferSize:(UInt32)bufferSize];
            NSLog(@"Frequncy : %f Highest Note : %@",maxFrequency,noteName);
      });
 } 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜