diff options
| author | hibby <d@vehibberd.com> | 2026-10-06 21:24:40 +0100 |
|---|---|---|
| committer | hibby <d@vehibberd.com> | 2026-10-06 21:24:40 +0100 |
| commit | c25cbdf6fb6d946175f4335fab77bfea601b56db (patch) | |
| tree | 6f7a94b7b81f999e434f61b73d47e337dfd26bf2 /lib/EchoCallSim.f90 | |
| parent | 71f5689252c9f13e70e1c24856904475b2307809 (diff) | |
| parent | 0685fcada9f95fe90f70b387cd7d757da8209624 (diff) | |
Merge tag 'debian/3.2.0_rc1+dfsg-2' into debian/trixie-backportsdebian/trixie-backports
tagging wsjtx 3.2.0~rc1+dfsg-2
Diffstat (limited to 'lib/EchoCallSim.f90')
| -rw-r--r-- | lib/EchoCallSim.f90 | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/lib/EchoCallSim.f90 b/lib/EchoCallSim.f90 index 224e68c7..e9b55b5a 100644 --- a/lib/EchoCallSim.f90 +++ b/lib/EchoCallSim.f90 @@ -4,13 +4,13 @@ program EchoCallSim use wavhdr parameter (NSPS=4096,NZ=3*12000) - parameter (NMAX=6*NSPS) !Samples in .wav file, 2.2*12000 + parameter (NMAX=6*NSPS) !Samples occupied by the signal type(hdr) h !Header for .wav file integer*2 iwave(NZ) !Generated waveform integer itone(6) !Channel symbols, values 0-37 real*4 xnoise(NMAX) !Generated random noise real*4 dat(NMAX) !Generated real data - complex cdat(NMAX) !Generated complex waveform + complex cdat(NZ) !Generated full-length complex waveform complex z real*8 f0,dt,twopi,phi,dphi,fsample,freq character callsign*6,fname*17,arg*8 @@ -46,7 +46,7 @@ program EchoCallSim twopi=8.d0*atan(1.d0) rms=100. fsample=12000.d0 !Sample rate (Hz) - npts=NMAX !Total samples in .wav file + npts=NMAX !Samples occupied by the signal nfft=npts nh=nfft/2 dt=1.d0/fsample !Sample interval (s) @@ -61,8 +61,11 @@ program EchoCallSim endif bandwidth_ratio=2500.0/6000.0 - sig=sqrt(2*bandwidth_ratio)*10.0**(0.05*snrdb) - if(snrdb.gt.90.0) sig=1.0 + if(snrdb.ge.90.0) then + sig=1.0 + else + sig=sqrt(2*bandwidth_ratio)*10.0**(0.05*snrdb) + endif phi=0.d0 dphi=0.d0 @@ -80,12 +83,22 @@ program EchoCallSim enddo enddo + cdat(npts+1:)=0. if(fspread.gt.0.0) call fspread_lorentz(cdat,fspread) - dat=aimag(cdat) + xnoise !Add generated AWGN noise - fac=32767.0 - 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)) + dat=aimag(cdat(1:npts)) + xnoise !Add generated AWGN noise + datpk=maxval(abs(dat)) + fac=rms + if(datpk.gt.0.0) then + if(snrdb.ge.90.0) then + fac=32766.0/datpk + elseif(fac*datpk.gt.32766.0) then + fac=32766.0/datpk + write(*,'(a,i0,a)') 'Warning: normalized file ',ifile, & + ' to prevent 16-bit PCM overflow; absolute level was not preserved.' + endif + endif + iwave(1:npts)=nint(fac*dat(1:npts)) iwave(npts+1:)=0 nDop=nint(fdop) @@ -101,7 +114,7 @@ program EchoCallSim isec=mod(n,60) write(fname,1102) ihr,imin,isec 1102 format('000000_',3i2.2,'.wav') - open(10,file=trim(fname),access='stream',status='unknown') + open(10,file=trim(fname),access='stream',status='replace') write(10) h,iwave !Save the .wav file close(10) @@ -111,5 +124,3 @@ program EchoCallSim enddo 999 end program EchoCallSim - - |
