mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-22 20:28:42 -05:00
Add optional Rayleigh fading to jt65sim.
git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6132 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
parent
dc672c4bb1
commit
70a5fbd34c
@ -58,7 +58,7 @@ jt65: $(OBJS7) libjt9.a libsfrsd.a
|
||||
|
||||
OBJS2 = jt65sim.o wavhdr.o
|
||||
jt65sim: $(OBJS2) libjt9.a
|
||||
$(FC) -o jt65sim $(OBJS2) -L. -L/opt/local/lib -ljt9
|
||||
$(FC) -o jt65sim $(OBJS2) -L. -L/opt/local/lib -ljt9 -lfftw3f
|
||||
$(CP) jt65sim $(EXE_DIR)
|
||||
|
||||
init_rs.o: init_rs.c
|
||||
|
116
lib/jt65sim.f90
116
lib/jt65sim.f90
@ -4,16 +4,21 @@ program jt65sim
|
||||
|
||||
use wavhdr
|
||||
use packjt
|
||||
parameter (NTMAX=54)
|
||||
parameter (NMAX=NTMAX*12000)
|
||||
type(hdr) h
|
||||
parameter (NMAX=54*12000) ! = 648,000
|
||||
parameter (NFFT=10*65536,NH=NFFT/2)
|
||||
type(hdr) h !Header for .wav file
|
||||
integer*2 iwave(NMAX) !Generated waveform
|
||||
integer*4 itone(126) !Channel symbols (values 0-65)
|
||||
integer dgen(12),sent(63)
|
||||
real*4 dat(NMAX)
|
||||
integer dgen(12) !Twelve 6-bit data symbols
|
||||
integer sent(63) !RS(63,12) codeword
|
||||
real*4 xnoise(NMAX) !Generated random noise
|
||||
real*4 dat(NMAX) !Generated real data
|
||||
complex cdat(NMAX) !Generated complex waveform
|
||||
complex cspread(0:NFFT-1) !Complex amplitude for Rayleigh fading
|
||||
complex z
|
||||
real*8 f0,dt,twopi,phi,dphi,baud,fsample,freq,sps
|
||||
character msg*22,arg*8,fname*11,csubmode*1
|
||||
integer nprc(126)
|
||||
integer nprc(126) !Sync pattern
|
||||
data nprc/1,0,0,1,1,0,0,0,1,1,1,1,1,1,0,1,0,1,0,0, &
|
||||
0,1,0,1,1,0,0,1,0,0,0,1,1,1,0,0,1,1,1,1, &
|
||||
0,1,1,0,1,1,1,1,0,0,0,1,1,0,1,0,1,0,1,1, &
|
||||
@ -24,8 +29,8 @@ program jt65sim
|
||||
|
||||
nargs=iargc()
|
||||
if(nargs.ne.5) then
|
||||
print*,'Usage: jt65sim mode nRay nsigs SNR nfiles'
|
||||
print*,'Example: jt65sim B 0 10 -24 1'
|
||||
print*,'Usage: jt65sim mode nsigs fspread SNR nfiles'
|
||||
print*,'Example: jt65sim B 10 0.0 -24 1'
|
||||
print*,'Enter SNR = 0 to generate a range of SNRs.'
|
||||
go to 999
|
||||
endif
|
||||
@ -36,40 +41,39 @@ program jt65sim
|
||||
if(csubmode.eq.'B') mode65=2
|
||||
if(csubmode.eq.'C') mode65=4
|
||||
call getarg(2,arg)
|
||||
read(arg,*) nRay !1 ==> Rayleigh fading
|
||||
call getarg(3,arg)
|
||||
read(arg,*) nsigs !Number of signals in each file
|
||||
call getarg(3,arg)
|
||||
read(arg,*) fspread !Doppler spread (Hz)
|
||||
call getarg(4,arg)
|
||||
read(arg,*) snrdb !S/N in dB (2500 hz reference BW)
|
||||
call getarg(5,arg)
|
||||
read(arg,*) nfiles !Number of files
|
||||
|
||||
rmsdb=25.
|
||||
rms=10.0**(0.05*rmsdb)
|
||||
rms=100.
|
||||
fsample=12000.d0 !Sample rate (Hz)
|
||||
dt=1.d0/fsample !Sample interval (s)
|
||||
twopi=8.d0*atan(1.d0)
|
||||
npts=54*12000
|
||||
baud=11025.d0/4096.d0
|
||||
npts=54*12000 !Total samples in .wav file
|
||||
baud=11025.d0/4096.d0 !Keying rate
|
||||
sps=12000.d0/baud !Samples per symbol, at fsample=12000 Hz
|
||||
nsym=126
|
||||
nsym=126 !Number of channel symbols
|
||||
h=default_header(12000,npts)
|
||||
dfsig=2000.0/nsigs !Freq spacing between sigs in file (Hz)
|
||||
|
||||
do ifile=1,nfiles !Loop over all files
|
||||
do ifile=1,nfiles !Loop over requested number of files
|
||||
write(fname,1002) ifile !Output filename
|
||||
1002 format('000000_',i4.4)
|
||||
open(10,file=fname//'.wav',access='stream',status='unknown')
|
||||
|
||||
xnoise=0.
|
||||
cdat=0.
|
||||
if(snrdb.lt.90) then
|
||||
do i=1,npts
|
||||
dat(i)=gran() !Generate AWGN
|
||||
xnoise(i)=gran() !Generate gaussian noise
|
||||
enddo
|
||||
else
|
||||
dat(1:npts)=0.
|
||||
endif
|
||||
|
||||
dfsig=2000.0/nsigs
|
||||
do isig=1,nsigs
|
||||
do isig=1,nsigs !Generate requested number of sigs
|
||||
if(mod(nsigs,2).eq.0) f0=1500.0 + dfsig*(isig-0.5-nsigs/2)
|
||||
if(mod(nsigs,2).eq.1) f0=1500.0 + dfsig*(isig-(nsigs+1)/2)
|
||||
nsnr=nint(snrdb)
|
||||
@ -80,12 +84,12 @@ program jt65sim
|
||||
1010 format('K1ABC W9XYZ ',i3.2)
|
||||
|
||||
call packmsg(msg,dgen,itype) !Pack message into 12 six-bit bytes
|
||||
call rs_encode(dgen,sent) !RS encode
|
||||
call rs_encode(dgen,sent) !Encode using RS(63,12)
|
||||
call interleave63(sent,1) !Interleave channel symbols
|
||||
call graycode65(sent,63,1) !Apply Gray code
|
||||
|
||||
k=0
|
||||
do j=1,nsym
|
||||
do j=1,nsym !Insert sync and data into itone()
|
||||
if(nprc(j).eq.0) then
|
||||
k=k+1
|
||||
itone(j)=sent(k)+2
|
||||
@ -95,7 +99,6 @@ program jt65sim
|
||||
enddo
|
||||
|
||||
sig=10.0**(0.05*nsnr)
|
||||
! sig=1.122*sig
|
||||
if(nsnr.gt.90.0) sig=1.0
|
||||
write(*,1020) ifile,isig,f0,csubmode,nsnr,sig,msg
|
||||
1020 format(i4,i4,f10.3,1x,a1,i5,f8.4,2x,a22)
|
||||
@ -104,7 +107,7 @@ program jt65sim
|
||||
dphi=0.d0
|
||||
k=12000 !Start audio at t = 1.0 s
|
||||
isym0=-99
|
||||
do i=1,npts
|
||||
do i=1,npts !Add this signal into cdat()
|
||||
isym=nint(i/sps)+1
|
||||
if(isym.gt.nsym) exit
|
||||
if(isym.ne.isym0) then
|
||||
@ -115,15 +118,74 @@ program jt65sim
|
||||
phi=phi + dphi
|
||||
if(phi.gt.twopi) phi=phi-twopi
|
||||
xphi=phi
|
||||
z=cmplx(cos(xphi),sin(xphi))
|
||||
k=k+1
|
||||
dat(k)=dat(k) + sig*sin(xphi)
|
||||
cdat(k)=cdat(k) + sig*z
|
||||
enddo
|
||||
enddo
|
||||
|
||||
if(fspread.ne.0) then !Apply specified Doppler spread
|
||||
df=12000.0/nfft
|
||||
twopi=8*atan(1.0)
|
||||
cspread(0)=1.0
|
||||
cspread(NH)=0.
|
||||
|
||||
do i=1,NH
|
||||
f=i*df
|
||||
x=-f/fspread
|
||||
z=0.
|
||||
a=0.
|
||||
if(x.lt.50.0) then
|
||||
a=sqrt(exp(-x*x))
|
||||
call random_number(r1)
|
||||
phi1=twopi*r1
|
||||
z=a*cmplx(cos(phi1),sin(phi1))
|
||||
endif
|
||||
cspread(i)=z
|
||||
z=0.
|
||||
if(x.lt.50.0) then
|
||||
call random_number(r2)
|
||||
phi2=twopi*r2
|
||||
z=a*cmplx(cos(phi2),sin(phi2))
|
||||
endif
|
||||
cspread(NFFT-i)=z
|
||||
enddo
|
||||
|
||||
do i=0,NFFT-1
|
||||
f=i*df
|
||||
if(i.gt.NH) f=(i-nfft)*df
|
||||
s=real(cspread(i))**2 + aimag(cspread(i))**2
|
||||
! write(13,3000) i,f,s,cspread(i)
|
||||
!3000 format(i5,f10.3,3f12.6)
|
||||
enddo
|
||||
! s=real(cspread(0))**2 + aimag(cspread(0))**2
|
||||
! write(13,3000) 1024,0.0,s,cspread(0)
|
||||
|
||||
call four2a(cspread,NFFT,1,1,1) !Transform to time domain
|
||||
|
||||
sum=0.
|
||||
do i=0,NFFT-1
|
||||
p=real(cspread(i))**2 + aimag(cspread(i))**2
|
||||
sum=sum+p
|
||||
enddo
|
||||
avep=sum/NFFT
|
||||
fac=sqrt(1.0/avep)
|
||||
cspread=fac*cspread !Normalize to constant avg power
|
||||
cdat=cspread(1:npts)*cdat !Apply Rayleigh fading
|
||||
|
||||
! do i=0,NFFT-1
|
||||
! p=real(cspread(i))**2 + aimag(cspread(i))**2
|
||||
! write(14,3010) i,p,cspread(i)
|
||||
!3010 format(i8,3f12.6)
|
||||
! enddo
|
||||
|
||||
endif
|
||||
|
||||
dat=aimag(cdat) + xnoise !Add the generated noise
|
||||
fac=32767.0/nsigs
|
||||
if(snrdb.ge.90.0) iwave(1:npts)=nint(fac*dat(1:npts))
|
||||
if(snrdb.lt.90.0) iwave(1:npts)=nint(rms*dat(1:npts))
|
||||
write(10) h,iwave(1:npts)
|
||||
write(10) h,iwave(1:npts) !Save the .wav file
|
||||
close(10)
|
||||
enddo
|
||||
|
||||
|
@ -1,9 +1,10 @@
|
||||
CC = gcc
|
||||
#CC = clang
|
||||
#CC = clang-3.5
|
||||
FC = gfortran
|
||||
|
||||
CFLAGS= -I/usr/include -Wall -Wno-missing-braces -O3 -ffast-math
|
||||
LDFLAGS = -L/usr/lib
|
||||
FFLAGS = -O2 -Wall -Wno-conversion
|
||||
LIBS = -lfftw3 -lm
|
||||
|
||||
# Default rules
|
||||
|
Loading…
Reference in New Issue
Block a user