开发者

Determine frequency from received audio mic input

开发者 https://www.devze.com 2023-02-17 18:57 出处:网络
For searching over internet , i have enough code to record audio mic input.Using Speak here sample code from apple sample code.What i want is ,i want to display a Frequency in (UILabel) in my applicat

For searching over internet , i have enough code to record audio mic input.Using Speak here sample code from apple sample code.What i want is ,i want to display a Frequency in (UILabel) in my application. I have an ipod touch 3rd generation ,i record audio using Headphone mic.Whatever i received input over mic , i want to display its frequency range(hz) in UILabel. I also downloaded the code aurio touch but all give some tips to find frequency.No one gave any sample code to determine frequency using fft in auriotouch.I am new to iphone app development.This is my first task,so i want done it good.So plz guide me a right way to do this.And i am also didnt know about digital signal processing.(I have one doube , is it only possible to determine frequency using drawed area of sine wave or we calculate over own).

For long surfing i have got one more sample name SCListener , there is source in github.When i download and run the code it displayed averagePower,peakPower,and frequency values displayed in label.Is this correct example to use in开发者_如何学Go my code ?And also i didnt know the output should be in hz or khz.

How to check the recorded frequency displayed in label should be correct ?

Plz plz help me ........ Thanks in advance..Sorry for my bad english.


You need to use a Fourier transform. The best library I am aware is FFTW.

Remember, you're not going to get a single frequency; you'll get a mix of all of them up to sample_rate/2. You need some algorithm to pick the correct spike.

You may want to take a step back and read about Nyquist theory and signal processing (specifically FFT) before you go much further otherwise you're going to make a lot of mistakes.


One way to check that your frequency label is displaying the correct value is to test it using some sort of calibrated signal generator.

You might be able to find a Mac or PC audio synthesis/generator program that can play a sine wave at a known frequency. Try it, and check the results displayed by your app using your iPod Touch or the iOS Simulator. (Do not use a musical sound to test, and it may produce a bunch of frequencies very different from the recognized pitch.)

If you have audio input to an FFT working, and are measuring the frequency of a sine wave much louder than any other spectral content, you can try determining the FFT bin (result index) with the largest magnitude. A very approximate estimate of the frequency will be:

frequency_estimate = bin_number * sample_rate / fft_length_in_samples;

The estimate error will be proportional to (sample_rate / fft_length_in_samples).

0

精彩评论

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