DSPRelated.com
Forums

Hanning Windowing

Started by happ...@yahoo.com.sg December 5, 2007
Hi all,

I would like to know how to apply the hanning window to an audio signal that is sampled at 16KHz?And how do we set the duration of the hanning window to be 20ms for the whole signal?

Thanks!!
Hi,

Generate Hanning window with N = 320 from this wikipedia link. N = 320 will correspond to 20 ms at 16 kHz. Frame your input signal with 320 samples in each frame. 2 consecutive input frames should have an overlap of 50%(assuming you need this for a compression algo. Else, for any other analysis, you could go for a higher percentage overlap, ofcourse with a different window function).

Multiply Frame1, Frame2, .. with the window to get the windowed signal.

Multiply Frame1, Frame2, .. of the recieved signal with the same window. Overlap and add the second half of Frame1 with first half of Frame2 to get 160 samples of the reconstructed signal.. and so on and so forth for the rest of the frames.

There is a book by Marina Bosi on Audio Coding which explains these concepts well.

Regards,
Amit

----- Original Message ----
From: "h...@yahoo.com.sg"
To: a...
Sent: Wednesday, 5 December, 2007 1:27:16 PM
Subject: [audiodsp] Hanning Windowing

Hi all,

I would like to know how to apply the hanning window to an audio signal that is sampled at 16KHz?And how do we set the duration of the hanning window to be 20ms for the whole signal?

Thanks!!
I supose that you're going to do a FFT, isn't it?
You have to buffer N samples of your signal and multiply each sample by a N samples of a Hanning window:

W(n)=0.5*(1-cos(2*pi*n/N-1)), n=0 to N-1

The number of samples will depend of number of lines of the FFT.
If you want a 1024 lines FFT, you have to buffer 2048 samples and multiply by a window with 2048 samples. (2048/16000 = 128ms).

It is convenient to do a zero padding, to reach a better resolution.

Regards

Hi all,
>
>I would like to know how to apply the hanning window to an audio signal that is sampled at 16KHz?And how do we set the duration of the hanning window to be 20ms for the whole signal?
>
>Thanks!!
Here is how I coded up a Blackman window in C:
for(k=0;k
{

double w=0.42 - 0.5*cos(2*pi*k/(NFFT-1)) + 0.08*cos(4*pi*k/(NFFT-1));

samples[k] *=w;

}

In this case the window fits over the signal that is NFFT samples long

On 12/6/07, Amit wrote:
>
> Hi,
>
> Generate Hanning window with N = 320 from this wikipedia link. N = 320
> will correspond to 20 ms at 16 kHz. Frame your input signal with 320 samples
> in each frame. 2 consecutive input frames should have an overlap of
> 50%(assuming you need this for a compression algo. Else, for any other
> analysis, you could go for a higher percentage overlap, ofcourse with a
> different window function).
>
> Multiply Frame1, Frame2, .. with the window to get the windowed signal.
>
> Multiply Frame1, Frame2, .. of the recieved signal with the same window.
> Overlap and add the second half of Frame1 with first half of Frame2 to get
> 160 samples of the reconstructed signal.. and so on and so forth for the
> rest of the frames.
>
> There is a book by Marina Bosi on Audio Coding which explains these
> concepts well.
>
> Regards,
> Amit
>
> ----- Original Message ----
> From: "h...@yahoo.com.sg " <
> h...@yahoo.com.sg >
> To: a...
> Sent: Wednesday, 5 December, 2007 1:27:16 PM
> Subject: [audiodsp] Hanning Windowing
>
> Hi all,
>
> I would like to know how to apply the hanning window to an audio signal
> that is sampled at 16KHz?And how do we set the duration of the hanning
> window to be 20ms for the whole signal?
>
> Thanks!!
>