6
$\begingroup$

I'm calculating the beat of song through the frequency domain. I have 60 seconds of audio sampled at 48000Hz, multiplied by a Hanning window in the time domain. This gives me a resolution in the frequency domain of 1BPM, and I'm interested in frequencies from ~10 BPM to ~300BPM, which is only the first 300 bins of the 48000*60 bin length FFT. How does the Hanning window affect the phase of the song's beat? Using no window (really a rectangular window) results in a different phase than the Hanning window does.

$\endgroup$
2
  • $\begingroup$ Phase on its own is irrelevant. It only makes sense if you were to reconstruct the signal using an inverse transform (you don't), or you were comparing the signal to some other signal. Are you? $\endgroup$ Commented Jun 23, 2014 at 20:37
  • $\begingroup$ Not really working on this anymore, but I was comparing the phases of multiple audio files and trying to align them. It worked okay. $\endgroup$
    – ablatner
    Commented Jun 24, 2014 at 20:54

2 Answers 2

2
$\begingroup$

Recall that windowing in the time domain is the equivalent of convolution in the frequency domain. Multiplying a signal in the time domain with a Hanning window is the equivalent of convolving the frequency domain signal with the kernel [-1 2 -1]/4.

Thus, if $H(f)$ represents the (non-windowed) frequency response, a corresponding windowed frequency response would be: $$H_w(f) = -0.25H(f-\Delta f) + 0.5H(f) -0.25H(f+\Delta f)$$ where $\Delta f$ is the frequency resolution - else you could write this (with $n$ being a frequency index) as:

$$H_w[n] = -0.25H[n-1] + 0.5H[n] -0.25H[n+1]$$

( windowed frequency response in terms of 'non-windowed' frequency response )

So the phase difference you are looking for is:

delta_phase = angle(Hw(n)) - angle(H(n))

Hope this helps

$\endgroup$
1
$\begingroup$

It't really more of a question of what the rectangular window is doing to your phase relationships, because it doesn't deemphasize the "edge effects" that occur at the beginning and end of your block of samples, which is the whole point of using a non-rectangular window.

Try this experiment: Do a number of FFTs with lengths ranging from 59*48000 samples to 60*48000 samples, using both window types. You'll find that the Hanning window gives much more consistent results than the rectangular window does. The two results will agree best when the length is close to an integer number of beats.

$\endgroup$
6
  • $\begingroup$ Thanks. Because changing the length affects the resolution and changes the frequencies, I did a linear interpolation of the phase using the bins just below and above 130 (which is the known BPM for this song), and I got this nice plot of frequency vs phase. With the Hanning window, they all overlap pretty well. puu.sh/6zozE.png $\endgroup$
    – ablatner
    Commented Jan 26, 2014 at 23:28
  • $\begingroup$ Just out of curiosity, are you analyzing the audio signal directly, or the envelope of the audio signal? $\endgroup$
    – Dave Tweed
    Commented Jan 27, 2014 at 0:44
  • $\begingroup$ I'm analyzing it directly. Would finding the envelope and analyzing that give more precise calculations? This is my first time analyzing real audio, but I think it should get rid of most of the high frequency components and leave the range that I'm actually interested in. Is that right? $\endgroup$
    – ablatner
    Commented Jan 27, 2014 at 9:03
  • 2
    $\begingroup$ In terms of the audio, there's actually very little energy at 2.17 Hz, and the microphone and recording system aren't really designed to capture energy at such low frequencies. Musically, what we think of as "beat" is a pulsation in the overall energy level of the sound, and this is best extracted from the envelope data. $\endgroup$
    – Dave Tweed
    Commented Jan 27, 2014 at 12:13
  • $\begingroup$ Then I'll also try analyzing the envelope, thanks. $\endgroup$
    – ablatner
    Commented Jan 28, 2014 at 2:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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