From 303eecdfd6e89daab762dd0749b909f2013653b4 Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Wed, 17 May 2017 13:13:11 +0000 Subject: [PATCH] Make wspr_fsk8d search for DT as well as f0. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@7681 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- CMakeLists.txt | 3 +- lib/fsk4hf/spec8.f90 | 2 +- lib/fsk4hf/wspr_fsk8_downsample.f90 | 16 ++++----- lib/fsk4hf/wspr_fsk8_params.f90 | 3 +- lib/fsk4hf/wspr_fsk8_sim.f90 | 4 --- lib/fsk4hf/wspr_fsk8_wav.f90 | 5 ++- lib/fsk4hf/wspr_fsk8d.f90 | 54 +++++++++++++++-------------- mainwindow.cpp | 14 ++++---- 8 files changed, 49 insertions(+), 52 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 435920737..3301b2c6b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -510,6 +510,7 @@ set (wsjt_FSRCS lib/fsk4hf/wspr5sim.f90 lib/fsk4hf/wspr_fsk8d.f90 lib/fsk4hf/wspr_fsk8_sim.f90 + lib/fsk4hf/wspr_fsk8_wav.f90 lib/fsk4hf/wspr5_downsample.f90 lib/fsk4hf/wspr_fsk8_downsample.f90 lib/fsk4hf/wspr5_wav.f90 @@ -1325,7 +1326,7 @@ install (TARGETS udp_daemon message_aggregator ) install (TARGETS jt9 jt65code qra64code qra64sim jt9code jt4code - msk144code wsprd wspr5d fmtave fcal fmeasure + msk144code wsprd wspr5d wspr_fsk8d fmtave fcal fmeasure RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT runtime BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT runtime ) diff --git a/lib/fsk4hf/spec8.f90 b/lib/fsk4hf/spec8.f90 index 7efc993d5..3c984fa03 100644 --- a/lib/fsk4hf/spec8.f90 +++ b/lib/fsk4hf/spec8.f90 @@ -1,7 +1,7 @@ subroutine spec8(c,s,savg) include 'wspr_fsk8_params.f90' - complex c(0:NZ-1) + complex c(0:NMAXD-1) complex c1(0:NSPS-1) real s(0:NH2,NN) real savg(0:NH2) diff --git a/lib/fsk4hf/wspr_fsk8_downsample.f90 b/lib/fsk4hf/wspr_fsk8_downsample.f90 index ed173bc05..9750e0cbc 100644 --- a/lib/fsk4hf/wspr_fsk8_downsample.f90 +++ b/lib/fsk4hf/wspr_fsk8_downsample.f90 @@ -1,13 +1,12 @@ subroutine wspr_fsk8_downsample(iwave,c) ! Input: i*2 data in iwave() at sample rate 12000 Hz -! Output: Complex data in c(), sampled at 4=500 Hz +! Output: Complex data in c(), sampled at 12000/24=500 Hz include 'wspr_fsk8_params.f90' - parameter (NMAX=240*12000,NFFTD=NMAX/24) integer*2 iwave(NMAX) - complex c(0:NZ-1) - complex c1(0:NFFTD-1) + complex c(0:NMAXD-1) + complex c1(0:NMAXD-1) complex cx(0:NMAX/2) real x(NMAX) equivalence (x,cx) @@ -17,13 +16,12 @@ subroutine wspr_fsk8_downsample(iwave,c) call four2a(x,NMAX,1,-1,0) !r2c FFT to freq domain i0=nint(1500.0/df) c1(0)=cx(i0) - do i=1,NFFTD/2 + do i=1,NMAXD/2 c1(i)=cx(i0+i) - c1(NFFTD-i)=cx(i0-i) + c1(NMAXD-i)=cx(i0-i) enddo - c1=c1/NFFTD - call four2a(c1,NFFTD,1,1,1) !c2c FFT back to time domain - c=c1(0:NZ-1) + c=c1/NMAXD + call four2a(c,NMAXD,1,1,1) !c2c FFT back to time domain return end subroutine wspr_fsk8_downsample diff --git a/lib/fsk4hf/wspr_fsk8_params.f90 b/lib/fsk4hf/wspr_fsk8_params.f90 index 3bc17fa98..c080f0296 100644 --- a/lib/fsk4hf/wspr_fsk8_params.f90 +++ b/lib/fsk4hf/wspr_fsk8_params.f90 @@ -8,6 +8,7 @@ parameter (NSPS0=24576) !Samples per symbol at 12000 S/s parameter (NSPS=NSPS0/NDOWN) !Sam/sym, downsampled (1024) parameter (N7=7*NSPS) !Samples in Costas 7x7 array (7168) parameter (NZ=NSPS*NN) !Samples in downsampled waveform (116,736) -parameter (NZMAX=NSPS0*NN) !Samples in *.wav (2,801,664) +parameter (NMAX=240*12000) !Samples in iwave() +parameter (NMAXD=NMAX/24) !Samples in c(), after downsampling parameter (NFFT1=4*NSPS,NH1=NFFT1/2) parameter (NH2=NSPS/2) diff --git a/lib/fsk4hf/wspr_fsk8_sim.f90 b/lib/fsk4hf/wspr_fsk8_sim.f90 index 4049cdf18..e2c587c8d 100644 --- a/lib/fsk4hf/wspr_fsk8_sim.f90 +++ b/lib/fsk4hf/wspr_fsk8_sim.f90 @@ -5,7 +5,6 @@ program wspr_fsk8_sim use wavhdr include 'wspr_fsk8_params.f90' !Set various constants - parameter (NMAX=300*12000) type(hdr) h !Header for .wav file character arg*12,fname*16 character msg*22,msgsent*22 @@ -59,6 +58,3 @@ program wspr_fsk8_sim enddo 999 end program wspr_fsk8_sim - - include 'wspr_fsk8_wav.f90' - diff --git a/lib/fsk4hf/wspr_fsk8_wav.f90 b/lib/fsk4hf/wspr_fsk8_wav.f90 index 00039ae9e..3b0a0ff38 100644 --- a/lib/fsk4hf/wspr_fsk8_wav.f90 +++ b/lib/fsk4hf/wspr_fsk8_wav.f90 @@ -3,7 +3,6 @@ subroutine wspr_fsk8_wav(baud,xdt,f0,itone,snrdb,iwave) ! Generate iwave() from itone(). include 'wspr_fsk8_params.f90' - parameter (NMAX=240*12000) integer itone(NN) integer*2 iwave(NMAX) real*8 twopi,dt,dphi,phi @@ -15,7 +14,7 @@ subroutine wspr_fsk8_wav(baud,xdt,f0,itone,snrdb,iwave) dat=0. if(snrdb.lt.90) then do i=1,NMAX - dat(i)=gran() !Generate gaussian noise + dat(i)=gran() !Generate gaussian noise, rms = 1.0 enddo bandwidth_ratio=2500.0/6000.0 sig=sqrt(2*bandwidth_ratio)*10.0**(0.05*snrdb) @@ -24,7 +23,7 @@ subroutine wspr_fsk8_wav(baud,xdt,f0,itone,snrdb,iwave) endif phi=0.d0 - k=nint(xdt/dt) + k=nint((xdt+1.0)/dt) do j=1,NN dphi=twopi*(f0+ itone(j)*baud)*dt if(k.eq.0) phi=-dphi diff --git a/lib/fsk4hf/wspr_fsk8d.f90 b/lib/fsk4hf/wspr_fsk8d.f90 index c706a6ad9..67fc809f3 100644 --- a/lib/fsk4hf/wspr_fsk8d.f90 +++ b/lib/fsk4hf/wspr_fsk8d.f90 @@ -15,13 +15,12 @@ program wspr_fsk8d ! Still to do: find and decode more than one signal in the specified passband. include 'wspr_fsk8_params.f90' - parameter (NMAX=240*12000) character arg*8,message*22,cbits*50,infile*80,datetime*11 character*120 data_dir complex csync(0:N7-1) !Sync symbols for Costas 7x7 array complex c1(0:2*N7-1) complex c2(0:2*N7-1) - complex c(0:NMAX-1) !Complex waveform + complex c(0:NMAXD-1) !Complex waveform real*8 fMHz real rxdata(3*ND),llr(3*ND) !Soft symbols real a(5) !For twkfreq1 @@ -86,45 +85,48 @@ program wspr_fsk8d read(infile(j2-4:j2-1),*) nutc datetime=infile(j2-11:j2-1) call wspr_fsk8_downsample(iwave,c) - c(NZ:)=0. - j0=0 -! Need to get jpk ==> xdt - j0b=j0+107*NSPS - c1(0:N7-1)=c(j0:j0+N7-1)*conjg(csync) - c1(N7:)=0. - c2(0:N7-1)=c(j0b:j0b+N7-1)*conjg(csync) - c2(N7:)=0. - call four2a(c1,2*N7,1,-1,1) - call four2a(c2,2*N7,1,-1,1) pmax=0. df1=fs/(2*N7) - do i=0,N7 - f=1500.0 + i*df1 - p=1.e-9*(real(c1(i))**2 + aimag(c1(i))**2 + & - real(c2(i))**2 + aimag(c2(i))**2) - ss(i)=p - if(p.gt.pmax) then - pmax=p - ipk=i - endif - write(32,3201) f,ss(i) -3201 format(f12.4,e12.4) + ipk=0 + jpk=0 +! Get xdt and f0 from the sync arrays + do j0=0,1000,50 + j0b=j0+107*NSPS + c1(0:N7-1)=c(j0:j0+N7-1)*conjg(csync) + c1(N7:)=0. + c2(0:N7-1)=c(j0b:j0b+N7-1)*conjg(csync) + c2(N7:)=0. + call four2a(c1,2*N7,1,-1,1) + call four2a(c2,2*N7,1,-1,1) + do i=0,N7 + f=1500.0 + i*df1 + p=1.e-9*(real(c1(i))**2 + aimag(c1(i))**2 + & + real(c2(i))**2 + aimag(c2(i))**2) + ss(i)=p + if(p.gt.pmax) then + pmax=p + ipk=i + jpk=j0 + endif + enddo enddo - + f0=ipk*df1 + xdt=jpk*dt - 1.0 + sp3n=(ss(ipk-1)+ss(ipk)+ss(ipk+1)) !Sig + 3*noise call pctile(ss,N7,45,base) psig=sp3n-3*base !Sig only pnoise=(2500.0/df1)*base !Noise in 2500 Hz xsnr=db(psig/pnoise) !SNR from sync tones - f0=ipk*df1 + if(jpk.ge.0) c(0:NMAXD-1-jpk)=c(jpk:NMAX-1) + a(1)=-f0 a(2:5)=0. call twkfreq1(c,NZ,fs,a,c) !Mix from f0 down to 0 call spec8(c,s,savg) !Get symbol spectra - j0=0 do j=1,ND k=j+7 ps=s(0:7,k) diff --git a/mainwindow.cpp b/mainwindow.cpp index d54538ba1..5eef67152 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -94,7 +94,7 @@ extern "C" { void genwspr_(char* msg, char* msgsent, int itone[], int len1, int len2); - void genwspr5_(char* msg, char* msgsent, int itone[], int len1, int len2); + void genwspr_fsk8_(char* msg, char* msgsent, int itone[], int len1, int len2); void geniscat_(char* msg, char* msgsent, int itone[], int len1, int len2); @@ -1111,7 +1111,7 @@ void MainWindow::fixStop() if(m_mode=="WSPR") { m_hsymStop=396; } else if(m_mode=="WSPR-LF") { - m_hsymStop=1030; + m_hsymStop=832; } else if(m_mode=="Echo") { m_hsymStop=10; } else if (m_mode=="JT4"){ @@ -1288,7 +1288,7 @@ void MainWindow::dataSink(qint64 frames) QString t3=cmnd; int i1=cmnd.indexOf("/wsprd "); cmnd=t3.mid(0,i1+7) + t3.mid(i1+7); - if(m_mode=="WSPR-LF") cmnd=cmnd.replace("/wsprd ","/wspr5d "); + if(m_mode=="WSPR-LF") cmnd=cmnd.replace("/wsprd ","/wspr_fsk8d "); if (ui) ui->DecodeButton->setChecked (true); m_cmndP1=QDir::toNativeSeparators(cmnd); p1Timer.start(1000); @@ -2972,7 +2972,7 @@ void MainWindow::guiUpdate() &m_currentMessageType, len1, len1); if(m_mode=="WSPR") genwspr_(message, msgsent, const_cast (itone), len1, len1); - if(m_mode=="WSPR-LF") genwspr5_(message, msgsent, const_cast (itone), + if(m_mode=="WSPR-LF") genwspr_fsk8_(message, msgsent, const_cast (itone), len1, len1); if(m_modeTx=="MSK144") { bool bcontest=m_config.contestMode(); @@ -4569,11 +4569,11 @@ void MainWindow::on_actionWSPR_LF_triggered() m_mode="WSPR-LF"; switch_mode (Modes::WSPR); m_modeTx="WSPR-LF"; - m_TRperiod=300; + m_TRperiod=240; m_modulator->setPeriod(m_TRperiod); // TODO - not thread safe m_detector->setPeriod(m_TRperiod); // TODO - not thread safe - m_hsymStop=1030; - m_toneSpacing=0.5*12000.0/8640.0; + m_hsymStop=832; + m_toneSpacing=12000.0/24576.0; setup_status_bar (false); ui->actionWSPR_LF->setChecked(true); m_wideGraph->setPeriod(m_TRperiod,m_nsps);