From 91388f8ba21c66dacf74dbd040199d8e5854180e Mon Sep 17 00:00:00 2001 From: Steve Franke Date: Wed, 4 Jul 2018 09:52:39 -0500 Subject: [PATCH] Create a separate simulation program, ft8sim2, for New Style 77 bit messages. Hashes are not handled yet. Needs more testing. --- CMakeLists.txt | 4 ++ lib/ft8/ft8sim.f90 | 10 ++-- lib/ft8/ft8sim2.f90 | 130 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 139 insertions(+), 5 deletions(-) create mode 100644 lib/ft8/ft8sim2.f90 diff --git a/CMakeLists.txt b/CMakeLists.txt index 08f1e1272..cc2cfa6c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -466,6 +466,7 @@ set (wsjt_FSRCS lib/ft8/ft8code.f90 lib/ft8/ft8_downsample.f90 lib/ft8/ft8sim.f90 + lib/ft8/ft8sim2.f90 lib/gen4.f90 lib/gen65.f90 lib/gen9.f90 @@ -1277,6 +1278,9 @@ target_link_libraries (ft8code wsjt_fort wsjt_cxx) add_executable (ft8sim lib/ft8/ft8sim.f90 wsjtx.rc) target_link_libraries (ft8sim wsjt_fort wsjt_cxx) +add_executable (ft8sim2 lib/ft8/ft8sim2.f90 wsjtx.rc) +target_link_libraries (ft8sim2 wsjt_fort wsjt_cxx) + add_executable (wsprlfsim lib/fsk4hf/wsprlfsim.f90 wsjtx.rc) target_link_libraries (wsprlfsim wsjt_fort wsjt_cxx) diff --git a/lib/ft8/ft8sim.f90 b/lib/ft8/ft8sim.f90 index 7aad00fe0..e88891a49 100644 --- a/lib/ft8/ft8sim.f90 +++ b/lib/ft8/ft8sim.f90 @@ -22,11 +22,11 @@ program ft8sim ! Get command-line argument(s) nargs=iargc() if(nargs.ne.9) then - print*,'Usage: ft8sim "message" nsig|f0 DT fdop del width nfiles snr type' - print*,'Examples: ft8sim "K1ABC W9XYZ EN37" 1500.0 0.0 0.1 1.0 0 10 -18 1' - print*,' ft8sim "K1ABC W9XYZ EN37" 10 0.0 0.1 1.0 25 10 -18 1' - print*,' ft8sim "K1ABC W9XYZ EN37" 25 0.0 0.1 1.0 25 10 -18 1' - print*,' ft8sim "K1ABC RR73; W9XYZ -11" 300 0 0 0 25 1 -10 1' + print*,'Usage: ft8sim "message" nsig|f0 DT fdop del width nfiles snr' + print*,'Examples: ft8sim "K1ABC W9XYZ EN37" 1500.0 0.0 0.1 1.0 0 10 -18' + print*,' ft8sim "K1ABC W9XYZ EN37" 10 0.0 0.1 1.0 25 10 -18' + print*,' ft8sim "K1ABC W9XYZ EN37" 25 0.0 0.1 1.0 25 10 -18' + print*,' ft8sim "K1ABC RR73; W9XYZ -11" 300 0 0 0 25 1 -10' print*,'Make nfiles negative to invoke 72-bit contest mode.' go to 999 endif diff --git a/lib/ft8/ft8sim2.f90 b/lib/ft8/ft8sim2.f90 new file mode 100644 index 000000000..55787c49e --- /dev/null +++ b/lib/ft8/ft8sim2.f90 @@ -0,0 +1,130 @@ +program ft8sim2 + +! Generate simulated "type 2" ft8 files +! Output is saved to a *.wav file. + + use wavhdr + include 'ft8_params.f90' !Set various constants + parameter (NWAVE=NN*NSPS) + type(hdr) h !Header for .wav file + character arg*12,fname*17 + character msg37*37,msgsent37*37,msg40*40 + character c77*77 + character*6 mygrid6 + logical bcontest + complex c0(0:NMAX-1) + complex c(0:NMAX-1) + real wave(NMAX) + integer itone(NN) + integer*1 msgbits(77) + integer*2 iwave(NMAX) !Generated full-length waveform + data mygrid6/'EM48 '/ + +! Get command-line argument(s) + nargs=iargc() + if(nargs.ne.8) then + print*,'Usage: ft8sim "message" nsig|f0 DT fdop del width nfiles snr' + print*,'Examples: ft8sim "K1ABC W9XYZ EN37" 1500.0 0.0 0.1 1.0 0 10 -18' + print*,' ft8sim "K1ABC W9XYZ EN37" 10 0.0 0.1 1.0 25 10 -18' + print*,' ft8sim "K1ABC W9XYZ EN37" 25 0.0 0.1 1.0 25 10 -18' + print*,' ft8sim "K1ABC RR73; W9XYZ -11" 300 0 0 0 25 1 -10' + print*,'Make nfiles negative to invoke 72-bit contest mode.' + go to 999 + endif + call getarg(1,msg37) !Message to be transmitted + call getarg(2,arg) + read(arg,*) f0 !Frequency (only used for single-signal) + call getarg(3,arg) + read(arg,*) xdt !Time offset from nominal (s) + call getarg(4,arg) + read(arg,*) fspread !Watterson frequency spread (Hz) + call getarg(5,arg) + read(arg,*) delay !Watterson delay (ms) + call getarg(6,arg) + read(arg,*) width !Filter transition width (Hz) + call getarg(7,arg) + read(arg,*) nfiles !Number of files + call getarg(8,arg) + read(arg,*) snrdb !SNR_2500 + + nsig=1 + if(f0.lt.100.0) then + nsig=f0 + f0=1500 + endif + + bcontest=nfiles.lt.0 + nfiles=abs(nfiles) + twopi=8.0*atan(1.0) + fs=12000.0 !Sample rate (Hz) + dt=1.0/fs !Sample interval (s) + tt=NSPS*dt !Duration of symbols (s) + baud=1.0/tt !Keying rate (baud) + bw=8*baud !Occupied bandwidth (Hz) + txt=NZ*dt !Transmission length (s) + bandwidth_ratio=2500.0/(fs/2.0) + sig=sqrt(2*bandwidth_ratio) * 10.0**(0.05*snrdb) + if(snrdb.gt.90.0) sig=1.0 + txt=NN*NSPS/12000.0 + +! Source-encode, then get itone() + call pack77(msg37,i3,n3,c77) + call unpack77(c77,msgsent37) + call genft8_174_91(msg37,mygrid6,bcontest,i3,n3,msgsent37,msgbits,itone) + write(*,1000) f0,xdt,txt,snrdb,bw,msgsent37 +1000 format('f0:',f9.3,' DT:',f6.2,' TxT:',f6.1,' SNR:',f6.1, & + ' BW:',f4.1,2x,a37) + + write(*,'(a23,a37,i1,a1,i1)') 'New Style FT8 Message: ',msgsent37,i3,'.',n3 + write(*,'(a14)') 'Message bits: ' + write(*,'(77i1)') msgbits + write(*,'(a17)') 'Channel symbols: ' + write(*,'(79i1)') itone + + call sgran() + + msg0=msg + do ifile=1,nfiles + k=nint((xdt+0.5)/dt) + ia=k + phi=0.0 + do j=1,NN !Generate complex waveform + dphi=twopi*(f0*dt+itone(j)/real(NSPS)) + do i=1,NSPS + if(k.ge.0 .and. k.lt.NMAX) c0(k)=cmplx(cos(phi),sin(phi)) + k=k+1 + phi=mod(phi+dphi,twopi) + enddo + enddo + if(fspread.ne.0.0 .or. delay.ne.0.0) call watterson(c0,NMAX,fs,delay,fspread) + c=c+sig*c0 + enddo + ib=k + wave=real(c) + peak=maxval(abs(wave(ia:ib))) + rms=sqrt(dot_product(wave(ia:ib),wave(ia:ib))/NWAVE) + nslots=1 + if(width.gt.0.0) call filt8(f0,nslots,width,wave) + + if(snrdb.lt.90) then + do i=1,NMAX !Add gaussian noise at specified SNR + xnoise=gran() + wave(i)=wave(i) + xnoise + enddo + endif + + fac=32767.0 + rms=100.0 + if(snrdb.ge.90.0) iwave(1:NMAX)=nint(fac*wave) + if(snrdb.lt.90.0) iwave(1:NMAX)=nint(rms*wave) + + h=default_header(12000,NMAX) + write(fname,1102) ifile +1102 format('000000_',i6.6,'.wav') + open(10,file=fname,status='unknown',access='stream') + write(10) h,iwave !Save to *.wav file + close(10) + write(*,1110) ifile,xdt,f0,snrdb,fname +1110 format(i4,f7.2,f8.2,f7.1,2x,a17) + +999 end program ft8sim2