diff --git a/Core/config.h b/Core/config.h index 5eacba42..a5be10c1 100644 --- a/Core/config.h +++ b/Core/config.h @@ -45,14 +45,22 @@ inline void null_func(const char *format, ...) { } #define DbgPrintf DbgEmpty #endif -#define SWVERSION "1.3.0 RC1" +#define SWVERSION "1.3.3 Alfa" #define SETTINGS_IDENTIFIER "sddc_1.06" #define SWNAME "ExtIO_sddc.dll" #define QUEUE_SIZE 32 #define WIDEFFTN // test FFTN 8192 -#define FFTN_R_ADC (8192) // FFTN used for ADC real stream DDC tested at 2048, 8192, 32768, 131072 +#define FFTN_R_ADC (32768) // FFTN used for ADC real stream DDC tested at 2048, 8192, 32768, 131072 +#define HALF_FFT (FFTN_R_ADC / 2) +//#define HTLEN ( HALF_FFT / 4 + 1) // ok +#define HTLEN ( HALF_FFT * 3 / 8 + 1 ) // ok +//#define HTLEN ( HALF_FFT * 7 / 16 + 1 ) // ok ? +//#define HTLEN ( HALF_FFT / 2 + 1 ) // distortion at edges ???? +#ifdef _WIN32 +#define _SOFT_TONE_DEBUG // Generate soft tone period transferSamples debug +#endif // GAINFACTORS to be adjusted with lab reference source measured with HDSDR Smeter rms mode #define BBRF103_GAINFACTOR (7.8e-8f) // BBRF103 diff --git a/Core/fft_mt_r2iq.cpp b/Core/fft_mt_r2iq.cpp index 9bcf5803..26693c94 100644 --- a/Core/fft_mt_r2iq.cpp +++ b/Core/fft_mt_r2iq.cpp @@ -40,6 +40,9 @@ fft_mt_r2iq::fft_mt_r2iq() : r2iqControlClass(), filterHw(nullptr) { +#ifdef _SOFT_TONE_DEBUG + genphase = 0.0; +#endif mtunebin = halfFft / 4; mfftdim[0] = halfFft; for (int i = 1; i < NDECIDX; i++) @@ -166,7 +169,7 @@ void fft_mt_r2iq::Init(float gain, ringbuffer *input, ringbuffer } filterplan_t2f_c2c = fftwf_plan_dft_1d(halfFft, pfilterht, filterHw[0], FFTW_FORWARD, FFTW_MEASURE); - float *pht = new float[halfFft / 4 + 1]; + float *pht = new float[HTLEN]; const float Astop = 120.0f; const float relPass = 0.85f; // 85% of Nyquist should be usable const float relStop = 1.1f; // 'some' alias back into transition band is OK @@ -176,7 +179,7 @@ void fft_mt_r2iq::Init(float gain, ringbuffer *input, ringbuffer // to allow same stopband-attenuation for all decimations float Bw = 64.0f / mratio[d]; // Bw *= 0.8f; // easily visualize Kaiser filter's response - KaiserWindow(halfFft / 4 + 1, Astop, relPass * Bw / 128.0f, relStop * Bw / 128.0f, pht); + KaiserWindow(HTLEN, Astop, relPass * Bw / 128.0f, relStop * Bw / 128.0f, pht); float gainadj = gain * 2048.0f / (float)FFTN_R_ADC; // reference is FFTN_R_ADC == 2048 @@ -185,7 +188,7 @@ void fft_mt_r2iq::Init(float gain, ringbuffer *input, ringbuffer pfilterht[t][0] = pfilterht[t][1]= 0.0F; } - for (int t = 0; t < (halfFft/4+1); t++) + for (int t = 0; t < (HTLEN); t++) { pfilterht[halfFft-1-t][0] = gainadj * pht[t]; } diff --git a/Core/fft_mt_r2iq.h b/Core/fft_mt_r2iq.h index 8aa6f766..b29fb655 100644 --- a/Core/fft_mt_r2iq.h +++ b/Core/fft_mt_r2iq.h @@ -26,7 +26,33 @@ class fft_mt_r2iq : public r2iqControlClass void TurnOff(void); bool IsOn(void); -protected: +protected: + +#ifdef _SOFT_TONE_DEBUG + double genphase; +#define PI ( 3.14159265358979323846 ) + float burst[transferSamples + HALF_FFT]; + void init_burst(void) + { + for (int m = 0; m < transferSamples + HALF_FFT; m++) + { + genphase += (PI * 2048.0) / (double)(transferSamples); + + if (genphase > 2.0 * PI) genphase -= 2.0 * PI; + + burst[m] = 32768.0F * sin(genphase); + } + } + void generate_float( float* output, int size) + { + for (int m = 0; m < size; m++) + { + output[m] = burst[m]; + // output[m] = 32768.0F; // generate DC + + } + } +#endif template void convert_float(const int16_t *input, float* output, int size) { diff --git a/Core/fft_mt_r2iq_impl.hpp b/Core/fft_mt_r2iq_impl.hpp index 7d9662b1..2532b0f6 100644 --- a/Core/fft_mt_r2iq_impl.hpp +++ b/Core/fft_mt_r2iq_impl.hpp @@ -9,7 +9,9 @@ plan_f2t_c2c = &plans_f2t_c2c[decimate]; fftwf_complex* pout = nullptr; int decimate_count = 0; - +#ifdef _SOFT_TONE_DEBUG + init_burst(); // if DEBUG_LENGTH +#endif while (r2iqOn) { const int16_t *dataADC; // pointer to input data const int16_t *endloop; // pointer to end data to be copied to beginning @@ -49,8 +51,12 @@ } else { +#ifdef _SOFT_TONE_DEBUG + generate_float(inloop, transferSamples + halfFft); +#else convert_float(endloop, inloop, halfFft); convert_float(dataADC, inloop + halfFft, transferSamples); +#endif } #if PRINT_INPUT_RANGE