I analyzed the code and tried to understand every part of the algorithm. I came across this part where the bitwise and operator were used
if (qpd >= 0) qpd += qpd&1;
else qpd -= qpd&1;
From what I understand, the algorithm wants to use character 1 as a mask for the qpd variable, but since the number is 1, there is no point in doing an operation that makes almost no changes. Please enlighten me here since I am lost.
A closed loop that receives the magnitude and frequency of data from an array that uses a bitwise operator looks like this:
for (k = 0; k <= fftFrameSize2; k++) {
real = gFFTworksp[2*k];
imag = gFFTworksp[2*k+1];
magn = 2.*sqrt(real*real + imag*imag);
phase = atan2(imag,real);
tmp = phase - gLastPhase[k];
gLastPhase[k] = phase;
tmp -= (double)k*expct;
qpd = tmp/M_PI;
if (qpd >= 0) qpd += qpd&1;
else qpd -= qpd&1;
tmp -= M_PI*(double)qpd;
tmp = osamp*tmp/(2.*M_PI);
tmp = (double)k*freqPerBin + tmp*freqPerBin;
gAnaMagn[k] = magn;
gAnaFreq[k] = tmp;
}
source
share