hi guys -
trying build a basic fft analyzer for general spectral information, and also as a base for a polyphonic tuner. (have already tried the fiddle~ based externals (fiddle~, analyzer~, pitch~) but have had a number of issues with these). i seem to be getting close using pfft~ but i'm running into a couple problems coordinating the index with the amp/phase calculation.
using this equation inside pfft~ that i pulled from a past post on the forum:
frequency = phasediff*(samplerate/(hopsize*(2pi))) + fftindex*fftfundamental
but for some reason, using a test cycle~ tone, and peek~ to scroll through the calculated frequencies written to the buffer~, i'm two main issues i think:
1) the amplitude and frequency indexes get off from each other, sometimes the peak amplitude will be 1-2 indexes above or below the test tone, sometimes it will be perfect.
this seems to vary with the pitch of the sine wave as well as with the fft size. i'm guessing it has something to do with the way i'm using the buffer~, or maybe could it be some kind of timing issue?
2) more generally, once aligned, the freq/amp readings seems to spread into the neighboring bins - which i've also read can happen - but i'd like to figure out how to focus it more if possible.
i'm pretty new to fft - so maybe i'm doing something else wrong?
any advice would be great.
here's the patch (two parts with the pfft~):
save this first one as: pfft_bincalc2