Merge branch 'feat-50bit' into develop

This commit is contained in:
Steven Franke 2020-04-03 10:34:02 -05:00
commit f78f63a53d
5 changed files with 694 additions and 653 deletions

View File

@ -596,6 +596,13 @@ set (wsjt_FSRCS
lib/wqencode.f90
lib/wspr_downsample.f90
lib/zplot9.f90
lib/fsk4hf/wsprcpmsim.f90
lib/fsk4hf/wsprcpm_wav.f90
lib/fsk4hf/wsprcpmd.f90
lib/fsk4hf/bpdecode204.f90
lib/fsk4hf/osd204.f90
lib/fsk4hf/genwsprcpm.f90
lib/fsk4hf/encode204.f90
)
# temporary workaround for a gfortran v7.3 ICE on Fedora 27 64-bit
@ -1331,6 +1338,12 @@ target_link_libraries (ft4sim_mult wsjt_fort wsjt_cxx)
add_executable (record_time_signal Audio/tools/record_time_signal.cpp)
target_link_libraries (record_time_signal wsjt_cxx wsjt_qtmm wsjt_qt)
add_executable (wsprcpmsim lib/fsk4hf/wsprcpmsim.f90 wsjtx.rc)
target_link_libraries (wsprcpmsim wsjt_fort wsjt_cxx)
add_executable (wsprcpmd lib/fsk4hf/wsprcpmd.f90 wsjtx.rc)
target_link_libraries (wsprcpmd wsjt_fort wsjt_cxx)
endif(WSJT_BUILD_UTILS)
# build the main application

View File

@ -1,70 +1,70 @@
subroutine genwsprcpm(msg,msgsent,itone)
! Encode a WSPRCPM message, producing array itone().
!
use crc
include 'wsprcpm_params.f90'
!
use crc
include 'wsprcpm_params.f90'
character*22 msg,msgsent
character*64 cbits
character*32 sbits
integer iuniqueword0
integer*1,target :: idat(9)
integer*1 msgbits(68),codeword(ND)
logical first
integer icw(ND)
integer id(NS+ND)
integer jd(NS+ND)
integer ipreamble(16) !Freq estimation preamble
integer isync(200) !Long sync vector
integer itone(NN)
data ipreamble/1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1/
data first/.true./
data iuniqueword0/z'30C9E8AD'/
save first,isync,ipreamble
character*22 msg,msgsent
character*64 cbits
character*32 sbits
integer iuniqueword0
integer*1,target :: idat(9)
integer*1 msgbits(68),codeword(ND)
logical first
integer icw(ND)
integer id(NS+ND)
integer jd(NS+ND)
integer ipreamble(16) !Freq estimation preamble
integer isync(200) !Long sync vector
integer itone(NN)
data ipreamble/1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1/
data first/.true./
data iuniqueword0/z'30C9E8AD'/
save first,isync,ipreamble
if(first) then
write(sbits,'(b32.32)') iuniqueword0
read(sbits,'(32i1)') isync(1:32)
read(sbits,'(32i1)') isync(33:64)
read(sbits,'(32i1)') isync(65:96)
read(sbits,'(32i1)') isync(97:128)
read(sbits,'(32i1)') isync(129:160)
read(sbits,'(32i1)') isync(161:192)
read(sbits,'(8i1)') isync(193:200)
first=.false.
endif
if(first) then
write(sbits,'(b32.32)') iuniqueword0
read(sbits,'(32i1)') isync(1:32)
read(sbits,'(32i1)') isync(33:64)
read(sbits,'(32i1)') isync(65:96)
read(sbits,'(32i1)') isync(97:128)
read(sbits,'(32i1)') isync(129:160)
read(sbits,'(32i1)') isync(161:192)
read(sbits,'(8i1)') isync(193:200)
first=.false.
endif
idat=0
call wqencode(msg,ntype0,idat) !Source encoding
id7=idat(7)
if(id7.lt.0) id7=id7+256
id7=id7/64
write(*,*) 'idat ',idat
icrc=crc14(c_loc(idat),9)
write(*,*) 'icrc: ',icrc
write(*,'(a6,b16.16)') 'icrc: ',icrc
call wqdecode(idat,msgsent,itype)
print*,msgsent,itype
write(cbits,1004) idat(1:6),id7,iand(icrc,z'3FFF')
idat=0
call wqencode(msg,ntype0,idat) !Source encoding
id7=idat(7)
if(id7.lt.0) id7=id7+256
id7=id7/64
write(*,*) 'idat ',idat
icrc=crc14(c_loc(idat),9)
write(*,*) 'icrc: ',icrc
write(*,'(a6,b16.16)') 'icrc: ',icrc
call wqdecode(idat,msgsent,itype)
print*,msgsent,itype
write(cbits,1004) idat(1:6),id7,iand(icrc,z'3FFF')
1004 format(6b8.8,b2.2,b14.14)
msgbits=0
read(cbits,1006) msgbits(1:64)
msgbits=0
read(cbits,1006) msgbits(1:64)
1006 format(64i1)
write(*,'(50i1,1x,14i1,1x,4i1)') msgbits
write(*,'(50i1,1x,14i1,1x,4i1)') msgbits
call encode204(msgbits,codeword) !Encode the test message
call encode204(msgbits,codeword) !Encode the test message
! Message structure:
! d100 p16 d100
itone(1:100)=isync(1:100)+2*codeword(1:100)
itone(101:116)=ipreamble+1
itone(117:216)=isync(101:200)+2*codeword(101:200)
itone=2*itone-3
do i=1,216
write(*,*) i,itone(i)
enddo
! d100 p16 d100
itone(1:100)=isync(1:100)+2*codeword(1:100)
itone(101:116)=ipreamble+1
itone(117:216)=isync(101:200)+2*codeword(101:200)
itone=2*itone-3
do i=1,216
write(*,*) i,itone(i)
enddo
return
return
end subroutine genwsprcpm

View File

@ -1,44 +1,44 @@
subroutine wsprcpm_wav(baud,xdt,h,f0,itone,snrdb,iwave)
! Generate iwave() from itone().
include 'wsprcpm_params.f90'
parameter (NMAX=120*12000)
integer itone(NN)
integer*2 iwave(NMAX)
real*8 twopi,dt,dphi0,dphi1,dphi,phi
real dat(NMAX)
twopi=8.d0*atan(1.d0)
dt=1.d0/12000.d0
include 'wsprcpm_params.f90'
parameter (NMAX=120*12000)
integer itone(NN)
integer*2 iwave(NMAX)
real*8 twopi,dt,dphi0,dphi1,dphi,phi
real dat(NMAX)
dat=0.
if(snrdb.lt.90) then
do i=1,NMAX
dat(i)=gran() !Generate gaussian noise
enddo
bandwidth_ratio=2500.0/6000.0
sig=sqrt(2*bandwidth_ratio)*10.0**(0.05*snrdb)
else
sig=1.0
endif
twopi=8.d0*atan(1.d0)
dt=1.d0/12000.d0
phi=0.d0
k=nint(xdt/dt)
do j=1,NN
dphi=twopi*(f0+itone(j)*(h/2.0d0)*baud)*dt
do i=1,NSPS0
k=k+1
phi=phi+dphi
if(phi.gt.twopi) phi=phi-twopi
xphi=phi
if(k.gt.0 .and. k.le.NMAX) dat(k)=dat(k) + sig*sin(xphi)
enddo
enddo
fac=32767.0
rms=100.0
if(snrdb.ge.90.0) iwave=nint(fac*dat)
if(snrdb.lt.90.0) iwave=nint(rms*dat)
dat=0.
if(snrdb.lt.90) then
do i=1,NMAX
dat(i)=gran() !Generate gaussian noise
enddo
bandwidth_ratio=2500.0/6000.0
sig=sqrt(2*bandwidth_ratio)*10.0**(0.05*snrdb)
else
sig=1.0
endif
return
phi=0.d0
k=nint(xdt/dt)
do j=1,NN
dphi=twopi*(f0+itone(j)*(h/2.0d0)*baud)*dt
do i=1,NSPS0
k=k+1
phi=phi+dphi
if(phi.gt.twopi) phi=phi-twopi
xphi=phi
if(k.gt.0 .and. k.le.NMAX) dat(k)=dat(k) + sig*sin(xphi)
enddo
enddo
fac=32767.0
rms=100.0
if(snrdb.ge.90.0) iwave=nint(fac*dat)
if(snrdb.lt.90.0) iwave=nint(rms*dat)
return
end subroutine wsprcpm_wav

File diff suppressed because it is too large Load Diff

View File

@ -1,109 +1,106 @@
program wsprcpmsim
! Generate simulated data for a 2-minute "WSPR-LF" mode. Output is saved
! Generate simulated data for a 2-minute "WSPR-LF" mode. Output is saved
! to a *.c2 or *.wav file.
use wavhdr
include 'wsprcpm_params.f90' !Set various constants
parameter (NMAX=120*12000)
type(hdr) hwav !Header for .wav file
character arg*12,fname*16
character msg*22,msgsent*22
complex c0(0:NMAX/NDOWN-1)
complex c(0:NMAX/NDOWN-1)
real*8 fMHz
integer itone(NN)
integer*2 iwave(NMAX) !Generated full-length waveform
use wavhdr
include 'wsprcpm_params.f90' !Set various constants
parameter (NMAX=120*12000)
type(hdr) hwav !Header for .wav file
character arg*12,fname*16
character msg*22,msgsent*22
complex c0(0:NMAX/NDOWN-1)
complex c(0:NMAX/NDOWN-1)
real*8 fMHz
integer itone(NN)
integer*2 iwave(NMAX) !Generated full-length waveform
! Get command-line argument(s)
nargs=iargc()
if(nargs.ne.8) then
print*,'Usage: wsprmsksim "message" f0 DT fsp del nwav nfiles snr'
print*,'Example: wsprmsksim "K1ABC FN42 30" 50 0.0 0.1 1.0 1 10 -33'
go to 999
endif
call getarg(1,msg) !Message to be transmitted
call getarg(2,arg)
read(arg,*) f0 !Freq relative to WSPR-band center (Hz)
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,*) nwav !1 for *.wav file, 0 for *.c2 file
call getarg(7,arg)
read(arg,*) nfiles !Number of files
call getarg(8,arg)
read(arg,*) snrdb !SNR_2500
nargs=iargc()
if(nargs.ne.9) then
print*,'Usage: wsprcpmsim "message" f0 DT fsp del nwav nfiles snr h'
print*,'Example: wsprcpmsim "K1ABC FN42 30" 50 0.0 0.1 1.0 1 10 -33 1.0'
go to 999
endif
call getarg(1,msg) !Message to be transmitted
call getarg(2,arg)
read(arg,*) f0 !Freq relative to WSPR-band center (Hz)
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,*) nwav !1 for *.wav file, 0 for *.c2 file
call getarg(7,arg)
read(arg,*) nfiles !Number of files
call getarg(8,arg)
read(arg,*) snrdb !SNR_2500
call getarg(9,arg)
read(arg,*) h !h
twopi=8.0*atan(1.0)
fs=12000.0/NDOWN !
dt=1.0/fs !Sample interval (s)
tt=NSPS*dt !Duration of "itone" symbols (s)
baud=1.0/tt !Keying rate for "itone" symbols (baud)
txt=NZ*dt !Transmission length (s)
bandwidth_ratio=2500.0/(fs/2.0)
sig=sqrt(bandwidth_ratio) * 10.0**(0.05*snrdb)
if(snrdb.gt.90.0) sig=1.0
txt=NN*NSPS0/12000.0
twopi=8.0*atan(1.0)
fs=12000.0/NDOWN !
dt=1.0/fs !Sample interval (s)
tt=NSPS*dt !Duration of "itone" symbols (s)
baud=1.0/tt !Keying rate for "itone" symbols (baud)
txt=NZ*dt !Transmission length (s)
bandwidth_ratio=2500.0/(fs/2.0)
sig=sqrt(bandwidth_ratio) * 10.0**(0.05*snrdb)
if(snrdb.gt.90.0) sig=1.0
txt=NN*NSPS0/12000.0
call genwsprcpm(msg,msgsent,itone) !Encode the message, get itone
write(*,1000) f0,xdt,txt,snrdb,fspread,delay,nfiles,msgsent
call genwsprcpm(msg,msgsent,itone) !Encode the message, get itone
write(*,1000) f0,xdt,txt,snrdb,fspread,delay,nfiles,msgsent
1000 format('f0:',f9.3,' DT:',f6.2,' txt:',f6.1,' SNR:',f6.1, &
' fspread:',f6.1,' delay:',f6.1,' nfiles:',i3,2x,a22)
' fspread:',f6.1,' delay:',f6.1,' nfiles:',i3,2x,a22)
c0=0.
k=-1 + nint(xdt/dt)
do j=1,NN
dp=twopi*(f0+itone(j)*(h/2.0)*baud)*dt
do i=1,NSPS
k=k+1
phi=mod(phi+dp,twopi)
if(k.ge.0 .and. k.lt.NMAX/NDOWN) c0(k)=cmplx(cos(phi),sin(phi))
enddo
enddo
call sgran()
do ifile=1,nfiles
c=c0
if(nwav.eq.0) then
if( fspread .ne. 0.0 .or. delay .ne. 0.0 ) then
ntot=NMAX/NDOWN
nsig=NN*NSPS
call watterson(c,ntot,nsig,fs,delay,fspread)
endif
c=c*sig
if(snrdb.lt.90) then
do i=0,NMAX/NDOWN-1 !Add gaussian noise at specified SNR
xnoise=gran()
ynoise=gran()
c(i)=c(i) + cmplx(xnoise,ynoise)
enddo
endif
write(fname,1100) ifile
1100 format('000000_',i4.4,'.c2')
open(10,file=fname,status='unknown',access='stream')
fMHz=10.1387d0
nmin=2
write(10) fname,nmin,fMHz,c !Save to *.c2 file
close(10)
else
call wsprcpm_wav(baud,xdt,h,f0,itone,snrdb,iwave)
hwav=default_header(12000,NMAX)
write(fname,1102) ifile
1102 format('000000_',i4.4,'.wav')
open(10,file=fname,status='unknown',access='stream')
write(10) hwav,iwave !Save to *.wav file
close(10)
endif
write(*,1110) ifile,xdt,f0,snrdb,fname
1110 format(i4,f7.2,f8.2,f7.1,2x,a16)
enddo
h=1.00
c0=0.
k=-1 + nint(xdt/dt)
do j=1,NN
dp=twopi*(f0+itone(j)*(h/2.0)*baud)*dt
do i=1,NSPS
k=k+1
phi=mod(phi+dp,twopi)
if(k.ge.0 .and. k.lt.NMAX/NDOWN) c0(k)=cmplx(cos(phi),sin(phi))
enddo
enddo
call sgran()
do ifile=1,nfiles
c=c0
if(nwav.eq.0) then
if( fspread .ne. 0.0 .or. delay .ne. 0.0 ) then
call watterson(c,NMAX/NDOWN,fs,delay,fspread)
endif
!do i=0,NMAX/NDOWN-1
!write(23,*) i,real(c(i)),imag(c(i))
!enddo
c=c*sig
if(snrdb.lt.90) then
do i=0,NMAX/NDOWN-1 !Add gaussian noise at specified SNR
xnoise=gran()
ynoise=gran()
c(i)=c(i) + cmplx(xnoise,ynoise)
enddo
endif
write(fname,1100) ifile
1100 format('000000_',i4.4,'.c2')
open(10,file=fname,status='unknown',access='stream')
fMHz=10.1387d0
nmin=2
write(10) fname,nmin,fMHz,c !Save to *.c2 file
close(10)
!do i=0,NMAX/NDOWN-1
!write(57,*) i,real(c(i)),imag(c(i))
!enddo
else
call wsprcpm_wav(baud,xdt,h,f0,itone,snrdb,iwave)
hwav=default_header(12000,NMAX)
write(fname,1102) ifile
1102 format('000000_',i4.4,'.wav')
open(10,file=fname,status='unknown',access='stream')
write(10) hwav,iwave !Save to *.wav file
close(10)
endif
write(*,1110) ifile,xdt,f0,snrdb,fname
1110 format(i4,f7.2,f8.2,f7.1,2x,a16)
enddo
999 end program wsprcpmsim