Skip to content

Commit

Permalink
Convolution sign fix (#151)
Browse files Browse the repository at this point in the history
Correcting the sign bug the sqroot and gain correction.
  • Loading branch information
ik1xpv authored Jan 13, 2021
1 parent cb4189e commit 5fbf7b6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Core/fft_mt_r2iq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,11 @@ void fft_mt_r2iq::Init(float gain, int16_t **buffers, float** obuffers)
// Bw *= 0.8f; // easily visualize Kaiser filter's response
KaiserWindow(halfFft / 4 + 1, Astop, relPass * Bw / 128.0f, relStop * Bw / 128.0f, pht);

float gainadj = gain / sqrtf(2.0f) * 2048.0f / (float)FFTN_R_ADC; // reference is FFTN_R_ADC == 2048
float gainadj = gain * 2048.0f / (float)FFTN_R_ADC; // reference is FFTN_R_ADC == 2048

for (int t = 0; t < (halfFft/4+1); t++)
{
pfilterht[t][0] = pfilterht[t][1] = gainadj * pht[t];
pfilterht[halfFft-1-t][0] = gainadj * pht[t];
}

fftwf_execute_dft(filterplan_t2f_c2c, pfilterht, filterHw[d]);
Expand Down Expand Up @@ -399,9 +399,9 @@ void * fft_mt_r2iq::r2iqThreadf(r2iqThreadArg *th) {
for (int m = 0; m < count; m++)
{
// besides circular shift, do complex multiplication with the lowpass filter's spectrum
th->inFreqTmp[m][0] = (source[m][0] * filter[m][0] +
th->inFreqTmp[m][0] = (source[m][0] * filter[m][0] -
source[m][1] * filter[m][1]);
th->inFreqTmp[m][1] = (source[m][1] * filter[m][0] -
th->inFreqTmp[m][1] = (source[m][1] * filter[m][0] +
source[m][0] * filter[m][1]);
}
if (mfft / 2 != count)
Expand All @@ -411,9 +411,9 @@ void * fft_mt_r2iq::r2iqThreadf(r2iqThreadArg *th) {
for (int m = start; m < mfft / 2; m++)
{
// also do complex multiplication with the lowpass filter's spectrum
dest[m][0] = (source2[m][0] * filter2[m][0] +
dest[m][0] = (source2[m][0] * filter2[m][0] -
source2[m][1] * filter2[m][1]);
dest[m][1] = (source2[m][1] * filter2[m][0] -
dest[m][1] = (source2[m][1] * filter2[m][0] +
source2[m][0] * filter2[m][1]);
}
if (start != 0)
Expand Down

0 comments on commit 5fbf7b6

Please sign in to comment.