krafter / DetectingAudioFrequency

An example iPhone project to show how to detect frequency of captured microphone audio.
MIT License
123 stars 30 forks source link

Numbers specified in ViewController.mm #10

Open paulsimon99 opened 4 years ago

paulsimon99 commented 4 years ago

Kudos to your good work! I wonder how you derive the numbers of FrameSize, SampleRate, accumulatorDataLenght, .. in the file?

Thanks for comments

krafter commented 4 years ago

Thank you! Well, sample rates are somewhat standard. 44100 = (human hearing range + some extra range)*2. Some explanations are in this article

Frame size tells you how much data gets accumulated before callback function gets called. In other words how often it's called. It should be power of 2. (512, 1024, ...) Divide frame size by sample rate and you get amount of time in seconds between callbacks. Divide sample rate by frame size and you get FPS (frames per second)

accumulatorDataLenght - is how much data you accumulate before doing frequency detection. Choose any number multiple of frame size.