Allow q65sim toi generate multiple signals.

This commit is contained in:
Joe Taylor 2023-02-15 15:46:06 -05:00
parent 37cd5b3ede
commit 6877a87fe4
2 changed files with 75 additions and 44 deletions

View File

@ -8,6 +8,7 @@ program q65sim
type(hdr) h !Header for .wav file type(hdr) h !Header for .wav file
integer*2 iwave(NMAX) !Generated waveform integer*2 iwave(NMAX) !Generated waveform
integer itone(85) !Channel symbols (values 0-65) integer itone(85) !Channel symbols (values 0-65)
integer ntone(85,10) !Channel symbols for up to 10 messages
integer y(63) !Codeword integer y(63) !Codeword
integer istart !averaging compatible start seconds integer istart !averaging compatible start seconds
integer imins !minutes for 15s period timestamp integer imins !minutes for 15s period timestamp
@ -18,18 +19,19 @@ program q65sim
complex cspread(0:NMAX-1) !Complex amplitude for Rayleigh fading complex cspread(0:NMAX-1) !Complex amplitude for Rayleigh fading
complex z complex z
real*8 f0,dt,twopi,phi,dphi,baud,fsample,freq real*8 f0,dt,twopi,phi,dphi,baud,fsample,freq
character msg*37,fname*17,csubmode*1,arg*12 character fname*17,csubmode*1,arg*12,c2*2
character msgsent*37 character*37 msg,msgsent,imsg(10)
nargs=iargc() nargs=iargc()
if(nargs.ne.10) then if(nargs.ne.11) then
print*,'Usage: q65sim "msg" A-E freq fDop DT f1 Stp TRp Nfile SNR' print*,'Usage: q65sim "msg" A-E freq fDop DT f1 Stp TRp Nsig Nfile SNR'
print*,'Example: q65sim "K1ABC W9XYZ EN37" A 1500 0.0 0.0 0.0 1 60 1 -26' print*,'Example: q65sim "K1ABC W9XYZ EN37" A 1500 0.0 0.0 0.0 1 60 1 1 -26'
print*,'Example: q65sim "ST" A 1500 0.0 0.0 0.0 1 60 1 -26' print*,'Example: q65sim "ST" A 1500 0.0 0.0 0.0 1 60 1 -26'
print*,' fDop = Doppler spread' print*,' fDop = Doppler spread'
print*,' f1 = Drift or Doppler rate (Hz/min)' print*,' f1 = Drift or Doppler rate (Hz/min)'
print*,' Stp = Step size (Hz)' print*,' Stp = Step size (Hz)'
print*,' Stp = 0 implies no Doppler tracking' print*,' Stp = 0 implies no Doppler tracking'
print*,' Nsig = number of generated signals, 1 - 10'
print*,' Creates filenames which increment to permit averaging in first period' print*,' Creates filenames which increment to permit averaging in first period'
print*,' If msg = ST program produces a single tone at freq' print*,' If msg = ST program produces a single tone at freq'
go to 999 go to 999
@ -50,8 +52,10 @@ program q65sim
call getarg(8,arg) call getarg(8,arg)
read(arg,*) ntrperiod read(arg,*) ntrperiod
call getarg(9,arg) call getarg(9,arg)
read(arg,*) nfiles read(arg,*) nsig
call getarg(10,arg) call getarg(10,arg)
read(arg,*) nfiles
call getarg(11,arg)
read(arg,*) snrdb read(arg,*) snrdb
if(ntrperiod.eq.15) then if(ntrperiod.eq.15) then
@ -79,9 +83,25 @@ program q65sim
nsym=85 !Number of channel symbols nsym=85 !Number of channel symbols
mode65=2**(ichar(csubmode) - ichar('A')) mode65=2**(ichar(csubmode) - ichar('A'))
ichk=0
call genq65(msg,ichk,msgsent,itone,i3,n3)
imsg(1)=msg
if(nsig.ge.2) then
i0=index(msg,' ')
i0=i0 + index(msg(i0+1:),' ')-2
do i=1,nsig
c2=char(ichar('A')+i-1)//char(ichar('A')+i-1)
imsg(i)=msg(1:i0-1)//c2//msg(i0+2:)
enddo
endif
ichk=0
do i=1,nsig
msg=imsg(i)
call genq65(msg,ichk,msgsent,itone,i3,n3)
ntone(:,i)=itone
enddo
if(nsig.eq.1) then
j=0 j=0
do i=1,85 do i=1,85
if(itone(i).gt.0) then if(itone(i).gt.0) then
@ -95,6 +115,7 @@ program q65sim
1002 format(/'Codeword:'/(20i3)) 1002 format(/'Codeword:'/(20i3))
write(*,1003) itone write(*,1003) itone
1003 format(/'Channel symbols:'/(20i3)) 1003 format(/'Channel symbols:'/(20i3))
endif
baud=12000.d0/nsps !Keying rate (6.67 baud fot 15-s sequences) baud=12000.d0/nsps !Keying rate (6.67 baud fot 15-s sequences)
h=default_header(12000,npts) h=default_header(12000,npts)
@ -116,18 +137,27 @@ program q65sim
open(10,file=trim(fname),access='stream',status='unknown') open(10,file=trim(fname),access='stream',status='unknown')
xnoise=0. xnoise=0.
cdat=0.
if(snrdb.lt.90) then if(snrdb.lt.90) then
do i=1,npts do i=1,npts
xnoise(i)=gran() !Generate gaussian noise xnoise(i)=gran() !Generate gaussian noise
enddo enddo
endif endif
cdat=0.
bandwidth_ratio=2500.0/6000.0 bandwidth_ratio=2500.0/6000.0
sig=sqrt(2*bandwidth_ratio)*10.0**(0.05*snrdb) sig=sqrt(2*bandwidth_ratio)*10.0**(0.05*snrdb)
if(snrdb.gt.90.0) sig=1.0 if(snrdb.gt.90.0) sig=1.0
write(*,1020) ifile,ntrperiod,f0,csubmode,snrdb,fspread,xdt,f1,nstp,trim(msgsent) write(*,1020) ifile,ntrperiod,f0,csubmode,snrdb,fspread,xdt,f1,nstp,trim(msgsent)
1020 format(i4,i6,f7.1,2x,a1,2x,f5.1,1x,f6.2,2f6.1,i4,2x,a) 1020 format(i4,i6,f7.1,2x,a1,2x,f5.1,1x,f6.2,2f6.1,i4,2x,a)
n=65.0*baud*mode65/100.0 + 0.9999
nfstep=100*n
nf1=1500 - nfstep*nsig/2
do n=1,nsig
if(nsig.ge.2) then
f0=nf1 + (n-1)*nfstep
itone=ntone(:,n)
endif
phi=0.d0 phi=0.d0
dphi=0.d0 dphi=0.d0
k=(xdt+0.5)*12000 !Start audio at t=xdt+0.5 s (TR=15 and 30 s) k=(xdt+0.5)*12000 !Start audio at t=xdt+0.5 s (TR=15 and 30 s)
@ -154,6 +184,7 @@ program q65sim
k=k+1 k=k+1
if(k.ge.1) cdat(k)=cdat(k) + sig*z if(k.ge.1) cdat(k)=cdat(k) + sig*z
enddo enddo
enddo
if(fspread.ne.0) then !Apply specified Doppler spread if(fspread.ne.0) then !Apply specified Doppler spread
df=12000.0/nfft df=12000.0/nfft

View File

@ -35,7 +35,7 @@ program sumsim
fac=1.0/nargs fac=1.0/nargs
iwave(1:npts)=nint(fac*wave(1:npts)) iwave(1:npts)=nint(fac*wave(1:npts))
open(12,file='000000_0000.wav',access='stream',status='unknown') open(12,file='000001_0000.wav',access='stream',status='unknown')
write(12) h,iwave(1:npts) write(12) h,iwave(1:npts)
close(12) close(12)