diff options
Diffstat (limited to 'lib')
| -rwxr-xr-x | lib/cwsim.f90 | 235 | ||||
| -rwxr-xr-x | lib/decoder.f90 | 61 | ||||
| -rwxr-xr-x | lib/ft8/foxgen.f90 | 27 | ||||
| -rwxr-xr-x | lib/ft8/foxgen_wrap.f90 | 4 | ||||
| -rwxr-xr-x | lib/ft8/ft8sim.f90 | 16 | ||||
| -rwxr-xr-x | lib/ft8/watterson.f90 | 2 | ||||
| -rwxr-xr-x | lib/jt9com.f90 | 3 | ||||
| -rwxr-xr-x | lib/qra/q65/q65sim.f90 | 18 | ||||
| -rwxr-xr-x | lib/superfox/sfox_wave.f90 | 40 | ||||
| -rwxr-xr-x | lib/superfox/sfox_wave_gfsk.f90 | 78 |
10 files changed, 444 insertions, 40 deletions
diff --git a/lib/cwsim.f90 b/lib/cwsim.f90 new file mode 100755 index 00000000..e9034a9f --- /dev/null +++ b/lib/cwsim.f90 @@ -0,0 +1,235 @@ +program cwsim
+
+! Generate simulated audio for a CW message sent repeatedly for 60 seconds
+
+ use wavhdr
+ parameter (NMAX=60*12000)
+ type(hdr) h !Header for the .wav file
+ integer*2 iwave(NMAX) !Generated waveform (no noise)
+ integer icw(500) !Encoded CW message bits
+ complex cspread(0:NMAX-1) !Complex amplitude for Rayleigh fading
+ complex cdat(0:NMAX-1) !Complex waveform
+ real dat(NMAX) !Audio waveform
+ real*4 xnoise(NMAX) !Generated random noise
+ character*60 message
+ character*12 arg
+
+ nargs=iargc()
+ if(nargs.ne.6) then
+ print*,'Usage: cwsim "message" freq bw wpm fspread snr'
+ print*,'Example: cwsim "CQ CQ CQ DE K1JT K1JT K1JT" 700 100 20 100 -10'
+ go to 999
+ endif
+
+ call getarg(1,message)
+ call getarg(2,arg)
+ read(arg,*) ifreq !Audio frequency (Hz)
+ call getarg(3,arg)
+ read(arg,*) bw !Bandwidth (Hz)
+ call getarg(4,arg)
+ read(arg,*) wpm !CW speed, words per minute
+ call getarg(5,arg)
+ read(arg,*) fspread !Doppler spread in Hz
+ call getarg(6,arg)
+ read(arg,*) snrdb !S/N in dB (2500 hz reference BW)
+
+ rms=500.0
+ bandwidth_ratio=2500.0/6000.0
+ sig=sqrt(2*bandwidth_ratio)*10.0**(0.05*snrdb)
+ twopi=8.0*atan(1.0)
+
+ h=default_header(12000,NMAX)
+ open(10,file='000000_0000.wav',access='stream',status='unknown')
+ do i=1,NMAX !Generate gaussian noise
+ xnoise(i)=gran()
+ enddo
+
+ itone=0
+ call morse(message,icw,ncw)
+ call cwsig(icw,ncw,ifreq,wpm,sig,cdat)
+ nfft=NMAX
+
+ if(fspread.ne.0) then !Apply specified Doppler spread
+ nh=nfft/2
+ df=12000.0/nfft
+ cspread(0)=1.0
+ cspread(nh)=0.
+ b=6.0 !Use truncated Lorenzian shape for fspread
+ do i=1,nh
+ f=i*df
+ x=b*f/fspread
+ z=0.
+ a=0.
+ if(x.lt.3.0) then !Cutoff beyond x=3
+ a=sqrt(1.111/(1.0+x*x)-0.1) !Lorentzian amplitude
+ phi1=twopi*rran() !Random phase
+ z=a*cmplx(cos(phi1),sin(phi1))
+ endif
+ cspread(i)=z
+ z=0.
+ if(x.lt.3.0) then !Same thing for negative freqs
+ phi2=twopi*rran()
+ z=a*cmplx(cos(phi2),sin(phi2))
+ endif
+ cspread(nfft-i)=z
+ enddo
+
+ 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*cdat !Apply Rayleigh fading
+ endif
+
+ dat=aimag(cdat) + xnoise
+
+ cdat=dat
+ call four2a(cdat,nfft,1,-1,1) !c2c to frequency domain
+ ia=max(250/df,(ifreq-0.5*bw)/df)
+ ib=ia+bw/df
+ cdat(0:ia)=0.
+ cdat(ib:)=0.
+ call four2a(cdat,nfft,1,+1,1) !c2c to time domain
+ fac=sqrt(5000/bw)/nfft
+ dat=fac*real(cdat)
+
+ iwave=nint(rms*dat)
+ write(10) h,iwave
+ close(10)
+
+999 end program cwsim
+
+subroutine cwsig(icw,ncw,ifreq,wpm,sig,cdat)
+
+ parameter(NMAX=60*12000)
+ integer icw(ncw)
+ complex cdat(NMAX)
+ complex z(NMAX)
+ real x(NMAX)
+ real y(NMAX)
+ real*8 dt,twopi,phi,dphi,fsample,tdit,t
+
+ nspd=nint(1.2*12000.0/wpm)
+ fsample=12000.d0 !Sample rate (Hz)
+ dt=1.d0/fsample !Sample interval (s)
+ tdit=nspd*dt
+ twopi=8.d0*atan(1.d0)
+ dphi=twopi*ifreq*dt
+ phi=0.
+ k=12000 !Start audio at t = 1.0 s
+ t=0.
+ npts=59*12000
+ x=0.
+ do i=1,npts
+ t=t+dt
+ j=nint(t/tdit) + 1
+ j=mod(j-1,ncw) + 1
+ phi=phi + dphi
+ if(phi.gt.twopi) phi=phi-twopi
+ xphi=phi
+ k=k+1
+ x(k)=icw(j)
+ z(k)=cmplx(cos(xphi),sin(xphi))
+ if(t.ge.59.5) exit
+ enddo
+
+ nadd=0.004/dt
+ call smo(x,npts,y,nadd)
+ y=y/nadd
+ cdat=sig*y*z
+
+ return
+end subroutine cwsig
+
+subroutine morse(msg,idat,n)
+
+! Convert ascii message to a Morse code bit string.
+! Dash = 3 dots
+! Space between dots, dashes = 1 dot
+! Space between letters = 3 dots
+! Space between words = 7 dots
+
+ character*(*) msg
+ integer idat(500)
+ integer*1 ic(21,38)
+ data ic/ &
+ 1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,0,20, &
+ 1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,0,0,0,18, &
+ 1,0,1,0,1,1,1,0,1,1,1,0,1,1,1,0,0,0,0,0,16, &
+ 1,0,1,0,1,0,1,1,1,0,1,1,1,0,0,0,0,0,0,0,14, &
+ 1,0,1,0,1,0,1,0,1,1,1,0,0,0,0,0,0,0,0,0,12, &
+ 1,0,1,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,10, &
+ 1,1,1,0,1,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,12, &
+ 1,1,1,0,1,1,1,0,1,0,1,0,1,0,0,0,0,0,0,0,14, &
+ 1,1,1,0,1,1,1,0,1,1,1,0,1,0,1,0,0,0,0,0,16, &
+ 1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,0,0,0,18, &
+ 1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 6, &
+ 1,1,1,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,10, &
+ 1,1,1,0,1,0,1,1,1,0,1,0,0,0,0,0,0,0,0,0,12, &
+ 1,1,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0, 8, &
+ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 2, &
+ 1,0,1,0,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,10, &
+ 1,1,1,0,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,10, &
+ 1,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0, 8, &
+ 1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 4, &
+ 1,0,1,1,1,0,1,1,1,0,1,1,1,0,0,0,0,0,0,0,14, &
+ 1,1,1,0,1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,10, &
+ 1,0,1,1,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,10, &
+ 1,1,1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0, 8, &
+ 1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 6, &
+ 1,1,1,0,1,1,1,0,1,1,1,0,0,0,0,0,0,0,0,0,12, &
+ 1,0,1,1,1,0,1,1,1,0,1,0,0,0,0,0,0,0,0,0,12, &
+ 1,1,1,0,1,1,1,0,1,0,1,1,1,0,0,0,0,0,0,0,14, &
+ 1,0,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0, 8, &
+ 1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 6, &
+ 1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 4, &
+ 1,0,1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0, 8, &
+ 1,0,1,0,1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,10, &
+ 1,0,1,1,1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,10, &
+ 1,1,1,0,1,0,1,0,1,1,1,0,0,0,0,0,0,0,0,0,12, &
+ 1,1,1,0,1,0,1,1,1,0,1,1,1,0,0,0,0,0,0,0,14, &
+ 1,1,1,0,1,1,1,0,1,0,1,0,0,0,0,0,0,0,0,0,12, &
+ 1,1,1,0,1,0,1,0,1,1,1,0,1,0,0,0,0,0,0,0,14, &
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 2/ !Incremental word space
+ save
+
+ msglen=len(trim(msg))
+ idat=0
+ n=6
+ do k=1,msglen
+ jj=ichar(msg(k:k))
+ if(jj.ge.97 .and. jj.le.122) jj=jj-32 !Convert lower to upper case
+ if(jj.ge.48 .and. jj.le.57) j=jj-48 !Numbers
+ if(jj.ge.65 .and. jj.le.90) j=jj-55 !Letters
+ if(jj.eq.47) j=36 !Slash (/)
+ if(jj.eq.32) j=37 !Word space
+ j=j+1
+
+! Insert this character
+ nmax=ic(21,j)
+ if (n + nmax + 4 .gt. size (idat)) exit
+ do i=1,nmax
+ n=n+1
+ idat(n)=ic(i,j)
+ enddo
+
+! Insert character space of 2 dit lengths:
+ n=n+1
+ idat(n)=0
+ n=n+1
+ idat(n)=0
+ enddo
+
+! Insert word space at end of message
+ do j=1,4
+ n=n+1
+ idat(n)=0
+ enddo
+
+ return
+end subroutine morse
diff --git a/lib/decoder.f90 b/lib/decoder.f90 index fc23cd2f..10f73212 100755 --- a/lib/decoder.f90 +++ b/lib/decoder.f90 @@ -67,7 +67,7 @@ subroutine multimode_decoder(ss,id2,params,nfsample) ntr0=params%ntr
rms=sqrt(dot_product(float(id2(1:180000)), &
float(id2(1:180000)))/180000.0)
- if(rms.lt.3.0) go to 800
+ if(rms.lt.0.5) go to 800
!cast C character arrays to Fortran character strings
datetime=transfer(params%datetime, datetime)
@@ -124,8 +124,7 @@ subroutine multimode_decoder(ss,id2,params,nfsample) if(params%nmode.eq.8) then
! We're in FT8 mode
-
- if(ncontest.eq.6) then
+ if(ncontest.eq.6) then !Fox=6, Hound=7
! Fox mode: initialize and open houndcallers.txt
inquire(file=trim(temp_dir)//'/houndcallers.txt',exist=ex)
if(.not.ex) then
@@ -140,27 +139,40 @@ subroutine multimode_decoder(ss,id2,params,nfsample) open(19,file=trim(temp_dir)//'/houndcallers.txt',status='unknown')
endif
- call timer('decft8 ',0)
- newdat=params%newdat
- if(params%emedelay.ne.0.0) then
- id2(1:156000)=id2(24001:180000) ! Drop the first 2 seconds of data
- id2(156001:180000)=0
- endif
- call my_ft8%decode(ft8_decoded,id2,params%nQSOProgress,params%nfqso, &
- params%nftx,newdat,params%nutc,params%nfa,params%nfb, &
- params%nzhsym,params%ndepth,params%emedelay,ncontest, &
- logical(params%nagain),logical(params%lft8apon), &
- logical(params%lapcqonly),params%napwid,mycall,hiscall, &
- params%ndiskdat)
- call timer('decft8 ',1)
- if(nfox.gt.0) then
- n30min=minval(n30fox(1:nfox))
- n30max=maxval(n30fox(1:nfox))
+ if(ncontest.eq.7 .and. params%b_superfox .and. params%b_even_seq) then
+ if(params%nzhsym.lt.50) go to 800
+! Call the superFox decoder
+ open(47,file=trim(temp_dir)//'/fort.47',status='unknown', &
+ access='stream')
+ write(47) params%yymmdd,params%nutc,id2(1:20),id2(1:180000)
+ close(47)
+ call execute_command_line(trim(exe_dir)//'/sfrx '//'"'//trim(temp_dir)//'/fort.47"')
+ else
+ call timer('decft8 ',0)
+ newdat=params%newdat
+ if(params%emedelay.ne.0.0) then
+ id2(1:156000)=id2(24001:180000) ! Drop the first 2 seconds of data
+ id2(156001:180000)=0
+ endif
+ call my_ft8%decode(ft8_decoded,id2,params%nQSOProgress,params%nfqso, &
+ params%nftx,newdat,params%nutc,params%nfa,params%nfb, &
+ params%nzhsym,params%ndepth,params%emedelay,ncontest, &
+ logical(params%nagain),logical(params%lft8apon), &
+ logical(params%lapcqonly),params%napwid,mycall,hiscall, &
+ params%ndiskdat)
+ call timer('decft8 ',1)
endif
j=0
if(ncontest.eq.6) then
! Fox mode: save decoded Hound calls for possible selection by FoxOp
+
+ n=params%nutc
+ n30=(3600*(n/10000) + 60*mod((n/100),100) + mod(n,100))/30
+ if(n30.lt.n30z) nwrap=nwrap+2880 !New UTC day, handle the wrap
+ n30z=n30
+ n30=n30+nwrap
+
rewind 19
if(nfox.eq.0) then
endfile 19
@@ -168,21 +180,22 @@ subroutine multimode_decoder(ss,id2,params,nfsample) else
do i=1,nfox
n=n30fox(i)
- if(n30max-n30fox(i).le.4) then
+ if(n30-n30fox(i).le.4) then
j=j+1
c2fox(j)=c2fox(i)
g2fox(j)=g2fox(i)
nsnrfox(j)=nsnrfox(i)
nfreqfox(j)=nfreqfox(i)
n30fox(j)=n
- m=n30max-n
+ nage=min(99,mod(n30-n+288000,2880))
if(len(trim(g2fox(j))).eq.4) then
call azdist(mygrid,g2fox(j)//' ',0.d0,nAz,nEl,nDmiles, &
nDkm,nHotAz,nHotABetter)
else
nDkm=9999
endif
- write(19,1004) c2fox(j),g2fox(j),nsnrfox(j),nfreqfox(j),nDkm,m
+ write(19,1004) c2fox(j),g2fox(j),nsnrfox(j),nfreqfox(j), &
+ nDkm,nage
1004 format(a12,1x,a4,i5,i6,i7,i3)
endif
enddo
@@ -661,10 +674,10 @@ contains endif
b1=i3-i2.eq.5 .and. isgrid4(g2)
b2=i3-i2.eq.1
- if(b0 .and. (b1.or.b2) .and. nint(freq).ge.1000) then
+ if(b0 .and. (b1.or.b2) .and. (nint(freq).ge.1000 .or. params%b_superfox)) then
n=params%nutc
n30=(3600*(n/10000) + 60*mod((n/100),100) + mod(n,100))/30
- if(n30.lt.n30z) nwrap=nwrap+5760 !New UTC day, handle the wrap
+ if(n30.lt.n30z) nwrap=nwrap+2880 !New UTC day, handle the wrap
n30z=n30
n30=n30+nwrap
if(nfox.lt.MAXFOX) nfox=nfox+1
diff --git a/lib/ft8/foxgen.f90 b/lib/ft8/foxgen.f90 index 8a0c4206..ce74b564 100755 --- a/lib/ft8/foxgen.f90 +++ b/lib/ft8/foxgen.f90 @@ -1,4 +1,4 @@ -subroutine foxgen()
+subroutine foxgen(bSuperFox,fname)
! Called from MainWindow::foxTxSequencer() to generate the Tx waveform in
! FT8 Fox mode. The Tx message can contain up to 5 "slots", each carrying
@@ -15,9 +15,12 @@ subroutine foxgen() ! common block.
parameter (NN=79,ND=58,NSPS=4*1920)
- parameter (NWAVE=(160+2)*134400*4) ! the biggest waveform we generate (FST4-1800 at 48kHz)
+ parameter (NWAVE=(160+2)*134400*4) !the biggest waveform we generate (FST4-1800 at 48kHz)
parameter (NFFT=614400,NH=NFFT/2)
+ logical*1 bSuperFox,bMoreCQs,bSendMsg
+ character*(*) fname
character*40 cmsg
+ character*26 textMsg
character*37 msg,msgsent
integer itone(79)
integer*1 msgbits(77),msgbits2
@@ -25,10 +28,26 @@ subroutine foxgen() real x(NFFT)
real*8 dt,twopi,f0,fstep,dfreq,phi,dphi
complex cx(0:NH)
- common/foxcom/wave(NWAVE),nslots,nfreq,i3bit(5),cmsg(5),mycall(12)
+ common/foxcom/wave(NWAVE),nslots,nfreq,i3bit(5),cmsg(5),mycall(12), &
+ textMsg,bMoreCQs,bSendMsg
common/foxcom2/itone2(NN),msgbits2(77)
equivalence (x,cx),(y,cy)
+ if(bSuperFox) then
+ n=nslots
+ if(bMoreCQs) cmsg(1)(40:40)='1' !Set flag to include a CQ
+ if(bSendMsg) then
+ n=min(nslots+1,3)
+ cmsg(n)=textMsg
+ cmsg(n)(39:39)='1' !Set flag for text message
+ nslots=n
+ endif
+ open(25,file=fname,status='unknown')
+ write(25,'(a40)') cmsg(1:n)
+ close(25)
+ go to 999
+ endif
+
fstep=60.d0
dfreq=6.25d0
dt=1.d0/48000.d0
@@ -66,7 +85,7 @@ subroutine foxgen() peak3=maxval(abs(wave))
wave=wave/peak3
- return
+999 return
end subroutine foxgen
! include 'plotspec.f90'
diff --git a/lib/ft8/foxgen_wrap.f90 b/lib/ft8/foxgen_wrap.f90 index 82510760..170b93fc 100755 --- a/lib/ft8/foxgen_wrap.f90 +++ b/lib/ft8/foxgen_wrap.f90 @@ -2,12 +2,12 @@ subroutine foxgen_wrap(msg40,msgbits,itone) parameter (NN=79,ND=58,KK=77,NSPS=4*1920)
parameter (NWAVE=(160+2)*134400*4) !the biggest waveform we generate (FST4-1800)
-
+ logical*1 bMoreCQs
character*40 msg40,cmsg
character*12 mycall12
integer*1 msgbits(KK),msgbits2
integer itone(NN)
- common/foxcom/wave(NWAVE),nslots,nfreq,i3bit(5),cmsg(5),mycall12
+ common/foxcom/wave(NWAVE),nslots,nfreq,i3bit(5),cmsg(5),mycall12,bMoreCQs
common/foxcom2/itone2(NN),msgbits2(KK)
nslots=1
diff --git a/lib/ft8/ft8sim.f90 b/lib/ft8/ft8sim.f90 index a12b6d60..693542be 100755 --- a/lib/ft8/ft8sim.f90 +++ b/lib/ft8/ft8sim.f90 @@ -101,14 +101,24 @@ program ft8sim_gfsk wave=imag(c)
peak=maxval(abs(wave))
nslots=1
-
+
+ psig=0.
+ pnoise=0.
if(snrdb.lt.90) then
do i=1,NMAX !Add gaussian noise at specified SNR
xnoise=gran()
+ if(i.ge.6001 .and. i.le.157692) then
+ psig=psig + wave(i)*wave(i) !Signal power
+ pnoise=pnoise + xnoise*xnoise !Noise power in signal interval
+ endif
wave(i)=wave(i) + xnoise
enddo
endif
+! Noise power in signal interval and 2500 Hz bandwidth:
+ pnoise=bandwidth_ratio*pnoise
+ snr_2500=db(psig/pnoise) !SNR in 2500 Hz bandwidth
+
gain=100.0
if(snrdb.lt.90.0) then
wave=gain*wave
@@ -125,7 +135,7 @@ program ft8sim_gfsk open(10,file=fname,status='unknown',access='stream')
write(10) h,iwave !Save to *.wav file
close(10)
- write(*,1110) ifile,xdt,f0,snrdb,fname
-1110 format(i4,f7.2,f8.2,f7.1,2x,a17)
+ write(*,1110) ifile,xdt,f0,snrdb,fname,snr_2500
+1110 format(i4,f7.2,f8.2,f7.1,2x,a17,f8.2)
enddo
999 end program ft8sim_gfsk
diff --git a/lib/ft8/watterson.f90 b/lib/ft8/watterson.f90 index 7c3aa35d..6fd0edf8 100755 --- a/lib/ft8/watterson.f90 +++ b/lib/ft8/watterson.f90 @@ -24,7 +24,7 @@ subroutine watterson(c,npts,nsig,fs,delay,fspread) do i=0,npts-1
f=i*df
if(i.gt.npts/2) f=(i-npts)*df
- x=(f/(0.5*fspread))**2
+ x=(f/fspread)**2
a=0.
if(x.le.50.0) then
a=exp(-x)
diff --git a/lib/jt9com.f90 b/lib/jt9com.f90 index 97b3ab27..2e044422 100755 --- a/lib/jt9com.f90 +++ b/lib/jt9com.f90 @@ -47,6 +47,9 @@ character(kind=c_char) :: mygrid(6)
character(kind=c_char) :: hiscall(12)
character(kind=c_char) :: hisgrid(6)
+ logical(c_bool) :: b_even_seq
+ logical(c_bool) :: b_superfox
+ integer(c_int) :: yymmdd
end type params_block
type, bind(C) :: dec_data
diff --git a/lib/qra/q65/q65sim.f90 b/lib/qra/q65/q65sim.f90 index b9462939..04c064e3 100755 --- a/lib/qra/q65/q65sim.f90 +++ b/lib/qra/q65/q65sim.f90 @@ -222,14 +222,20 @@ program q65sim fac=sqrt(1.0/avep)
cspread=fac*cspread !Normalize to constant avg power
cdat=cspread*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
+! psig=0.
+! pnoise=0.
+! do i=1,npts
+! if(i.gt.12000 .and. i.lt.624000) then
+! psig=psig + aimag(cdat(i))**2
+! pnoise=pnoise + xnoise(i)*xnoise(i)
+! endif
+! enddo
+! pnoise=pnoise*bandwidth_ratio
+! snr_2500=db(psig/pnoise) !Calibration confirmation!
+! print*,'SNR_2500:',snr_2500
+
dat=aimag(cdat) + xnoise !Add generated AWGN noise
fac=32767.0
if(snrdb.ge.90.0) iwave(1:npts)=nint(fac*dat(1:npts))
diff --git a/lib/superfox/sfox_wave.f90 b/lib/superfox/sfox_wave.f90 new file mode 100755 index 00000000..2e39a1c6 --- /dev/null +++ b/lib/superfox/sfox_wave.f90 @@ -0,0 +1,40 @@ +subroutine sfox_wave(fname)
+
+! Called by WSJT-X when it's time for SuperFox to transmit. Reads array
+! itone(1:151) from disk file 'sfox_2.dat' in the writable data directory.
+
+ parameter (NWAVE=(160+2)*134400*4) !Max WSJT-X waveform (FST4-1800 at 48kHz)
+ parameter (NN=151,NSPS=1024)
+ character*(*) fname
+ integer itone(151)
+ real*8 dt,twopi,f0,baud,phi,dphi
+
+ common/foxcom/wave(NWAVE)
+
+ wave=0.
+ open(25,file=trim(fname),status='unknown',err=999)
+ read(25,'(20i4)',err=999,end=999) itone
+ close(25)
+ if(itone(1).lt.0 .or. itone(1).gt.128) go to 999
+
+! Generate the SuperFox waveform.
+
+ dt=1.d0/48000.d0
+ twopi=8.d0*atan(1.d0)
+ f0=750.0d0
+ phi=0.d0
+ baud=12000.d0/NSPS
+ k=0
+ do j=1,NN
+ f=f0 + baud*mod(itone(j),128)
+ dphi=twopi*f*dt
+ do ii=1,4*NSPS
+ k=k+1
+ phi=phi+dphi
+ xphi=phi
+ wave(k)=sin(xphi)
+ enddo
+ enddo
+
+999 return
+end subroutine sfox_wave
diff --git a/lib/superfox/sfox_wave_gfsk.f90 b/lib/superfox/sfox_wave_gfsk.f90 new file mode 100755 index 00000000..c4e30d75 --- /dev/null +++ b/lib/superfox/sfox_wave_gfsk.f90 @@ -0,0 +1,78 @@ +subroutine sfox_wave_gfsk(fname)
+
+! Called by WSJT-X when it's time for SuperFox to transmit. Reads array
+! itone(1:151) from disk file 'sfox_2.dat' in the writable data directory.
+! Generates a GFSK waveform with short ramp-up and ramp-down symbols of
+! duration NSPS/BT at the beginning and end of the waveform.
+
+ parameter (NWAVE=(160+2)*134400*4) !Max WSJT-X waveform (FST4-1800 at 48kHz)
+ parameter (NSYM=151,NSPS=1024*4)
+ parameter (NPTS=(NSYM+2)*NSPS)
+ parameter (BT=8)
+ character*(*) fname
+ integer itone(151)
+ real*8 dt,twopi,f0,baud,phi,dphi_peak
+ real*8 dphi(0:NPTS-1)
+ real*8 pulse(3*NSPS)
+ logical first/.true./
+
+ common/foxcom/wave(NWAVE)
+ save first,twopi,dt,hmod,dphi_peak,pulse
+
+ if(first) then
+ fsample=48000.0
+ twopi=8.d0*atan(1.d0)
+ dt=1.d0/fsample
+ hmod=1.0
+ dphi_peak=twopi*hmod/real(NSPS)
+ do i=1,3*NSPS
+ tt=(i-1.5*NSPS)/real(NSPS)
+ pulse(i)=gfsk_pulse(BT,tt)
+ enddo
+ first=.false.
+ endif
+ wave=0.
+
+ open(25,file=trim(fname),status='unknown',err=999)
+ read(25,'(20i4)',err=999,end=999) itone
+ close(25)
+ if(itone(1).lt.0 .or. itone(1).gt.128) go to 999
+
+! Generate the SuperFox waveform.
+
+ dphi=0.d0
+ do j=1,NSYM
+ ib=(j-1)*NSPS
+ ie=ib+3*NSPS-1
+ dphi(ib:ie)=dphi(ib:ie)+dphi_peak*pulse(1:3*NSPS)*itone(j)
+ enddo
+ dphi(0:2*NSPS-1)=dphi(0:2*NSPS-1)+dphi_peak*itone(1)*pulse(NSPS+1:3*NSPS)
+ dphi(NSYM*NSPS:(NSYM+2)*NSPS-1)=dphi(NSYM*NSPS:(NSYM+2)*NSPS-1)+dphi_peak*itone(NSYM)*pulse(1:2*NSPS)
+
+ phi=0.d0
+ f0=750.0d0
+ dphi=dphi+twopi*f0*dt
+ k=0
+ do j=1,NSPS*(NSYM+2)-1
+ k=k+1
+ wave(k)=sin(phi)
+ phi=phi+dphi(j)
+ enddo
+
+! Add raised cosine ramps at the beginning and end of the waveform.
+! Since the modulator expects an integral number of symbols, dummy
+! symbols are added to the beginning and end of the waveform to
+! hold the ramps. All but nramp of the samples in each dummy
+! symbol will be zero.
+
+ nramp=NSPS/BT
+ wave(1:NSPS-nramp)=0.0
+ wave(NSPS-nramp+1:NSPS)=wave(NSPS-nramp+1:NSPS) * &
+ (1.0-cos(twopi*(/(i,i=0,nramp-1)/)/(2.0*nramp)))/2.0
+ k1=(NSYM+1)*NSPS+1
+ wave(k1:k1+nramp-1)=wave(k1:k1+nramp-1) * &
+ (1.0+cos(twopi*(/(i,i=0,nramp-1)/)/(2.0*nramp)))/2.0
+ wave(k1+nramp:NPTS)=0.0
+
+999 return
+end subroutine sfox_wave_gfsk
|
