mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2025-05-24 10:22:26 -04:00
Merge branch 'develop' of bitbucket.org:k1jt/wsjtx into develop
This commit is contained in:
commit
b9888a09ff
@ -1308,9 +1308,6 @@ target_link_libraries (ft8code wsjt_fort wsjt_cxx)
|
||||
add_executable (ft4code lib/ft4/ft4code.f90 wsjtx.rc)
|
||||
target_link_libraries (ft4code wsjt_fort wsjt_cxx)
|
||||
|
||||
add_executable (ft8 lib/ft8.f90 wsjtx.rc)
|
||||
target_link_libraries (ft8 wsjt_fort wsjt_cxx)
|
||||
|
||||
add_executable (ft8sim_fsk lib/ft8/ft8sim_fsk.f90 wsjtx.rc)
|
||||
target_link_libraries (ft8sim_fsk wsjt_fort wsjt_cxx)
|
||||
|
||||
|
@ -110,11 +110,12 @@ elseif(ndeep.eq.2) then
|
||||
npre1=1
|
||||
npre2=0
|
||||
nt=66
|
||||
ntheta=16
|
||||
ntheta=22
|
||||
ntau = 16
|
||||
elseif(ndeep.eq.3) then
|
||||
nord=2
|
||||
nord=1
|
||||
npre1=1
|
||||
npre2=0
|
||||
npre2=1
|
||||
nt=66
|
||||
ntheta=22
|
||||
ntau=16
|
||||
@ -128,10 +129,10 @@ elseif(ndeep.eq.4) then
|
||||
elseif(ndeep.eq.5) then
|
||||
nord=3
|
||||
npre1=1
|
||||
npre2=0
|
||||
npre2=1
|
||||
nt=66
|
||||
ntheta=22
|
||||
ntau=20
|
||||
ntau=16
|
||||
endif
|
||||
|
||||
do iorder=1,nord
|
||||
|
@ -335,7 +335,7 @@ void sync_and_demodulate(float *id, float *qd, long np,
|
||||
|
||||
void noncoherent_sequence_detection(float *id, float *qd, long np,
|
||||
unsigned char *symbols, float *f1, int *shift1,
|
||||
float *drift1, int symfac, int *nblocksize)
|
||||
float *drift1, int symfac, int *nblocksize, int *bitmetric)
|
||||
{
|
||||
/************************************************************************
|
||||
* Noncoherent sequence detection for wspr. *
|
||||
@ -364,6 +364,7 @@ void noncoherent_sequence_detection(float *id, float *qd, long np,
|
||||
lag=*shift1;
|
||||
nblock=*nblocksize;
|
||||
nseq=1<<nblock;
|
||||
int bitbybit=*bitmetric;
|
||||
|
||||
for (i=0; i<162; i++) {
|
||||
fp = f0 + (*drift1/2.0)*((float)i-81.0)/81.0;
|
||||
@ -456,6 +457,9 @@ void noncoherent_sequence_detection(float *id, float *qd, long np,
|
||||
}
|
||||
}
|
||||
fsymb[i+ib]=xm1-xm0;
|
||||
if( bitbybit == 1 ) {
|
||||
fsymb[i+ib]=fsymb[i+ib]/(xm1 > xm0 ? xm1 : xm0);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (i=0; i<162; i++) { //Normalize the soft symbols
|
||||
@ -529,14 +533,14 @@ void subtract_signal(float *id, float *qd, long np,
|
||||
return;
|
||||
}
|
||||
/******************************************************************************
|
||||
Fully coherent signal subtraction
|
||||
Subtract the coherent component of a signal
|
||||
*******************************************************************************/
|
||||
void subtract_signal2(float *id, float *qd, long np,
|
||||
float f0, int shift0, float drift0, unsigned char* channel_symbols)
|
||||
{
|
||||
float dt=1.0/375.0, df=375.0/256.0;
|
||||
float pi=4.*atan(1.0), twopidt, phi=0, dphi, cs;
|
||||
int i, j, k, ii, nsym=162, nspersym=256, nfilt=256; //nfilt must be even number.
|
||||
int i, j, k, ii, nsym=162, nspersym=256, nfilt=360; //nfilt must be even number.
|
||||
int nsig=nsym*nspersym;
|
||||
int nc2=45000;
|
||||
|
||||
@ -579,6 +583,20 @@ void subtract_signal2(float *id, float *qd, long np,
|
||||
}
|
||||
}
|
||||
|
||||
float w[nfilt], norm=0, partialsum[nfilt];
|
||||
//lowpass filter and remove startup transient
|
||||
for (i=0; i<nfilt; i++) partialsum[i]=0.0;
|
||||
for (i=0; i<nfilt; i++) {
|
||||
w[i]=sin(pi*(float)i/(float)(nfilt-1));
|
||||
norm=norm+w[i];
|
||||
}
|
||||
for (i=0; i<nfilt; i++) {
|
||||
w[i]=w[i]/norm;
|
||||
}
|
||||
for (i=1; i<nfilt; i++) {
|
||||
partialsum[i]=partialsum[i-1]+w[i];
|
||||
}
|
||||
|
||||
// s(t) * conjugate(r(t))
|
||||
// beginning of first symbol in reference signal is at i=0
|
||||
// beginning of first symbol in received data is at shift0.
|
||||
@ -592,20 +610,6 @@ void subtract_signal2(float *id, float *qd, long np,
|
||||
}
|
||||
}
|
||||
|
||||
//lowpass filter and remove startup transient
|
||||
float w[nfilt], norm=0, partialsum[nfilt];
|
||||
for (i=0; i<nfilt; i++) partialsum[i]=0.0;
|
||||
for (i=0; i<nfilt; i++) {
|
||||
w[i]=sin(pi*(float)i/(float)(nfilt-1));
|
||||
norm=norm+w[i];
|
||||
}
|
||||
for (i=0; i<nfilt; i++) {
|
||||
w[i]=w[i]/norm;
|
||||
}
|
||||
for (i=1; i<nfilt; i++) {
|
||||
partialsum[i]=partialsum[i-1]+w[i];
|
||||
}
|
||||
|
||||
// LPF
|
||||
for (i=nfilt/2; i<45000-nfilt/2; i++) {
|
||||
cfi[i]=0.0; cfq[i]=0.0;
|
||||
@ -616,7 +620,7 @@ void subtract_signal2(float *id, float *qd, long np,
|
||||
}
|
||||
|
||||
// subtract c(t)*r(t) here
|
||||
// (ci+j*cq)(refi+j*refq)=(ci*refi-cq*refq)+j(ci*refq)+cq*refi)
|
||||
// (ci+j*cq)(refi+j*refq)=(ci*refi-cq*refq)+j(ci*refq+cq*refi)
|
||||
// beginning of first symbol in reference signal is at i=nfilt
|
||||
// beginning of first symbol in received data is at shift0.
|
||||
for (i=0; i<nsig; i++) {
|
||||
@ -675,6 +679,23 @@ unsigned long writec2file(char *c2filename, int trmin, double freq
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int count_hard_errors( unsigned char *symbols, unsigned char *channel_symbols)
|
||||
{
|
||||
int i,is;
|
||||
unsigned char cw[162];
|
||||
unsigned int nerrors;
|
||||
for (i=0; i<162; i++) {
|
||||
cw[i] = channel_symbols[i] >=2 ? 1:0;
|
||||
}
|
||||
deinterleave(cw);
|
||||
nerrors=0;
|
||||
for (i=0; i<162; i++) {
|
||||
is = symbols[i] > 127 ? 1:0;
|
||||
nerrors = nerrors + (is == cw[i] ? 0:1);
|
||||
}
|
||||
return nerrors;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
void usage(void)
|
||||
{
|
||||
@ -710,7 +731,7 @@ int main(int argc, char *argv[])
|
||||
int i,j,k;
|
||||
unsigned char *symbols, *decdata, *channel_symbols, *apmask, *cw;
|
||||
signed char message[]={-9,13,-35,123,57,-39,64,0,0,0,0};
|
||||
char *callsign, *call_loc_pow;
|
||||
char *callsign, *grid, *call_loc_pow;
|
||||
char *ptr_to_infile,*ptr_to_infile_suffix;
|
||||
char *data_dir=NULL;
|
||||
char wisdom_fname[200],all_fname[200],spots_fname[200];
|
||||
@ -720,13 +741,11 @@ int main(int argc, char *argv[])
|
||||
int writenoise=0,usehashtable=1,wspr_type=2, ipass, nblocksize;
|
||||
int nhardmin,ihash;
|
||||
int writec2=0,maxdrift;
|
||||
int shift1, lagmin, lagmax, lagstep, ifmin, ifmax, worth_a_try, not_decoded;
|
||||
int shift1, lagmin, lagmax, lagstep, ifmin, ifmax, not_decoded;
|
||||
unsigned int nbits=81, stacksize=200000;
|
||||
unsigned int npoints, metric, cycles, maxnp;
|
||||
unsigned int npoints, cycles, maxnp, metric;
|
||||
float df=375.0/256.0/2;
|
||||
float freq0[200],snr0[200],drift0[200],sync0[200];
|
||||
float fsymbs[162];
|
||||
int shift0[200];
|
||||
float dt=1.0/375.0, dt_print;
|
||||
double dialfreq_cmdline=0.0, dialfreq, freq_print;
|
||||
double dialfreq_error=0.0;
|
||||
@ -737,16 +756,21 @@ int main(int argc, char *argv[])
|
||||
float *idat, *qdat;
|
||||
clock_t t0,t00;
|
||||
float tfano=0.0,treadwav=0.0,tcandidates=0.0,tsync0=0.0;
|
||||
float tsync1=0.0,tsync2=0.0,ttotal=0.0;
|
||||
float tsync1=0.0,tsync2=0.0,tosd=0.0,ttotal=0.0;
|
||||
|
||||
struct cand { float freq; float snr; int shift; float drift; float sync; };
|
||||
struct cand candidates[200];
|
||||
|
||||
struct result { char date[7]; char time[5]; float sync; float snr;
|
||||
float dt; double freq; char message[23]; float drift;
|
||||
unsigned int cycles; int jitter; int blocksize; unsigned int metric;
|
||||
unsigned char osd_decode; };
|
||||
int nhardmin; int ipass; int decodetype;};
|
||||
struct result decodes[50];
|
||||
|
||||
char *hashtab;
|
||||
hashtab=calloc(32768*13,sizeof(char));
|
||||
char *loctab;
|
||||
loctab=calloc(32768*5,sizeof(char));
|
||||
int nh;
|
||||
symbols=calloc(nbits*2,sizeof(unsigned char));
|
||||
apmask=calloc(162,sizeof(unsigned char));
|
||||
@ -754,6 +778,7 @@ int main(int argc, char *argv[])
|
||||
decdata=calloc(11,sizeof(unsigned char));
|
||||
channel_symbols=calloc(nbits*2,sizeof(unsigned char));
|
||||
callsign=calloc(13,sizeof(char));
|
||||
grid=calloc(5,sizeof(char));
|
||||
call_loc_pow=calloc(23,sizeof(char));
|
||||
float allfreqs[100];
|
||||
char allcalls[100][13];
|
||||
@ -768,9 +793,8 @@ int main(int argc, char *argv[])
|
||||
float minsync2=0.12; //Second sync limit
|
||||
int iifac=8; //Step size in final DT peakup
|
||||
int symfac=50; //Soft-symbol normalizing factor
|
||||
int block_demod=1; //Default is to use block demod on pass 2
|
||||
int subtraction=1;
|
||||
int npasses=2;
|
||||
int npasses=3;
|
||||
int ndepth=-1; //Depth for OSD
|
||||
|
||||
float minrms=52.0 * (symfac/64.0); //Final test for plausible decoding
|
||||
@ -792,7 +816,7 @@ int main(int argc, char *argv[])
|
||||
data_dir = optarg;
|
||||
break;
|
||||
case 'B':
|
||||
block_demod=0;
|
||||
npasses=2;
|
||||
break;
|
||||
case 'c':
|
||||
writec2=1;
|
||||
@ -892,8 +916,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
if((ftimer=fopen(timer_fname,"r"))) {
|
||||
//Accumulate timing data
|
||||
fscanf(ftimer,"%f %f %f %f %f %f %f",
|
||||
&treadwav,&tcandidates,&tsync0,&tsync1,&tsync2,&tfano,&ttotal);
|
||||
fscanf(ftimer,"%f %f %f %f %f %f %f %f",
|
||||
&treadwav,&tcandidates,&tsync0,&tsync1,&tsync2,&tfano,&tosd,&ttotal);
|
||||
fclose(ftimer);
|
||||
}
|
||||
ftimer=fopen(timer_fname,"w");
|
||||
@ -941,11 +965,13 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
if( usehashtable ) {
|
||||
char line[80], hcall[12];
|
||||
char line[80], hcall[13], hgrid[5];
|
||||
if( (fhash=fopen(hash_fname,"r+")) ) {
|
||||
while (fgets(line, sizeof(line), fhash) != NULL) {
|
||||
sscanf(line,"%d %s",&nh,hcall);
|
||||
hgrid[0]='\0';
|
||||
sscanf(line,"%d %s %s",&nh,hcall,hgrid);
|
||||
strcpy(hashtab+nh*13,hcall);
|
||||
if(strlen(hgrid)>0) strcpy(loctab+nh*5,hgrid);
|
||||
}
|
||||
} else {
|
||||
fhash=fopen(hash_fname,"w+");
|
||||
@ -955,21 +981,16 @@ int main(int argc, char *argv[])
|
||||
|
||||
//*************** main loop starts here *****************
|
||||
for (ipass=0; ipass<npasses; ipass++) {
|
||||
if(ipass == 0) {
|
||||
if(ipass==1 && ndecodes_pass == 0) ipass=2;
|
||||
if(ipass < 2) {
|
||||
nblocksize=1;
|
||||
maxdrift=4;
|
||||
minsync2=0.12;
|
||||
}
|
||||
if(ipass == 1 ) {
|
||||
if(block_demod == 1) {
|
||||
nblocksize=3; // try all blocksizes up to 3
|
||||
if(ipass == 2 ) {
|
||||
nblocksize=4; // try 3 blocksizes plus bitbybit normalization
|
||||
maxdrift=0; // no drift for smaller frequency estimator variance
|
||||
minsync2=0.10;
|
||||
} else { // if called with -B, revert to "classic" wspr params
|
||||
nblocksize=1;
|
||||
maxdrift=4;
|
||||
minsync2=0.12;
|
||||
}
|
||||
}
|
||||
ndecodes_pass=0; // still needed?
|
||||
|
||||
@ -1023,7 +1044,6 @@ int main(int argc, char *argv[])
|
||||
* The corresponding threshold is -42.3 dB in 2500 Hz bandwidth for WSPR-15. */
|
||||
|
||||
float min_snr, snr_scaling_factor;
|
||||
// min_snr = pow(10.0,-7.0/10.0); //this is min snr in wspr bw
|
||||
min_snr = pow(10.0,-8.0/10.0); //this is min snr in wspr bw
|
||||
if( wspr_type == 2 ) {
|
||||
snr_scaling_factor=26.3;
|
||||
@ -1038,32 +1058,31 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Find all local maxima in smoothed spectrum.
|
||||
for (i=0; i<200; i++) {
|
||||
freq0[i]=0.0;
|
||||
snr0[i]=0.0;
|
||||
drift0[i]=0.0;
|
||||
shift0[i]=0;
|
||||
sync0[i]=0.0;
|
||||
candidates[i].freq=0.0;
|
||||
candidates[i].snr=0.0;
|
||||
candidates[i].drift=0.0;
|
||||
candidates[i].shift=0;
|
||||
candidates[i].sync=0.0;
|
||||
}
|
||||
|
||||
int npk=0;
|
||||
unsigned char candidate;
|
||||
if( more_candidates ) {
|
||||
for(j=0; j<411; j=j+2) {
|
||||
candidate = (smspec[j]>min_snr) && (npk<200);
|
||||
if ( candidate ) {
|
||||
freq0[npk]=(j-205)*df;
|
||||
snr0[npk]=10*log10(smspec[j])-snr_scaling_factor;
|
||||
npk++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for(j=1; j<410; j++) {
|
||||
candidate = (smspec[j]>smspec[j-1]) &&
|
||||
(smspec[j]>smspec[j+1]) &&
|
||||
(npk<200);
|
||||
if ( candidate ) {
|
||||
freq0[npk]=(j-205)*df;
|
||||
snr0[npk]=10*log10(smspec[j])-snr_scaling_factor;
|
||||
candidates[npk].freq = (j-205)*df;
|
||||
candidates[npk].snr = 10*log10(smspec[j])-snr_scaling_factor;
|
||||
npk++;
|
||||
}
|
||||
}
|
||||
if( more_candidates ) {
|
||||
for(j=0; j<411; j=j+3) {
|
||||
candidate = (smspec[j]>min_snr) && (npk<200);
|
||||
if ( candidate ) {
|
||||
candidates[npk].freq = (j-205)*df;
|
||||
candidates[npk].snr = 10*log10(smspec[j])-snr_scaling_factor;
|
||||
npk++;
|
||||
}
|
||||
}
|
||||
@ -1076,26 +1095,22 @@ int main(int argc, char *argv[])
|
||||
// Don't waste time on signals outside of the range [fmin,fmax].
|
||||
i=0;
|
||||
for( j=0; j<npk; j++) {
|
||||
if( freq0[j] >= fmin && freq0[j] <= fmax ) {
|
||||
freq0[i]=freq0[j];
|
||||
snr0[i]=snr0[j];
|
||||
if( candidates[j].freq >= fmin && candidates[j].freq <= fmax ) {
|
||||
candidates[i]=candidates[j];
|
||||
i++;
|
||||
}
|
||||
}
|
||||
npk=i;
|
||||
|
||||
// bubble sort on snr, bringing freq along for the ride
|
||||
// bubble sort on snr
|
||||
int pass;
|
||||
float tmp;
|
||||
struct cand tmp;
|
||||
for (pass = 1; pass <= npk - 1; pass++) {
|
||||
for (k = 0; k < npk - pass ; k++) {
|
||||
if (snr0[k] < snr0[k+1]) {
|
||||
tmp = snr0[k];
|
||||
snr0[k] = snr0[k+1];
|
||||
snr0[k+1] = tmp;
|
||||
tmp = freq0[k];
|
||||
freq0[k] = freq0[k+1];
|
||||
freq0[k+1] = tmp;
|
||||
if (candidates[k].snr < candidates[k+1].snr) {
|
||||
tmp = candidates[k];
|
||||
candidates[k]=candidates[k+1];
|
||||
candidates[k+1] = tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1127,7 +1142,7 @@ int main(int argc, char *argv[])
|
||||
float smax,ss,pow,p0,p1,p2,p3;
|
||||
for(j=0; j<npk; j++) { //For each candidate...
|
||||
smax=-1e30;
|
||||
if0=freq0[j]/df+256;
|
||||
if0=candidates[j].freq/df+256;
|
||||
for (ifr=if0-2; ifr<=if0+2; ifr++) { //Freq search
|
||||
for( k0=-10; k0<22; k0++) { //Time search
|
||||
for (idrift=-maxdrift; idrift<=maxdrift; idrift++) { //Drift search
|
||||
@ -1154,10 +1169,10 @@ int main(int argc, char *argv[])
|
||||
sync1=ss/pow;
|
||||
if( sync1 > smax ) { //Save coarse parameters
|
||||
smax=sync1;
|
||||
shift0[j]=128*(k0+1);
|
||||
drift0[j]=idrift;
|
||||
freq0[j]=(ifr-256)*df;
|
||||
sync0[j]=sync1;
|
||||
candidates[j].shift=128*(k0+1);
|
||||
candidates[j].drift=idrift;
|
||||
candidates[j].freq=(ifr-256)*df;
|
||||
candidates[j].sync=sync1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1182,14 +1197,11 @@ int main(int argc, char *argv[])
|
||||
could each work on one candidate at a time.
|
||||
*/
|
||||
for (j=0; j<npk; j++) {
|
||||
memset(symbols,0,sizeof(char)*nbits*2);
|
||||
memset(callsign,0,sizeof(char)*13);
|
||||
memset(call_loc_pow,0,sizeof(char)*23);
|
||||
|
||||
f1=freq0[j];
|
||||
drift1=drift0[j];
|
||||
shift1=shift0[j];
|
||||
sync1=sync0[j];
|
||||
f1=candidates[j].freq;
|
||||
drift1=candidates[j].drift;
|
||||
shift1=candidates[j].shift;
|
||||
sync1=candidates[j].sync;
|
||||
|
||||
// coarse-grid lag and freq search, then if sync>minsync1 continue
|
||||
fstep=0.0; ifmin=0; ifmax=0;
|
||||
@ -1206,7 +1218,7 @@ int main(int argc, char *argv[])
|
||||
sync_and_demodulate(idat, qdat, npoints, symbols, &f1, ifmin, ifmax, fstep, &shift1,
|
||||
lagmin, lagmax, lagstep, &drift1, symfac, &sync1, 1);
|
||||
|
||||
if(ipass == 0) {
|
||||
if(ipass < 2) {
|
||||
// refine drift estimate
|
||||
fstep=0.0; ifmin=0; ifmax=0;
|
||||
float driftp,driftm,syncp,syncm;
|
||||
@ -1244,30 +1256,65 @@ int main(int argc, char *argv[])
|
||||
lagmin, lagmax, lagstep, &drift1, symfac, &sync1, 1);
|
||||
tsync1 += (float)(clock()-t0)/CLOCKS_PER_SEC;
|
||||
|
||||
worth_a_try = 1;
|
||||
} else {
|
||||
worth_a_try = 0;
|
||||
candidates[j].freq=f1;
|
||||
candidates[j].shift=shift1;
|
||||
candidates[j].drift=drift1;
|
||||
candidates[j].sync=sync1;
|
||||
}
|
||||
}
|
||||
|
||||
int nwat=0;
|
||||
int idupe;
|
||||
for ( j=0; j<npk; j++) {
|
||||
idupe=0;
|
||||
for (k=0;k<nwat;k++) {
|
||||
if( fabsf(candidates[j].freq - candidates[k].freq) < 0.05 &&
|
||||
abs(candidates[j].shift - candidates[k].shift) < 16 ) {
|
||||
idupe=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( idupe == 1 ) {
|
||||
if(candidates[j].sync > candidates[k].sync) candidates[k]=candidates[j];
|
||||
} else if ( candidates[j].sync > minsync2 ) {
|
||||
candidates[nwat]=candidates[j];
|
||||
nwat++;
|
||||
}
|
||||
}
|
||||
|
||||
int idt, ii, jittered_shift;
|
||||
float y,sq,rms;
|
||||
not_decoded=1;
|
||||
int osd_decode=0;
|
||||
int ib=1, blocksize;
|
||||
int ib, blocksize, bitmetric;
|
||||
int n1,n2,n3,nadd,nu,ntype;
|
||||
int osd_decode;
|
||||
for (j=0; j<nwat; j++) {
|
||||
memset(symbols,0,sizeof(char)*nbits*2);
|
||||
memset(callsign,0,sizeof(char)*13);
|
||||
memset(grid,0,sizeof(char)*5);
|
||||
memset(call_loc_pow,0,sizeof(char)*23);
|
||||
f1=candidates[j].freq;
|
||||
shift1=candidates[j].shift;
|
||||
drift1=candidates[j].drift;
|
||||
not_decoded=1;
|
||||
osd_decode=0;
|
||||
|
||||
ib=1;
|
||||
while( ib <= nblocksize && not_decoded ) {
|
||||
blocksize=ib;
|
||||
if (ib < 4) { blocksize=ib; bitmetric=0; }
|
||||
if (ib == 4) { blocksize=1; bitmetric=1; }
|
||||
|
||||
idt=0; ii=0;
|
||||
while ( worth_a_try && not_decoded && idt<=(128/iifac)) {
|
||||
while ( not_decoded && idt<=(128/iifac)) {
|
||||
ii=(idt+1)/2;
|
||||
if( idt%2 == 1 ) ii=-ii;
|
||||
ii=iifac*ii;
|
||||
jittered_shift=shift1+ii;
|
||||
nhardmin=0; dmin=0.0;
|
||||
|
||||
// Use mode 2 to get soft-decision symbols
|
||||
// Get soft-decision symbols
|
||||
t0 = clock();
|
||||
noncoherent_sequence_detection(idat, qdat, npoints, symbols, &f1,
|
||||
&jittered_shift, &drift1, symfac, &blocksize);
|
||||
&jittered_shift, &drift1, symfac, &blocksize, &bitmetric);
|
||||
tsync2 += (float)(clock()-t0)/CLOCKS_PER_SEC;
|
||||
|
||||
sq=0.0;
|
||||
@ -1277,7 +1324,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
rms=sqrt(sq/162.0);
|
||||
|
||||
if((sync1 > minsync2) && (rms > minrms)) {
|
||||
if(rms > minrms) {
|
||||
deinterleave(symbols);
|
||||
t0 = clock();
|
||||
|
||||
@ -1293,9 +1340,12 @@ int main(int argc, char *argv[])
|
||||
|
||||
if( (ndepth >= 0) && not_decoded ) {
|
||||
for(i=0; i<162; i++) {
|
||||
fsymbs[i]=symbols[i]-127;
|
||||
fsymbs[i]=symbols[i]-128.0;
|
||||
}
|
||||
t0 = clock();
|
||||
osdwspr_(fsymbs,apmask,&ndepth,cw,&nhardmin,&dmin);
|
||||
tosd += (float)(clock()-t0)/CLOCKS_PER_SEC;
|
||||
|
||||
for(i=0; i<162; i++) {
|
||||
symbols[i]=255*cw[i];
|
||||
}
|
||||
@ -1311,21 +1361,30 @@ int main(int argc, char *argv[])
|
||||
unpack50(message,&n1,&n2);
|
||||
if( !unpackcall(n1,callsign) ) break;
|
||||
callsign[12]=0;
|
||||
if( !unpackgrid(n2, grid) ) break;
|
||||
grid[4]=0;
|
||||
ntype = (n2&127) - 64;
|
||||
int itype;
|
||||
if( (ntype >= 0) && (ntype <= 62) ) {
|
||||
nu = ntype%10;
|
||||
itype=1;
|
||||
if( !(nu == 0 || nu == 3 || nu == 7) ) {
|
||||
nadd=nu;
|
||||
if( nu > 3 ) nadd=nu-3;
|
||||
if( nu > 7 ) nadd=nu-7;
|
||||
n3=n2/128+32768*(nadd-1);
|
||||
if( !unpackpfx(n3,callsign) ) break;
|
||||
if( !unpackpfx(n3,callsign) ) {
|
||||
break;
|
||||
}
|
||||
itype=2;
|
||||
}
|
||||
ihash=nhash(callsign,strlen(callsign),(uint32_t)146);
|
||||
if(strncmp(hashtab+ihash*13,callsign,13)==0) {
|
||||
if( (itype==1 && strncmp(loctab+ihash*5,grid,5)==0) ||
|
||||
(itype==2) ) {
|
||||
not_decoded=0;
|
||||
osd_decode =1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1337,7 +1396,7 @@ int main(int argc, char *argv[])
|
||||
ib++;
|
||||
}
|
||||
|
||||
if( worth_a_try && !not_decoded ) {
|
||||
if( !not_decoded ) {
|
||||
ndecodes_pass++;
|
||||
|
||||
for(i=0; i<11; i++) {
|
||||
@ -1353,22 +1412,21 @@ int main(int argc, char *argv[])
|
||||
// Unpack the decoded message, update the hashtable, apply
|
||||
// sanity checks on grid and power, and return
|
||||
// call_loc_pow string and also callsign (for de-duping).
|
||||
noprint=unpk_(message,hashtab,call_loc_pow,callsign);
|
||||
|
||||
// subtract even on last pass
|
||||
if( subtraction && (ipass < npasses ) && !noprint ) {
|
||||
if( get_wspr_channel_symbols(call_loc_pow, hashtab, channel_symbols) ) {
|
||||
noprint=unpk_(message,hashtab,loctab,call_loc_pow,callsign);
|
||||
if( subtraction && !noprint ) {
|
||||
if( get_wspr_channel_symbols(call_loc_pow, hashtab, loctab, channel_symbols) ) {
|
||||
subtract_signal2(idat, qdat, npoints, f1, shift1, drift1, channel_symbols);
|
||||
if(!osd_decode) nhardmin=count_hard_errors(symbols,channel_symbols);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove dupes (same callsign and freq within 3 Hz)
|
||||
// Remove dupes (same callsign and freq within 4 Hz)
|
||||
int dupe=0;
|
||||
for (i=0; i<uniques; i++) {
|
||||
if(!strcmp(callsign,allcalls[i]) &&
|
||||
(fabs(f1-allfreqs[i]) <3.0)) dupe=1;
|
||||
(fabs(f1-allfreqs[i]) <4.0)) dupe=1;
|
||||
}
|
||||
if( (verbose || !dupe) && !noprint) {
|
||||
strcpy(allcalls[uniques],callsign);
|
||||
@ -1388,17 +1446,19 @@ int main(int argc, char *argv[])
|
||||
|
||||
strcpy(decodes[uniques-1].date,date);
|
||||
strcpy(decodes[uniques-1].time,uttime);
|
||||
decodes[uniques-1].sync=sync1;
|
||||
decodes[uniques-1].snr=snr0[j];
|
||||
decodes[uniques-1].sync=candidates[j].sync;
|
||||
decodes[uniques-1].snr=candidates[j].snr;
|
||||
decodes[uniques-1].dt=dt_print;
|
||||
decodes[uniques-1].freq=freq_print;
|
||||
strcpy(decodes[uniques-1].message,call_loc_pow);
|
||||
decodes[uniques-1].drift=drift1;
|
||||
decodes[uniques-1].cycles=cycles;
|
||||
decodes[uniques-1].jitter=ii;
|
||||
decodes[uniques-1].blocksize=blocksize;
|
||||
decodes[uniques-1].blocksize=blocksize+3*bitmetric;
|
||||
decodes[uniques-1].metric=metric;
|
||||
decodes[uniques-1].osd_decode=osd_decode;
|
||||
decodes[uniques-1].nhardmin=nhardmin;
|
||||
decodes[uniques-1].ipass=ipass;
|
||||
decodes[uniques-1].decodetype=osd_decode;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1430,11 +1490,12 @@ int main(int argc, char *argv[])
|
||||
decodes[i].time, decodes[i].snr,decodes[i].dt, decodes[i].freq,
|
||||
(int)decodes[i].drift, decodes[i].message);
|
||||
fprintf(fall_wspr,
|
||||
"%6s %4s %3d %3.0f %5.2f %11.7f %-22s %2d %5u %4d %4d %4d %2u\n",
|
||||
decodes[i].date, decodes[i].time, (int)(10*decodes[i].sync),
|
||||
"%6s %4s %4d %3.0f %5.2f %11.7f %-22s %2d %2d %2d %4d %2d %4d %5u %5d\n",
|
||||
decodes[i].date, decodes[i].time, (int)(100*decodes[i].sync),
|
||||
decodes[i].snr, decodes[i].dt, decodes[i].freq,
|
||||
decodes[i].message, (int)decodes[i].drift, decodes[i].cycles/81,
|
||||
decodes[i].jitter,decodes[i].blocksize,decodes[i].metric,decodes[i].osd_decode);
|
||||
decodes[i].message, (int)decodes[i].drift, decodes[i].ipass,
|
||||
decodes[i].blocksize,decodes[i].jitter,decodes[i].decodetype,
|
||||
decodes[i].nhardmin,decodes[i].cycles/81,decodes[i].metric);
|
||||
fprintf(fwsprd,
|
||||
"%6s %4s %3d %3.0f %4.1f %10.6f %-22s %2d %5u %4d\n",
|
||||
decodes[i].date, decodes[i].time, (int)(10*decodes[i].sync),
|
||||
@ -1455,8 +1516,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
ttotal += (float)(clock()-t00)/CLOCKS_PER_SEC;
|
||||
|
||||
fprintf(ftimer,"%7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f\n\n",
|
||||
treadwav,tcandidates,tsync0,tsync1,tsync2,tfano,ttotal);
|
||||
fprintf(ftimer,"%7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f\n\n",
|
||||
treadwav,tcandidates,tsync0,tsync1,tsync2,tfano,tosd,ttotal);
|
||||
|
||||
fprintf(ftimer,"Code segment Seconds Frac\n");
|
||||
fprintf(ftimer,"-----------------------------------\n");
|
||||
@ -1467,6 +1528,7 @@ int main(int argc, char *argv[])
|
||||
fprintf(ftimer,"sync_and_demod(1) %7.2f %7.2f\n",tsync1,tsync1/ttotal);
|
||||
fprintf(ftimer,"sync_and_demod(2) %7.2f %7.2f\n",tsync2,tsync2/ttotal);
|
||||
fprintf(ftimer,"Stack/Fano decoder %7.2f %7.2f\n",tfano,tfano/ttotal);
|
||||
fprintf(ftimer,"OSD decoder %7.2f %7.2f\n",tosd,tosd/ttotal);
|
||||
fprintf(ftimer,"-----------------------------------\n");
|
||||
fprintf(ftimer,"Total %7.2f %7.2f\n",ttotal,1.0);
|
||||
|
||||
@ -1482,13 +1544,14 @@ int main(int argc, char *argv[])
|
||||
fhash=fopen(hash_fname,"w");
|
||||
for (i=0; i<32768; i++) {
|
||||
if( strncmp(hashtab+i*13,"\0",1) != 0 ) {
|
||||
fprintf(fhash,"%5d %s\n",i,hashtab+i*13);
|
||||
fprintf(fhash,"%5d %s %s\n",i,hashtab+i*13,loctab+i*5);
|
||||
}
|
||||
}
|
||||
fclose(fhash);
|
||||
}
|
||||
|
||||
free(hashtab);
|
||||
free(loctab);
|
||||
free(symbols);
|
||||
free(decdata);
|
||||
free(channel_symbols);
|
||||
|
@ -240,7 +240,7 @@ int floatcomp(const void* elem1, const void* elem2)
|
||||
return *(const float*)elem1 > *(const float*)elem2;
|
||||
}
|
||||
|
||||
int unpk_(signed char *message, char *hashtab, char *call_loc_pow, char *callsign)
|
||||
int unpk_(signed char *message, char *hashtab, char *loctab, char *call_loc_pow, char *callsign)
|
||||
{
|
||||
int n1,n2,n3,ndbm,ihash,nadd,noprint=0;
|
||||
char grid[5],grid6[7],cdbm[3];
|
||||
@ -279,6 +279,7 @@ int unpk_(signed char *message, char *hashtab, char *call_loc_pow, char *callsig
|
||||
strncat(call_loc_pow,"\0",1);
|
||||
ihash=nhash(callsign,strlen(callsign),(uint32_t)146);
|
||||
strcpy(hashtab+ihash*13,callsign);
|
||||
strcpy(loctab+ihash*5,grid);
|
||||
} else {
|
||||
nadd=nu;
|
||||
if( nu > 3 ) nadd=nu-3;
|
||||
|
@ -24,6 +24,6 @@ void deinterleave(unsigned char *sym);
|
||||
int doublecomp(const void* elem1, const void* elem2);
|
||||
int floatcomp(const void* elem1, const void* elem2);
|
||||
|
||||
int unpk_( signed char *message, char* hashtab, char *call_loc_pow, char *callsign);
|
||||
int unpk_( signed char *message, char* hashtab, char* loctab, char *call_loc_pow, char *callsign);
|
||||
|
||||
#endif
|
||||
|
@ -128,10 +128,12 @@ int main(int argc, char *argv[])
|
||||
int i, c, printchannel=0, writec2=0;
|
||||
float snr=50.0;
|
||||
float f0=0.0, t0=1.0;
|
||||
char *message, *c2filename, *hashtab;
|
||||
char *message, *c2filename, *hashtab, *loctab;
|
||||
c2filename=malloc(sizeof(char)*15);
|
||||
hashtab=malloc(sizeof(char)*32768*13);
|
||||
loctab=malloc(sizeof(char)*32768*5);
|
||||
memset(hashtab,0,sizeof(char)*32768*13);
|
||||
memset(hashtab,0,sizeof(char)*32768*5);
|
||||
|
||||
// message length is 22 characters
|
||||
message=malloc(sizeof(char)*23);
|
||||
@ -169,7 +171,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
unsigned char channel_symbols[162];
|
||||
get_wspr_channel_symbols(message, hashtab, channel_symbols);
|
||||
get_wspr_channel_symbols(message, hashtab, loctab, channel_symbols);
|
||||
|
||||
if( printchannel ) {
|
||||
printf("Channel symbols:\n");
|
||||
|
@ -162,7 +162,7 @@ void interleave(unsigned char *sym)
|
||||
}
|
||||
}
|
||||
|
||||
int get_wspr_channel_symbols(char* rawmessage, char* hashtab, unsigned char* symbols) {
|
||||
int get_wspr_channel_symbols(char* rawmessage, char* hashtab, char* loctab, unsigned char* symbols) {
|
||||
int m=0, ntype=0;
|
||||
long unsigned int n=0;
|
||||
int i, j, ihash;
|
||||
@ -292,7 +292,7 @@ int get_wspr_channel_symbols(char* rawmessage, char* hashtab, unsigned char* sym
|
||||
signed char check_data[11];
|
||||
memcpy(check_data,data,sizeof(char)*11);
|
||||
|
||||
unpk_(check_data,hashtab,check_call_loc_pow,check_callsign);
|
||||
unpk_(check_data,hashtab,loctab,check_call_loc_pow,check_callsign);
|
||||
// printf("Will decode as: %s\n",check_call_loc_pow);
|
||||
|
||||
unsigned int nbytes=11; // The message with tail is packed into almost 11 bytes.
|
||||
|
@ -11,6 +11,6 @@
|
||||
|
||||
extern int printdata;
|
||||
|
||||
int get_wspr_channel_symbols(char* message, char* hashtab, unsigned char* symbols);
|
||||
int get_wspr_channel_symbols(char* message, char* hashtab, char*loctab, unsigned char* symbols);
|
||||
|
||||
#endif
|
||||
|
@ -1491,8 +1491,8 @@ void MainWindow::dataSink(qint64 frames)
|
||||
double f0m1500=m_dialFreqRxWSPR/1000000.0; // + 0.000001*(m_BFO - 1500);
|
||||
t2.sprintf(" -f %.6f ",f0m1500);
|
||||
if((m_ndepth&7)==1) depth_string=" -qB "; //2 pass w subtract, no Block detection, no shift jittering
|
||||
if((m_ndepth&7)==2) depth_string=" -B "; //2 pass w subtract, no Block detection
|
||||
if((m_ndepth&7)==3) depth_string=" -C 5000 -o 4"; //2 pass w subtract, Block detection and OSD.
|
||||
if((m_ndepth&7)==2) depth_string=" -C 500 -o 4 "; //3 pass, subtract, Block detection, OSD
|
||||
if((m_ndepth&7)==3) depth_string=" -C 500 -o 4 -d "; //3 pass, subtract, Block detect, OSD, more candidates
|
||||
QString degrade;
|
||||
degrade.sprintf("-d %4.1f ",m_config.degrade());
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user