Hi

I use arduinofft library in my project

I want to get vreal and vimg of majorpeak frequncy how can do it?

Use the peak frequency to determine the closest bin index, then look in that bin?

frequency = bin_number * sampling_freq / FFT_size

so

bin_number = frequency * FFT_size / sampling_freq.

I want img and real value in peak frequency

Post your existing code, then I can point out which variables are your bins.

I want to calculate phase shift in peak frequency and it nead vimg and vreal value.i dont accsess to my code now I will send for you later.

Phase shift relative to what? The phase in an FFT is dependent on when you started sampling.

I want to calculate diffrence phase in two mics, but for peak frequency

Phase is one component of a rectangular to polar conversion of the real and imaginary value.

So:

- find the peak (I assume you mean amplitude)
- perform a rectangular to polar conversion

The code will show what variables are holding the real and imaginary values, these you supply to the library on instantiation I believe.

Phase is meaningless unless the sampling is synchronized to something. Perhaps all will be clear from the code.

There are two sources (microphones), so the phase is the relative phase of one with respect to the other.

Which triggers a thought - perhaps an FFT is not the best way to make a phase comparison of two sine waves (which is what the non-technical term "peak frequency" actually is).

It's possible the original poster is trying to determine the angle of arrival of a tone or some more complex waveform. If so, calculating the time-domain cross correlation and finding the (interpolated) correlation peak is probably more computationally efficient and almost certainly more robust way to go about it.

Correlation doesn't give the sign of the phase difference though as it commutes.

Taking the synchronous FFT of both signals and then dividing the complex amplitudes of the peak frequency can do this though. Division doesn't commute.

The problem is that I suspect the two signals are not sampled synchronously, but in round robin, adding 1/2 a sample time's skew between them - to be calibrated out?

I'm speculating that the OP is really looking for the delay difference between the two channels. That's equivalent to a phase difference for a sine wave input or a linear (unwrapped) phase difference across frequencies in the frequency domain.

I could be wrong about the intentions.

How could sample synchronously?

There are a diffrence time between sampling in any microphons almost 40 micro second in esp32

Subtract 40 us from one stream. Already suggested in #12. I see your confusion. If each sample stream has 80us sampling interval, how can you calculate a "between" value? Easy, interpolation.