Fixed Point DSP Rounding Help
Posted: Tue Dec 12, 2017 12:45 am
Can anyone point me to a good reference or help me understand what I should be doing to get my rounding correct when doing multiplication in the frequency domain w/ fixed point numbers?
NOTE: I'm using dsp_fft_split_spectrum and dsp_fft_merge_spectra so that I can save on operations. That's why I'm just multiplying the "two reals" together instead of complex vector multiplication in the following code. The final output seems to have low SNR and some artifacts, however my filter cutoff frequencies do seem to be as expected. Again, I believe it's a rounding problem. If I comment out the multiplication my output sounds fine...any help is appreciated.
NOTE: I'm using dsp_fft_split_spectrum and dsp_fft_merge_spectra so that I can save on operations. That's why I'm just multiplying the "two reals" together instead of complex vector multiplication in the following code. The final output seems to have low SNR and some artifacts, however my filter cutoff frequencies do seem to be as expected. Again, I believe it's a rounding problem. If I comment out the multiplication my output sounds fine...any help is appreciated.
Code: Select all
#define GUARD 2
void mult_two_reals(dsp_complex_t A[NFFT/2][2], dsp_complex_t B[NFFT/2][2]){
unsigned r_one_lo ,r_two_lo;
int r_one_hi , r_two_hi;
int round = 0x7FFFFFFF;
#pragma unsafe arrays
for (int x=0 ; x<2 ; x++){
for(int y=0 ; y<(NFFT/2) ; y++){
{r_one_hi , r_one_lo} = macs(A[y][x].re, B[y][x].re, 0, round);
{r_two_hi , r_two_lo} = macs(A[y][x].im, B[y][x].im, 0, round);
A[y][x].re = r_one_hi<<GUARD | r_one_lo>>(32-GUARD);
A[y][x].im = r_two_hi<<GUARD | r_two_lo>>(32-GUARD);
}
}
}