I once again raise a question regarding DSPLIB's FFT / IFFT scaling, as this topic is not well-covered in the API documentation ( http://focus.ti.com/lit/ug/sprueb8b/sprueb8b.pdf ).
I'm using
*TMS320TCI6482
*C64x+ DSP Library (DSPLIB) v2.10 .... ( http://focus.ti.com/docs/toolsw/folders/print/sprc265.html )
*C6000 Code Generation Tools (CGT) v7.0.1 .... ( https://www-a.ti.com/downloads/sds_support/TICodegenerationTools/download.htm )
*everything in little Endian
I compiled mentioned DSPLIB with mentioned CGT. I'm sampling signals from a microphone. The codec (AIC23B) provides samples at 48 kHz.
First, I generate twiddle factors for both my 256-FFT and my 256-IFFT
gen_twiddle_fft16x16(w, 256);
gen_twiddle_ifft16x16(iw, 256);
(sidenote 1: oddly, the twiddle functions are not part of the compiled library distribution, but are only available in source code)
(sidenote 2: oddly, the API documentation makes the impression that it's okay to use the same twiddle factors for both the FFT and IFFT, which is imho wrong)
I collect 256 samples of size short / Int16 / Q15 (everything is the same anyways) in an array, x1[512]. I write the samples to every even memory position (real parts). The odd memory positions are zero (imaginary parts).
I then take these 256 samples, pass them through one of DSPLIB's FFT function:
DSP_fft16x16(w, 256, x1, y1);
I then take the transformed samples and put them in the IFFT:
DSP_ifft16x16(iw, 256, y1, y2);
(sidenote 3: the FFT / IFFT functions work destructively on the input arrays. This is not documented in the API documentation)
Now I play back the real part of the y2 array on my headphones. When I whisper into the microphone, I can hear the same coming out of my headphone as what I'm whispering into the microphone. This is good.... When I speak with normal loudness, I only get distorted signals. This is bad.
I guess the distortion comes from overflow during the FFT and IFFT phases whenever these transforms have to work on signals which are too strong/loud/have to much energy. I tried different scalings for both y1 and y2 (dividing by 4... 8... 64... 256... etc.), but I always get distortions when speaking with normal loudness.
So the question is: How do I scale correctly? Basically all I want is speak in the microphone at any loudness and hear the same in my headphones. This should be possible with 256-FFT and 256-IFFT at 16 bits, right? Notice that the dynamic range of my samples is important (it's voice).
Basically, the problem with DSPLIB is, that both
*the API does not abstract/hide FFT domain knowledge, expecting the user to be an FFT implementation expert and knowing about scaling, twiddle factors, overflow and such, and
*the API documentation does not explain the usage of the API well.
I'm looking forward for your suggestions.
Cheers,
Jerry