Define a window as an entire function.
bool VecBuildBlackmanHarrisWindow( float* pOut, unsigned int num )
{
const float a0 = 0.35875f;
const float a1 = 0.48829f;
const float a2 = 0.14128f;
const float a3 = 0.01168f;
unsigned int idx = 0;
while( idx < num )
{
pOut[idx] = a0 - (a1 * cosf( (2.0f * M_PI * idx) / (num - 1) )) + (a2 * cosf( (4.0f * M_PI * idx) / (num - 1) )) - (a3 * cosf( (6.0f * M_PI * idx) / (num - 1) ));
idx++;
}
return true;
}
Then you can define the window function as follows:
std::vector< float > window( 1024 );
VecBuildBlackmanHarrisWindow( &window.front(), window.size() );
This means that you can pre-calculate the window function.
At this moment, I am sorry that I led you wrong. I'm sorry. I checked my code and calculated the value by averaging all the values of the window samples together and then dividing by 2 (effectively adding them all and dividing by N / 2).
float fTotal = 1.0f;
auto iter = window.begin();
while( iter != window.end() )
{
fTotal += *iter;
iter++;
}
fTotal /= 1024.0f;
fTotal /= 2.0f;
This gives me a value of 0.17969f
( , , , , , ).