I’m trying to replicate the function seen here: http://en.wikipedia.org/wiki/Window_function#Blackman.E2.80.93Harris_window
But I simply can’t get any sense making values. This is my current code:
double blackman_harris(int n, int N){
double a0, a1, a2, a3, seg1, seg2, seg3, w_n;
a0 = 0.35875;
a1 = 0.48829;
a2 = 0.14128;
a3 = 0.01168;
seg1 = a1 * (double) cos((double)(2*M_PI*n)/(double) (N - 1));
seg2 = a2 * (double) cos((double)(4*M_PI*n)/(double) (N - 1));
seg3 = a3 * (double) cos((double)(6*M_PI*n)/(double) (N - 1));
w_n = a0 - seg1 + seg2 - seg3;
return w_n;
}
Thanks a ton for your help.
Define the window as a whole function.
You can then define a window function as follows:
Which means you can pre-calculate the window function in advance.
At this point I’m sorry I have led you wrongly. Sorry. I checked my code and you calculate the value by averaging all the window sample values together and then dividing by 2 (effectively add them all up and divide by N/2).
This gives me a value of 0.17969f
(If you use a larger window this value will change hence the value I gave you before being slightly lower).
Apologies for the confusion