Search code examples
signal-processingaubio

How do I perform windowing on an incoming signal?


I'm using the Aubio library; I can't find this anywhere in the docs at aubio.org or on the internet. When doing processing (specifically pitch detection with aubio_pitch_detect in my case) does Aubio do anything to the incoming audio arrays in terms of windowing, or do I have to implement that myself?

If I need to add it, a simple windowing code sample (or link) would be welcome.


Solution

  • Found this in Performous:

    // Hamming window
    for (size_t i=0; i < FFT_N; i++) {
        m_window[i] = 0.53836 - 0.46164 * std::cos(2.0 * M_PI * i / (FFT_N - 1));
    }
    

    Edit: To address the "omg is it + or - or what" question, you need to look a little further to see whether you're multiplying by sin or cos of π*i/FFT_N. Because sin(0) = 0 and cos(0) = 1, you are looking at the difference between a window that looks (approximately!) like this:

    enter image description here

    or like this:

    enter image description here

    Note that if you put one after the other, they both look like this:

    enter image description here

    So while the specific processing you want to do on the signal after you window it might affect which windowing option you choose they are not in fact fundamentally opposed, just aligned differently.