Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

define ht length #227

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions Core/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions Core/fft_mt_r2iq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand Down Expand Up @@ -166,7 +169,7 @@ void fft_mt_r2iq::Init(float gain, ringbuffer<int16_t> *input, ringbuffer<float>
}

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
Expand All @@ -176,7 +179,7 @@ void fft_mt_r2iq::Init(float gain, ringbuffer<int16_t> *input, ringbuffer<float>
// 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

Expand All @@ -185,7 +188,7 @@ void fft_mt_r2iq::Init(float gain, ringbuffer<int16_t> *input, ringbuffer<float>
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];
}
Expand Down
28 changes: 27 additions & 1 deletion Core/fft_mt_r2iq.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool rand> void convert_float(const int16_t *input, float* output, int size)
{
Expand Down
8 changes: 7 additions & 1 deletion Core/fft_mt_r2iq_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -49,8 +51,12 @@
}
else
{
#ifdef _SOFT_TONE_DEBUG
generate_float(inloop, transferSamples + halfFft);
#else
convert_float<true>(endloop, inloop, halfFft);
convert_float<true>(dataADC, inloop + halfFft, transferSamples);
#endif
}

#if PRINT_INPUT_RANGE
Expand Down