Get sound frequency with Android FFT

北城余情 提交于 2019-11-30 15:58:47

Your FFT code doesn't give you frequency. It gives you an array of complex values at a bunch of different frequencies. And there may be a bug in your code if you are just looking at the "real" or cosine component of the FFT result instead of the vector magnitude of each complex component.

Each element of your toTransform[i] array after the FFT gives you a complex value for frequencies around or near (i * sampleRate / blockSize). You could find the maxima of the magnitudes of this array to estimate the approximate frequency at which the magnitude was greatest. You could also interpolate the maxima to improve this frequency estimate.

But if you are looking for a pitch estimate (of a guitar note for instance), that can be very different from a peak frequency estimate. Perhaps you might want to look into some pitch estimation algorithms instead.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!