mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-22 04:11:16 -05:00
Some test routines.
git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@7712 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
parent
f993094acb
commit
7047150453
@ -387,11 +387,13 @@ set (wsjt_FSRCS
|
||||
lib/fqso_first.f90
|
||||
lib/freqcal.f90
|
||||
lib/fsk4hf/fsk4hf.f90
|
||||
lib/fsk4hf/ft8sim.f90
|
||||
lib/gen4.f90
|
||||
lib/gen65.f90
|
||||
lib/gen9.f90
|
||||
lib/geniscat.f90
|
||||
lib/fsk4hf/genfsk4hf.f90
|
||||
lib/fsk4hf/genft8.f90
|
||||
lib/genmsk144.f90
|
||||
lib/genmsk40.f90
|
||||
lib/fsk4hf/genmskhf.f90
|
||||
@ -439,6 +441,7 @@ set (wsjt_FSRCS
|
||||
lib/msk144d2.f90
|
||||
lib/msk40decodeframe.f90
|
||||
lib/msk144decodeframe.f90
|
||||
lib/msk144sd.f90
|
||||
lib/msk40spd.f90
|
||||
lib/msk144spd.f90
|
||||
lib/msk40sync.f90
|
||||
@ -1146,6 +1149,9 @@ target_link_libraries (ldpcsim168 wsjt_fort wsjt_cxx)
|
||||
add_executable (fsk4hf lib/fsk4hf/fsk4hf.f90 wsjtx.rc)
|
||||
target_link_libraries (fsk4hf wsjt_fort wsjt_cxx)
|
||||
|
||||
add_executable (ft8sim lib/fsk4hf/ft8sim.f90 wsjtx.rc)
|
||||
target_link_libraries (ft8sim wsjt_fort wsjt_cxx)
|
||||
|
||||
add_executable (wspr5d lib/fsk4hf/wspr5d.f90 wsjtx.rc)
|
||||
target_link_libraries (wspr5d wsjt_fort wsjt_cxx)
|
||||
|
||||
@ -1164,6 +1170,9 @@ target_link_libraries (wspr_fsk8_sim wsjt_fort wsjt_cxx)
|
||||
add_executable (mskhfsim lib/fsk4hf/mskhfsim.f90 wsjtx.rc)
|
||||
target_link_libraries (mskhfsim wsjt_fort wsjt_cxx)
|
||||
|
||||
add_executable (msk144sd lib/msk144sd.f90 wsjtx.rc)
|
||||
target_link_libraries (msk144sd wsjt_fort wsjt_cxx)
|
||||
|
||||
add_executable (msk144sim lib/msk144sim.f90 wsjtx.rc)
|
||||
target_link_libraries (msk144sim wsjt_fort wsjt_cxx)
|
||||
|
||||
|
10
lib/fsk4hf/ft8_params.f90
Normal file
10
lib/fsk4hf/ft8_params.f90
Normal file
@ -0,0 +1,10 @@
|
||||
! LDPC (168,84) code
|
||||
parameter (KK=84) !Information bits (72 + CRC12)
|
||||
parameter (ND=56) !Data symbols
|
||||
parameter (NS=21) !Sync symbols (3 @ Costas 7x7)
|
||||
parameter (NN=NS+ND) !Total symbols (77)
|
||||
parameter (NSPS=2048) !Samples per symbol at 12000 S/s
|
||||
parameter (N7=7*NSPS) !Samples in Costas 7x7 array (14,336)
|
||||
parameter (NZ=NSPS*NN) !Samples in full 15 s waveform (157,696)
|
||||
parameter (NMAX=15*12000) !Samples in iwave (180,000)
|
||||
parameter (NFFT1=1*NSPS, NH1=NFFT1/2) !Length of FFTs for symbol spectra
|
104
lib/fsk4hf/ft8sim.f90
Normal file
104
lib/fsk4hf/ft8sim.f90
Normal file
@ -0,0 +1,104 @@
|
||||
program ft8sim
|
||||
|
||||
! Generate simulated data for a 15-second HF/6m mode using 8-FSK.
|
||||
! Output is saved to a *.wav file.
|
||||
|
||||
use wavhdr
|
||||
include 'ft8_params.f90' !Set various constants
|
||||
type(hdr) h !Header for .wav file
|
||||
character arg*12,fname*16
|
||||
character msg*22,msgsent*22
|
||||
complex c0(0:NZ-1)
|
||||
complex c(0:NZ-1)
|
||||
integer itone(NN)
|
||||
integer*2 iwave(NMAX) !Generated full-length waveform
|
||||
|
||||
! Get command-line argument(s)
|
||||
nargs=iargc()
|
||||
if(nargs.ne.7) then
|
||||
print*,'Usage: ft8sim "message" f0 DT fdop del nfiles snr'
|
||||
print*,'Example: ft8sim "K1ABC W9XYZ EN37" 1500 0.0 0.1 1.0 10 -18'
|
||||
go to 999
|
||||
endif
|
||||
call getarg(1,msg) !Message to be transmitted
|
||||
call getarg(2,arg)
|
||||
read(arg,*) f0 !Freq of tone 0 (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,*) nfiles !Number of files
|
||||
call getarg(7,arg)
|
||||
read(arg,*) snrdb !SNR_2500
|
||||
|
||||
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(bandwidth_ratio) * 10.0**(0.05*snrdb)
|
||||
if(snrdb.gt.90.0) sig=1.0
|
||||
txt=NN*NSPS/12000.0
|
||||
|
||||
call genft8(msg,msgsent,itone) !Source-encode, then get itone()
|
||||
write(*,1000) f0,xdt,txt,snrdb,bw,msgsent
|
||||
1000 format('f0:',f9.3,' DT:',f6.2,' TxT:',f6.1,' SNR:',f6.1, &
|
||||
' BW:',f4.1,2x,a22)
|
||||
|
||||
phi=0.0
|
||||
c0=0.
|
||||
k=-1 + nint(xdt/dt)
|
||||
do j=1,NN !Generate 8-FSK waveform from itone
|
||||
dphi=twopi*(f0+itone(j)*baud)*dt
|
||||
if(k.eq.0) phi=-dphi
|
||||
do i=1,NSPS
|
||||
k=k+1
|
||||
phi=phi+dphi
|
||||
if(phi.gt.twopi) phi=phi-twopi
|
||||
xphi=phi
|
||||
if(k.ge.0 .and. k.lt.NZ) c0(k)=cmplx(cos(xphi),sin(xphi))
|
||||
enddo
|
||||
enddo
|
||||
|
||||
call sgran()
|
||||
do ifile=1,nfiles
|
||||
c=c0
|
||||
if( fspread .ne. 0.0 .or. delay .ne. 0.0 ) then
|
||||
call watterson(c,NZ,fs,delay,fspread)
|
||||
endif
|
||||
c=c*sig
|
||||
if(snrdb.lt.90) then
|
||||
do i=0,NZ-1 !Add gaussian noise at specified SNR
|
||||
xnoise=gran()
|
||||
ynoise=gran()
|
||||
c(i)=c(i) + cmplx(xnoise,ynoise)
|
||||
enddo
|
||||
endif
|
||||
|
||||
fac=32767.0
|
||||
rms=100.0
|
||||
if(snrdb.ge.90.0) iwave(1:NZ)=nint(fac*real(c))
|
||||
if(snrdb.lt.90.0) iwave(1:NZ)=nint(rms*real(c))
|
||||
iwave(NZ+1:)=0
|
||||
|
||||
h=default_header(12000,NMAX)
|
||||
write(fname,1102) ifile
|
||||
1102 format('000000_',i4.4,'.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,a16)
|
||||
do i=0,NZ-1
|
||||
write(13,3001) i,i/12000.0,c(i),iwave(i+1)
|
||||
3001 format(i8,f12.6,2f12.3,i8)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
999 end program ft8sim
|
42
lib/fsk4hf/genft8.f90
Normal file
42
lib/fsk4hf/genft8.f90
Normal file
@ -0,0 +1,42 @@
|
||||
subroutine genft8(msg,msgsent,itone)
|
||||
|
||||
! Encode an FT8 message, producing array itone().
|
||||
|
||||
use crc
|
||||
use packjt
|
||||
use hashing
|
||||
include 'ft8_params.f90'
|
||||
|
||||
character*22 msg,msgsent
|
||||
character*84 cbits
|
||||
integer*4 i4Msg6BitWords(12) !72-bit message as 6-bit words
|
||||
integer*1 msgbits(KK),codeword(3*ND)
|
||||
integer itone(NN)
|
||||
integer icos7(0:6)
|
||||
data icos7/2,5,6,0,4,1,3/ !Costas 7x7 tone pattern
|
||||
|
||||
call packmsg(msg,i4Msg6BitWords,itype) !Pack into 12 6-bit bytes
|
||||
call unpackmsg(i4Msg6BitWords,msgsent) !Unpack to get msgsent
|
||||
icrc=0 !### temporary ###
|
||||
|
||||
write(cbits,1000) i4Msg6BitWords,icrc
|
||||
1000 format(12b6.6,b12.12)
|
||||
read(cbits,1002) msgbits
|
||||
1002 format(84i1)
|
||||
|
||||
call encode168(msgbits,codeword) !Encode the test message
|
||||
|
||||
! Message structure: S7 D28 S7 D28 S7
|
||||
itone(1:7)=icos7
|
||||
itone(35+1:35+7)=icos7
|
||||
itone(NN-6:NN)=icos7
|
||||
k=7
|
||||
do j=1,ND
|
||||
i=3*j -2
|
||||
k=k+1
|
||||
if(j.eq.29) k=k+7
|
||||
itone(k)=codeword(i)*4 + codeword(i+1)*2 + codeword(i+2)
|
||||
enddo
|
||||
|
||||
return
|
||||
end subroutine genft8
|
Loading…
Reference in New Issue
Block a user