1
$\begingroup$

Due to a limitation of the WebAudio specification the FFT available in JavaScript only makes available the real part (1st half) of the calculated frequency data. Is there any way of recreating the phase information (and subsequently improving interpolation of peak frequencies) using the fluctuations in bin amplitude between frames?

$\endgroup$
  • $\begingroup$ What is your objective with the processing? Having the phase information won't improve the frequency precision (if by that you mean the frequency bin values). Looking at the specs it seems the sample is windowed as well, then the frequency bin magnitudes are smoothed. $\endgroup$ – geometrikal Sep 9 '15 at 11:14
  • 1
    $\begingroup$ blogs.zynaptiq.com/bernsee/pitch-shifting-using-the-ft section 3 hints at being able to reconstruct true frequency of a peek using phase information. $\endgroup$ – norlesh Sep 9 '15 at 11:24
  • $\begingroup$ also of the interpolation algorithms mentioned in dspguru.com/dsp/howtos/how-to-interpolate-fft-peak the most accurate one utilises both real and imaginary information. $\endgroup$ – norlesh Sep 9 '15 at 11:27
  • 1
    $\begingroup$ Or maybe you can run the signal through a filter that rotates all phases by 90°, and compute another FFT on the rotated data... $\endgroup$ – Sebastian Reichelt Sep 9 '15 at 16:59
  • 1
    $\begingroup$ webaudio isn't returning the real part of the complex transform, but the log magnitude of the transform. It's returning n/2 points because the other half is symmetric in magnitude (given the real-only audio input) and thus redundant. Thus there is no way to recover the phase. $\endgroup$ – hotpaw2 Sep 10 '15 at 19:56
2
$\begingroup$

webaudio isn't returning the real part of the complex FFT transform, but just the log magnitude of the FFT result. From just this result alone, of the fluctuations between the results of multiple frames, you can't retrieve the phase information.

However, if you can get at the input data and decompose this input vector into a symmetric vector plus an anti-symmetric vector, the magnitude of the FFT of the symmetric vector will be equivalent to scaled real components of the FFT of the original input vector, and the magnitude of the FFT of the anti-symmetric vector will be equal scaled imaginary components of the FFT of the original input vector. Thus, the decomposition plus 2 magnitude-only FFTs will allow you to determine both the magnitude and phase of the FFT components.

v_even = v + v_reversed
v_odd  = v - v_reversed
$\endgroup$
  • $\begingroup$ Doh! it took me about 10 passes at reading the mathematics in the WebAudio FFT section before I finally found where the complex data is converted to magnitude during the smoothing... after a full FFT has been performed (GRRR!!!) $\endgroup$ – norlesh Sep 11 '15 at 12:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.