mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-14 16:11:50 -05:00
Enhance jt65sim to allow 11025 Hz rate, selectable base frequency and o/p gain offset.
Needs a review. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@8388 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
parent
b76e5248df
commit
d48fb58ffa
@ -5,7 +5,7 @@ program jt65sim
|
|||||||
use wavhdr
|
use wavhdr
|
||||||
use packjt
|
use packjt
|
||||||
use options
|
use options
|
||||||
parameter (NMAX=54*12000) ! = 648,000
|
parameter (NMAX=54*12000) ! = 648,000 @12kHz
|
||||||
parameter (NFFT=10*65536,NH=NFFT/2)
|
parameter (NFFT=10*65536,NH=NFFT/2)
|
||||||
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
|
||||||
@ -21,15 +21,18 @@ program jt65sim
|
|||||||
character msg*22,fname*11,csubmode*1,c,optarg*500,numbuf*32
|
character msg*22,fname*11,csubmode*1,c,optarg*500,numbuf*32
|
||||||
! character call1*5,call2*5
|
! character call1*5,call2*5
|
||||||
logical :: display_help=.false.,seed_prngs=.true.
|
logical :: display_help=.false.,seed_prngs=.true.
|
||||||
type (option) :: long_options(9) = [ &
|
type (option) :: long_options(12) = [ &
|
||||||
option ('help',.false.,'h','Display this help message',''), &
|
option ('help',.false.,'h','Display this help message',''), &
|
||||||
option ('sub-mode',.true.,'m','sub mode, default MODE=A','MODE'), &
|
option ('sub-mode',.true.,'m','sub mode, default MODE=A','MODE'), &
|
||||||
option ('num-sigs',.true.,'n','number of signals per file, default SIGNALS=10','SIGNALS'), &
|
option ('num-sigs',.true.,'n','number of signals per file, default SIGNALS=10','SIGNALS'), &
|
||||||
|
option ('f0',.true.,'F','base frequency offset, default F0=1500.0','F0'), &
|
||||||
option ('doppler-spread',.true.,'d','Doppler spread, default SPREAD=0.0','SPREAD'), &
|
option ('doppler-spread',.true.,'d','Doppler spread, default SPREAD=0.0','SPREAD'), &
|
||||||
option ('time-offset',.true.,'t','Time delta, default SECONDS=0.0','SECONDS'), &
|
option ('time-offset',.true.,'t','Time delta, default SECONDS=0.0','SECONDS'), &
|
||||||
option ('num-files',.true.,'f','Number of files to generate, default FILES=1','FILES'), &
|
option ('num-files',.true.,'f','Number of files to generate, default FILES=1','FILES'), &
|
||||||
option ('no-prng-seed',.false.,'p','Do not seed PRNGs (use for reproducible tests)',''), &
|
option ('no-prng-seed',.false.,'p','Do not seed PRNGs (use for reproducible tests)',''), &
|
||||||
option ('strength',.true.,'s','S/N in dB (2500Hz reference b/w), default SNR=0','SNR'), &
|
option ('strength',.true.,'s','S/N in dB (2500Hz reference b/w), default SNR=0','SNR'), &
|
||||||
|
option ('11025',.false.,'S','Generate at 11025Hz sample rate, default 12000Hz',''), &
|
||||||
|
option ('gain-offset',.true.,'G','Gain offset in dB, default GAIN=0dB','GAIN'), &
|
||||||
option ('message',.true.,'M','Message text','Message') ]
|
option ('message',.true.,'M','Message text','Message') ]
|
||||||
|
|
||||||
integer nprc(126) !Sync pattern
|
integer nprc(126) !Sync pattern
|
||||||
@ -45,14 +48,17 @@ program jt65sim
|
|||||||
csubmode='A'
|
csubmode='A'
|
||||||
mode65=1
|
mode65=1
|
||||||
nsigs=10
|
nsigs=10
|
||||||
|
bf0=1500.
|
||||||
fspread=0.
|
fspread=0.
|
||||||
xdt=0.
|
xdt=0.
|
||||||
snrdb=0.
|
snrdb=0.
|
||||||
nfiles=1
|
nfiles=1
|
||||||
|
nsample_rate=12000
|
||||||
|
gain_offset=0.
|
||||||
msg="K1ABC W9XYZ EN37"
|
msg="K1ABC W9XYZ EN37"
|
||||||
|
|
||||||
do
|
do
|
||||||
call getopt('hm:n:d:t:f:ps:M:',long_options,c,optarg,narglen,nstat,noffset,nremain,.true.)
|
call getopt('hm:n:F:d:t:f:ps:SG:M:',long_options,c,optarg,narglen,nstat,noffset,nremain,.true.)
|
||||||
if( nstat .ne. 0 ) then
|
if( nstat .ne. 0 ) then
|
||||||
exit
|
exit
|
||||||
end if
|
end if
|
||||||
@ -66,11 +72,13 @@ program jt65sim
|
|||||||
if(csubmode.eq.'C') mode65=4
|
if(csubmode.eq.'C') mode65=4
|
||||||
case ('n')
|
case ('n')
|
||||||
read (optarg(:narglen), *,err=10) nsigs
|
read (optarg(:narglen), *,err=10) nsigs
|
||||||
|
case ('F')
|
||||||
|
read (optarg(:narglen), *,err=10) bf0
|
||||||
case ('d')
|
case ('d')
|
||||||
read (optarg(:narglen), *,err=10) fspread
|
read (optarg(:narglen), *,err=10) fspread
|
||||||
case ('t')
|
case ('t')
|
||||||
read (optarg(:narglen), *) numbuf
|
read (optarg(:narglen), *) numbuf
|
||||||
if (numbuf(1:1) == '\') then
|
if (numbuf(1:1) == '\') then !'\'
|
||||||
read (numbuf(2:), *,err=10) xdt
|
read (numbuf(2:), *,err=10) xdt
|
||||||
else
|
else
|
||||||
read (numbuf, *,err=10) xdt
|
read (numbuf, *,err=10) xdt
|
||||||
@ -81,11 +89,20 @@ program jt65sim
|
|||||||
seed_prngs=.false.
|
seed_prngs=.false.
|
||||||
case ('s')
|
case ('s')
|
||||||
read (optarg(:narglen), *) numbuf
|
read (optarg(:narglen), *) numbuf
|
||||||
if (numbuf(1:1) == '\') then
|
if (numbuf(1:1) == '\') then !'\'
|
||||||
read (numbuf(2:), *,err=10) snrdb
|
read (numbuf(2:), *,err=10) snrdb
|
||||||
else
|
else
|
||||||
read (numbuf, *,err=10) snrdb
|
read (numbuf, *,err=10) snrdb
|
||||||
end if
|
end if
|
||||||
|
case ('S')
|
||||||
|
nsample_rate=11025
|
||||||
|
case ('G')
|
||||||
|
read (optarg(:narglen), *) numbuf
|
||||||
|
if (numbuf(1:1) == '\') then !'\'
|
||||||
|
read (numbuf(2:), *, err=10) gain_offset
|
||||||
|
else
|
||||||
|
read (numbuf, *, err=10) gain_offset
|
||||||
|
end if
|
||||||
case ('M')
|
case ('M')
|
||||||
read (optarg(:narglen), '(A)',err=10) msg
|
read (optarg(:narglen), '(A)',err=10) msg
|
||||||
write(*,*) msg
|
write(*,*) msg
|
||||||
@ -116,15 +133,16 @@ program jt65sim
|
|||||||
call sgran() ! see C rand generator (used in gran)
|
call sgran() ! see C rand generator (used in gran)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
rms=100.
|
rms=100. * 10. ** (gain_offset / 20.)
|
||||||
fsample=12000.d0 !Sample rate (Hz)
|
|
||||||
|
fsample=nsample_rate !Sample rate (Hz)
|
||||||
dt=1.d0/fsample !Sample interval (s)
|
dt=1.d0/fsample !Sample interval (s)
|
||||||
twopi=8.d0*atan(1.d0)
|
twopi=8.d0*atan(1.d0)
|
||||||
npts=54*12000 !Total samples in .wav file
|
npts=54*nsample_rate !Total samples in .wav file
|
||||||
baud=11025.d0/4096.d0 !Keying rate
|
baud=11025.d0/4096.d0 !Keying rate
|
||||||
sps=12000.d0/baud !Samples per symbol, at fsample=12000 Hz
|
sps=real(nsample_rate)/baud !Samples per symbol, at fsample=NSAMPLE_RATE Hz
|
||||||
nsym=126 !Number of channel symbols
|
nsym=126 !Number of channel symbols
|
||||||
h=default_header(12000,npts)
|
h=default_header(nsample_rate,npts)
|
||||||
dfsig=2000.0/nsigs !Freq spacing between sigs in file (Hz)
|
dfsig=2000.0/nsigs !Freq spacing between sigs in file (Hz)
|
||||||
|
|
||||||
do ifile=1,nfiles !Loop over requested number of files
|
do ifile=1,nfiles !Loop over requested number of files
|
||||||
@ -141,8 +159,8 @@ program jt65sim
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
do isig=1,nsigs !Generate requested number of sigs
|
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.0) f0=bf0 + dfsig*(isig-0.5-nsigs/2)
|
||||||
if(mod(nsigs,2).eq.1) f0=1500.0 + dfsig*(isig-(nsigs+1)/2)
|
if(mod(nsigs,2).eq.1) f0=bf0 + dfsig*(isig-(nsigs+1)/2)
|
||||||
xsnr=snrdb
|
xsnr=snrdb
|
||||||
if(snrdb.eq.0.0) xsnr=-19 - isig
|
if(snrdb.eq.0.0) xsnr=-19 - isig
|
||||||
if(csubmode.eq.'B' .and. snrdb.eq.0.0) xsnr=-21 - isig
|
if(csubmode.eq.'B' .and. snrdb.eq.0.0) xsnr=-21 - isig
|
||||||
@ -180,7 +198,7 @@ program jt65sim
|
|||||||
|
|
||||||
phi=0.d0
|
phi=0.d0
|
||||||
dphi=0.d0
|
dphi=0.d0
|
||||||
k=12000 + xdt*12000 !Start audio at t = xdt + 1.0 s
|
k=nsample_rate + xdt*nsample_rate !Start audio at t = xdt + 1.0 s
|
||||||
isym0=-99
|
isym0=-99
|
||||||
do i=1,npts !Add this signal into cdat()
|
do i=1,npts !Add this signal into cdat()
|
||||||
isym=floor(i/sps)+1
|
isym=floor(i/sps)+1
|
||||||
@ -200,7 +218,7 @@ program jt65sim
|
|||||||
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=real(nsample_rate)/nfft
|
||||||
twopi=8*atan(1.0)
|
twopi=8*atan(1.0)
|
||||||
cspread(0)=1.0
|
cspread(0)=1.0
|
||||||
cspread(NH)=0.
|
cspread(NH)=0.
|
||||||
@ -254,7 +272,7 @@ program jt65sim
|
|||||||
avep=sum/NFFT
|
avep=sum/NFFT
|
||||||
fac=sqrt(1.0/avep)
|
fac=sqrt(1.0/avep)
|
||||||
cspread=fac*cspread !Normalize to constant avg power
|
cspread=fac*cspread !Normalize to constant avg power
|
||||||
cdat=cspread(1:npts)*cdat !Apply Rayleigh fading
|
cdat(1:npts)=cspread(1:npts)*cdat(1:npts) !Apply Rayleigh fading
|
||||||
|
|
||||||
! do i=0,NFFT-1
|
! do i=0,NFFT-1
|
||||||
! p=real(cspread(i))**2 + aimag(cspread(i))**2
|
! p=real(cspread(i))**2 + aimag(cspread(i))**2
|
||||||
|
Loading…
Reference in New Issue
Block a user