mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-12-23 19:25:37 -05:00
Files that will eventually comprise a wspr simulator, in Fortran.
git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@8397 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
parent
e8e2d57cc2
commit
128b8a70d2
23
lib/fsk4hf/wspr_params.f90
Normal file
23
lib/fsk4hf/wspr_params.f90
Normal file
@ -0,0 +1,23 @@
|
||||
parameter (NN=162)
|
||||
parameter (NSPS0=8192) !Samples per symbol at 12000 S/s
|
||||
parameter (NDOWN=32)
|
||||
parameter (NSPS=NSPS0/NDOWN)
|
||||
parameter (NZ=NSPS*NN) !Samples in waveform at 12000 S/s
|
||||
parameter (NZ0=NSPS0*NN) !Samples in waveform at 375 S/s
|
||||
parameter (NMAX=120*12000) !Samples in waveform at 375 S/s
|
||||
|
||||
! Define the sync vector:
|
||||
integer*1 sync(162)
|
||||
data sync/ &
|
||||
1,1,0,0,0,0,0,0,1,0,0,0,1,1,1,0,0,0,1,0, &
|
||||
0,1,0,1,1,1,1,0,0,0,0,0,0,0,1,0,0,1,0,1, &
|
||||
0,0,0,0,0,0,1,0,1,1,0,0,1,1,0,1,0,0,0,1, &
|
||||
1,0,1,0,0,0,0,1,1,0,1,0,1,0,1,0,1,0,0,1, &
|
||||
0,0,1,0,1,1,0,0,0,1,1,0,1,0,1,0,0,0,1,0, &
|
||||
0,0,0,0,1,0,0,1,0,0,1,1,1,0,1,1,0,0,1,1, &
|
||||
0,1,0,0,0,1,1,1,0,0,0,0,0,1,0,1,0,0,1,1, &
|
||||
0,0,0,0,0,0,0,1,1,0,1,0,1,1,0,0,0,1,1,0, &
|
||||
0,0/
|
||||
|
||||
|
||||
|
42
lib/fsk4hf/wspr_wav.f90
Normal file
42
lib/fsk4hf/wspr_wav.f90
Normal file
@ -0,0 +1,42 @@
|
||||
subroutine wspr_wav(baud,xdt,h,f0,itone,snrdb,iwave)
|
||||
|
||||
! Generate iwave() from itone().
|
||||
|
||||
include 'wspr_params.f90'
|
||||
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
|
||||
baud=375.0/256.0
|
||||
|
||||
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
|
||||
|
||||
phi=0.d0
|
||||
k=nint(xdt/dt)
|
||||
do j=1,NN
|
||||
dphi=twopi*(f0+h*(itone(j)-1.5)*baud)*dt
|
||||
do i=1,NSPS0
|
||||
k=k+1
|
||||
phi=mod(phi+dphi,twopi)
|
||||
if(k.gt.0 .and. k.le.NMAX) dat(k)=dat(k) + sig*sin(phi)
|
||||
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 wspr_wav
|
113
lib/fsk4hf/wsprsimf.f90
Normal file
113
lib/fsk4hf/wsprsimf.f90
Normal file
@ -0,0 +1,113 @@
|
||||
!-------------------------------------------------------------------------------
|
||||
!
|
||||
! This file is part of the WSPR application, Weak Signal Propagation Reporter
|
||||
!
|
||||
!-------------------------------------------------------------------------------
|
||||
|
||||
program wsprsim
|
||||
|
||||
use wavhdr
|
||||
include 'wspr_params.f90'
|
||||
type(hdr) hwav
|
||||
character arg*12,fname14*14,fname15*15
|
||||
character*22 msg,msgsent
|
||||
complex c0(0:NMAX/NDOWN-1)
|
||||
complex c(0:NMAX/NDOWN-1)
|
||||
integer itone(NN)
|
||||
integer*2 iwave(NMAX)
|
||||
real*8 fMHz
|
||||
|
||||
! 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
|
||||
|
||||
twopi=8.0*atan(1.0)
|
||||
fs=12000.0/NDOWN
|
||||
dt=1.0/fs
|
||||
tt=NSPS*dt
|
||||
baud=12000.0/8192.0
|
||||
|
||||
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 genwspr(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)
|
||||
write(*,*) "Channel symbols: "
|
||||
write(*,'(162i2)') itone
|
||||
|
||||
h=1.0
|
||||
phi=0.0
|
||||
c0=0.
|
||||
k=-1 + nint(xdt/dt)
|
||||
do j=1,NN
|
||||
dphi=-twopi*(f0+h*(itone(j)-1.5)*baud)*dt
|
||||
do i=1,NSPS
|
||||
k=k+1
|
||||
phi=mod(phi+dphi,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
|
||||
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(fname14,1100) ifile
|
||||
1100 format('000000_',i4.4,'.c2')
|
||||
open(10,file=fname14,status='unknown',access='stream')
|
||||
fMHz=10.1387d0
|
||||
nmin=2
|
||||
write(10) fname14,nmin,fMHz,c !Save to *.c2 file
|
||||
close(10)
|
||||
write(*,1108) ifile,xdt,f0,snrdb,fname14
|
||||
1108 format(i4,f7.2,f8.2,f7.1,2x,a14)
|
||||
else
|
||||
freq=1500.0+f0
|
||||
call wspr_wav(baud,xdt,h,freq,itone,snrdb,iwave)
|
||||
hwav=default_header(12000,NMAX)
|
||||
write(fname15,1102) ifile
|
||||
1102 format('000000_',i4.4,'.wav')
|
||||
open(10,file=fname15,status='unknown',access='stream')
|
||||
write(10) hwav,iwave !Save to *.wav file
|
||||
close(10)
|
||||
write(*,1110) ifile,xdt,f0,snrdb,fname15
|
||||
1110 format(i4,f7.2,f8.2,f7.1,2x,a15)
|
||||
endif
|
||||
enddo
|
||||
|
||||
999 end program wsprsim
|
Loading…
Reference in New Issue
Block a user