Look at the example projects, especially the SimpleFFT example. You may need to pull the latest tip on the develop branch from GitHub, I know that project was broken on the main branch.
In fact Id break up what you are trying to do here.
Start by trying to get a meter showing the current level on the UI. That’ll be a less painful introduction than writing a tuner. You can then turn it into a tuner later.
The audio to process will be delivered into your plugin with the processBlock method. You need to set up your DAW application to send audio from your microphone into the plugin, it’s not the plugin’s job to deal with that.
i have a task to process the signal with FFT so inevitably i should try using FFT for tuner, please give me the reason why FFT can not be used to make the tuner? thanks a lot
I suspect it’s not easy to make it accurate. It’s not like you get a frequency bin for every note, especially at the bass end. I think there’s a way using the phase of the bins…but I never looked into it.
The FFT takes N samples and spits out the magnitude and phase information (as a complex number) into N “bins.” That means you have a frequency resolution of Fs/N. So for a full range audio tuner, you need to decide your resolution by picking the lowest note (say, A-1 which has a frequency of 27.5Hz), and 1 cent around there which is about 0.016Hz. If your sample rate is 44.1kHz, that means your minimum fft size (N) is 2,756,250 samples. Which is prohibitively large just from the computation, and that would be a latency of about 62.5 seconds (need to wait that long to collect that many samples). So obviously that’s a no go.
What you’re looking for is a real time pitch detection algorithm. There are a number of methods just a Google search away, many of which use the FFT or the autocorrelation of a signal, which can be computed with an FFT.