2016-06-01 19:46:36 -04:00
|
|
|
program msk144sim
|
2016-05-26 17:19:09 -04:00
|
|
|
|
|
|
|
use wavhdr
|
2021-09-14 14:09:54 -04:00
|
|
|
parameter (NMAX=30*12000)
|
2016-05-26 17:19:09 -04:00
|
|
|
real pings(0:NMAX-1)
|
2016-06-22 17:18:08 -04:00
|
|
|
real waveform(0:NMAX-1)
|
2018-07-07 11:35:59 -04:00
|
|
|
character arg*8,msg*37,msgsent*37,fname*40
|
2016-05-26 17:19:09 -04:00
|
|
|
real wave(0:NMAX-1) !Simulated received waveform
|
2016-06-10 10:18:10 -04:00
|
|
|
real*8 twopi,freq,phi,dphi0,dphi1,dphi
|
2016-05-26 17:19:09 -04:00
|
|
|
type(hdr) h !Header for .wav file
|
|
|
|
integer*2 iwave(0:NMAX-1)
|
|
|
|
integer itone(144) !Message bits
|
|
|
|
|
|
|
|
nargs=iargc()
|
2021-09-14 14:09:54 -04:00
|
|
|
if(nargs.ne.6) then
|
|
|
|
print*,'Usage: msk144sim message TRp freq width snr nfiles'
|
|
|
|
print*,'Example: msk144sim "K1ABC W9XYZ EN37" 15 1500 0.12 2 1'
|
|
|
|
print*,' msk144sim "K1ABC W9XYZ EN37" 30 1500 2.5 15 1'
|
2016-05-26 17:19:09 -04:00
|
|
|
go to 999
|
|
|
|
endif
|
|
|
|
call getarg(1,msg)
|
|
|
|
call getarg(2,arg)
|
2021-09-14 14:09:54 -04:00
|
|
|
read(arg,*) nTRperiod
|
2016-05-26 17:19:09 -04:00
|
|
|
call getarg(3,arg)
|
2021-09-14 14:09:54 -04:00
|
|
|
read(arg,*) freq
|
2016-05-26 17:19:09 -04:00
|
|
|
call getarg(4,arg)
|
2021-09-14 14:09:54 -04:00
|
|
|
read(arg,*) width
|
2018-11-23 16:10:44 -05:00
|
|
|
call getarg(5,arg)
|
2021-09-14 14:09:54 -04:00
|
|
|
read(arg,*) snrdb
|
|
|
|
call getarg(6,arg)
|
2017-06-07 14:28:38 -04:00
|
|
|
read(arg,*) nfiles
|
2016-05-28 16:53:35 -04:00
|
|
|
|
|
|
|
!sig is the peak amplitude of the ping.
|
2016-05-26 17:19:09 -04:00
|
|
|
sig=sqrt(2.0)*10.0**(0.05*snrdb)
|
2021-09-14 14:09:54 -04:00
|
|
|
npts=nTRperiod*12000
|
|
|
|
h=default_header(12000,npts)
|
2016-12-17 16:18:47 -05:00
|
|
|
i1=len(trim(msg))-5
|
2016-05-26 17:19:09 -04:00
|
|
|
ichk=0
|
2018-07-07 13:57:16 -04:00
|
|
|
itype=1
|
2020-05-03 11:10:21 -04:00
|
|
|
call fmtmsg(msg,iz)
|
2018-07-11 14:42:48 -04:00
|
|
|
call genmsk_128_90(msg,ichk,msgsent,itone,itype)
|
2018-09-20 10:49:42 -04:00
|
|
|
write(*,*) 'Requested message: ',msg
|
|
|
|
write(*,*) 'Message sent : ',msgsent
|
|
|
|
write(*,*) 'Tones: '
|
2018-10-20 11:16:17 -04:00
|
|
|
if(itone(41).ge.0) then
|
|
|
|
write(*,'(1x,72i1)') itone(1:72)
|
|
|
|
write(*,'(1x,72i1)') itone(73:144)
|
|
|
|
else
|
|
|
|
write(*,'(1x,40i1)') itone(1:40)
|
|
|
|
endif
|
2018-09-20 11:10:29 -04:00
|
|
|
|
2016-05-27 16:46:48 -04:00
|
|
|
twopi=8.d0*atan(1.d0)
|
2016-07-05 17:06:04 -04:00
|
|
|
nsym=144
|
2018-11-23 16:10:44 -05:00
|
|
|
nsps=6
|
2016-07-29 17:09:56 -04:00
|
|
|
if( itone(41) .lt. 0 ) nsym=40
|
2018-11-23 16:10:44 -05:00
|
|
|
baud=2000.d0
|
2017-06-06 14:57:17 -04:00
|
|
|
dphi0=twopi*(freq-0.25d0*baud)/12000.d0
|
|
|
|
dphi1=twopi*(freq+0.25d0*baud)/12000.d0
|
2016-05-27 16:46:48 -04:00
|
|
|
phi=0.0
|
2017-06-06 14:57:17 -04:00
|
|
|
k=0
|
2021-09-14 14:09:54 -04:00
|
|
|
nreps=npts/(nsym*nsps)
|
2018-09-20 10:49:42 -04:00
|
|
|
|
2016-06-22 17:18:08 -04:00
|
|
|
do jrep=1,nreps
|
2016-07-05 17:06:04 -04:00
|
|
|
do i=1,nsym
|
2016-06-22 17:18:08 -04:00
|
|
|
if( itone(i) .eq. 0 ) then
|
|
|
|
dphi=dphi0
|
|
|
|
else
|
|
|
|
dphi=dphi1
|
|
|
|
endif
|
2017-06-06 14:57:17 -04:00
|
|
|
do j=1,nsps
|
|
|
|
waveform(k)=cos(phi)
|
|
|
|
k=k+1
|
2016-06-22 17:18:08 -04:00
|
|
|
phi=mod(phi+dphi,twopi)
|
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
|
2016-05-26 17:19:09 -04:00
|
|
|
if(itype.lt.1 .or. itype.gt.7) then
|
|
|
|
print*,'Illegal message'
|
|
|
|
go to 999
|
|
|
|
endif
|
|
|
|
|
2021-09-14 14:09:54 -04:00
|
|
|
call makepings(pings,nTRperiod,npts,width,sig)
|
2016-05-28 16:53:35 -04:00
|
|
|
|
2016-06-21 22:29:37 -04:00
|
|
|
! call sgran()
|
2016-05-26 17:19:09 -04:00
|
|
|
do ifile=1,nfiles !Loop over requested number of files
|
|
|
|
write(fname,1002) ifile !Output filename
|
2016-06-05 13:58:04 -04:00
|
|
|
1002 format('000000_',i6.6)
|
|
|
|
open(10,file=fname(1:13)//'.wav',access='stream',status='unknown')
|
2016-05-26 17:19:09 -04:00
|
|
|
|
2016-06-22 17:18:08 -04:00
|
|
|
wave=0.0
|
|
|
|
iwave=0
|
2016-05-26 17:19:09 -04:00
|
|
|
fac=sqrt(6000.0/2500.0)
|
2021-09-14 14:09:54 -04:00
|
|
|
do i=0,npts-1
|
2016-05-26 17:19:09 -04:00
|
|
|
xx=gran()
|
2018-11-23 16:10:44 -05:00
|
|
|
wave(i)=pings(i)*waveform(i) + fac*xx
|
2016-05-26 17:19:09 -04:00
|
|
|
iwave(i)=30.0*wave(i)
|
|
|
|
enddo
|
|
|
|
|
2021-09-14 14:09:54 -04:00
|
|
|
write(10) h,iwave(0:npts-1) !Save the .wav file
|
|
|
|
endfile(10)
|
2016-05-26 17:19:09 -04:00
|
|
|
close(10)
|
|
|
|
|
|
|
|
enddo
|
|
|
|
|
2016-06-01 19:46:36 -04:00
|
|
|
999 end program msk144sim
|