2021-06-18 14:16:16 -04:00
|
|
|
subroutine q65b(nutc,nqd,nxant,fcenter,nfcal,nfsample,ikhz,mousedf,ntol,xpol, &
|
|
|
|
mycall0,mygrid,hiscall0,hisgrid,mode_q65,f0,fqso,newdat,nagain, &
|
|
|
|
max_drift,idec)
|
2021-04-07 09:30:28 -04:00
|
|
|
|
2021-05-02 13:51:01 -04:00
|
|
|
! This routine provides an interface between MAP65 and the Q65 decoder
|
|
|
|
! in WSJT-X. All arguments are input data obtained from the MAP65 GUI.
|
|
|
|
! Raw Rx data are available as the 96 kHz complex spectrum ca(MAXFFT1)
|
|
|
|
! in common/cacb. If xpol is true, we also have cb(MAXFFT1) for the
|
|
|
|
! orthogonal polarization. Decoded messages are sent back to the GUI
|
|
|
|
! on stdout.
|
|
|
|
|
2021-05-28 10:30:26 -04:00
|
|
|
! use wavhdr
|
2021-04-28 10:13:42 -04:00
|
|
|
use q65_decode
|
2021-05-13 11:24:26 -04:00
|
|
|
use wideband_sync
|
2021-04-29 09:39:08 -04:00
|
|
|
use timer_module, only: timer
|
2021-04-29 14:35:19 -04:00
|
|
|
|
2021-04-07 09:30:28 -04:00
|
|
|
parameter (MAXFFT1=5376000) !56*96000
|
|
|
|
parameter (MAXFFT2=336000) !56*6000 (downsampled by 1/16)
|
|
|
|
parameter (NMAX=60*12000)
|
2021-06-18 14:16:16 -04:00
|
|
|
parameter (RAD=57.2957795)
|
2021-05-28 10:30:26 -04:00
|
|
|
! type(hdr) h !Header for the .wav file
|
2021-04-07 09:30:28 -04:00
|
|
|
integer*2 iwave(60*12000)
|
|
|
|
complex ca(MAXFFT1),cb(MAXFFT1) !FFTs of raw x,y data
|
2021-04-12 15:21:38 -04:00
|
|
|
complex cx(0:MAXFFT2-1),cy(0:MAXFFT2-1),cz(0:MAXFFT2)
|
2021-04-22 14:56:57 -04:00
|
|
|
logical xpol
|
2021-04-29 14:35:19 -04:00
|
|
|
integer ipk1(1)
|
2021-04-30 15:22:41 -04:00
|
|
|
real*8 fcenter,freq0
|
2021-04-07 09:58:25 -04:00
|
|
|
character*12 mycall0,hiscall0
|
|
|
|
character*12 mycall,hiscall
|
2021-06-18 14:16:16 -04:00
|
|
|
character*6 mygrid,hisgrid
|
2021-04-07 09:58:25 -04:00
|
|
|
character*4 grid4
|
2021-04-28 10:13:42 -04:00
|
|
|
character*80 line
|
2021-04-07 18:46:05 -04:00
|
|
|
character*80 wsjtx_dir
|
2021-06-18 14:16:16 -04:00
|
|
|
character*1 cp,cmode*2
|
2021-04-07 09:30:28 -04:00
|
|
|
common/cacb/ca,cb
|
2021-04-07 18:46:05 -04:00
|
|
|
save
|
2021-04-23 18:59:34 -04:00
|
|
|
|
|
|
|
open(9,file='wsjtx_dir.txt',status='old')
|
2021-05-02 13:51:01 -04:00
|
|
|
read(9,'(a)') wsjtx_dir !Establish the working directory
|
2021-04-23 18:59:34 -04:00
|
|
|
close(9)
|
|
|
|
|
2021-04-07 09:58:25 -04:00
|
|
|
if(mycall0(1:1).ne.' ') mycall=mycall0
|
|
|
|
if(hiscall0(1:1).ne.' ') hiscall=hiscall0
|
|
|
|
if(hisgrid(1:4).ne.' ') grid4=hisgrid(1:4)
|
|
|
|
|
2021-05-24 11:25:04 -04:00
|
|
|
! Find best frequency and ipol from sync_dat, the "orange sync curve".
|
2021-05-08 13:58:43 -04:00
|
|
|
df3=96000.0/32768.0
|
2021-05-24 11:25:04 -04:00
|
|
|
ifreq=nint((1000.0*f0)/df3)
|
2021-05-08 13:58:43 -04:00
|
|
|
ia=nint(ifreq-ntol/df3)
|
|
|
|
ib=nint(ifreq+ntol/df3)
|
2021-05-12 16:34:00 -04:00
|
|
|
ipk1=maxloc(sync(ia:ib)%ccfmax)
|
2021-04-30 15:22:41 -04:00
|
|
|
ipk=ia+ipk1(1)-1
|
2021-05-12 16:34:00 -04:00
|
|
|
snr1=sync(ipk)%ccfmax
|
2021-05-18 14:04:33 -04:00
|
|
|
|
2021-04-30 15:22:41 -04:00
|
|
|
ipol=1
|
2021-05-12 16:34:00 -04:00
|
|
|
if(xpol) ipol=sync(ipk)%ipol
|
2021-05-15 09:46:00 -04:00
|
|
|
|
2021-04-07 09:30:28 -04:00
|
|
|
nfft1=MAXFFT1
|
|
|
|
nfft2=MAXFFT2
|
|
|
|
df=96000.0/NFFT1
|
|
|
|
if(nfsample.eq.95238) then
|
|
|
|
nfft1=5120000
|
|
|
|
nfft2=322560
|
|
|
|
df=96000.0/nfft1
|
|
|
|
endif
|
|
|
|
nh=nfft2/2
|
2021-05-20 13:01:36 -04:00
|
|
|
f_mouse=1000.0*(fqso+48.0) + mousedf
|
|
|
|
f_ipk=ipk*df3
|
2021-05-08 13:58:43 -04:00
|
|
|
k0=nint((ipk*df3-1000.0)/df)
|
2021-05-20 13:01:36 -04:00
|
|
|
if(nagain.eq.1) k0=nint((f_mouse-1000.0)/df)
|
2021-05-18 14:04:33 -04:00
|
|
|
|
2021-05-23 09:27:31 -04:00
|
|
|
if(k0.lt.nh .or. k0.gt.MAXFFT1-nfft2+1) go to 900
|
2021-05-16 14:56:43 -04:00
|
|
|
if(snr1.lt.1.5) go to 900 !### Threshold needs work? ###
|
2021-04-07 09:30:28 -04:00
|
|
|
|
|
|
|
fac=1.0/nfft2
|
2021-05-02 13:51:01 -04:00
|
|
|
cx(0:nfft2-1)=ca(k0:k0+nfft2-1)
|
2021-04-07 09:30:28 -04:00
|
|
|
cx=fac*cx
|
|
|
|
if(xpol) then
|
2021-05-02 13:51:01 -04:00
|
|
|
cy(0:nfft2-1)=cb(k0:k0+nfft2-1)
|
2021-04-07 09:30:28 -04:00
|
|
|
cy=fac*cy
|
|
|
|
endif
|
|
|
|
|
|
|
|
! Here cx and cy (if xpol) are frequency-domain data around the selected
|
|
|
|
! QSO frequency, taken from the full-length FFT computed in filbig().
|
|
|
|
! Values for fsample, nfft1, nfft2, df, and the downsampled data rate
|
|
|
|
! are as follows:
|
|
|
|
|
|
|
|
! fSample nfft1 df nfft2 fDownSampled
|
|
|
|
! (Hz) (Hz) (Hz)
|
|
|
|
!----------------------------------------------------
|
|
|
|
! 96000 5376000 0.017857143 336000 6000.000
|
|
|
|
! 95238 5120000 0.018601172 322560 5999.994
|
|
|
|
|
2021-06-18 14:16:16 -04:00
|
|
|
poldeg=0.
|
|
|
|
if(xpol) then
|
|
|
|
poldeg=sync(ipk)%pol
|
|
|
|
cz(0:MAXFFT2-1)=cos(poldeg/RAD)*cx + sin(poldeg/RAD)*cy
|
|
|
|
else
|
|
|
|
cz(0:MAXFFT2-1)=cx
|
|
|
|
endif
|
|
|
|
|
2021-04-29 14:35:19 -04:00
|
|
|
cz(MAXFFT2)=0.
|
2021-05-02 13:51:01 -04:00
|
|
|
! Roll off below 500 Hz and above 2500 Hz.
|
|
|
|
ja=nint(500.0/df)
|
|
|
|
jb=nint(2500.0/df)
|
|
|
|
do i=0,ja
|
|
|
|
r=0.5*(1.0+cos(i*3.14159/ja))
|
|
|
|
cz(ja-i)=r*cz(ja-i)
|
|
|
|
cz(jb+i)=r*cz(jb+i)
|
|
|
|
enddo
|
|
|
|
cz(ja+jb+1:)=0.
|
|
|
|
|
2021-04-13 13:52:46 -04:00
|
|
|
!Transform to time domain (real), fsample=12000 Hz
|
2021-04-29 14:35:19 -04:00
|
|
|
call four2a(cz,2*nfft2,1,1,-1)
|
|
|
|
do i=0,nfft2-1
|
|
|
|
j=nfft2-1-i
|
2021-05-02 13:51:01 -04:00
|
|
|
iwave(2*i+2)=nint(real(cz(j))) !Note the reversed order!
|
|
|
|
iwave(2*i+1)=nint(aimag(cz(j)))
|
2021-04-29 14:35:19 -04:00
|
|
|
enddo
|
|
|
|
iwave(2*nfft2+1:)=0
|
2021-05-02 13:51:01 -04:00
|
|
|
|
2021-05-28 10:30:26 -04:00
|
|
|
! open(30,file='000000_0001.wav',status='unknown',access='stream')
|
|
|
|
! h=default_header(12000,NMAX)
|
|
|
|
! write(30) h,iwave
|
|
|
|
! close(30)
|
2021-05-18 14:04:33 -04:00
|
|
|
|
2021-04-29 14:35:19 -04:00
|
|
|
nsubmode=mode_q65-1
|
2021-05-24 12:03:27 -04:00
|
|
|
nfa=990 !Tight limits around ipk for the wideband decode
|
|
|
|
nfb=1010
|
|
|
|
if(nagain.eq.1) then !For nagain=1, use limits of +/- ntol
|
2021-05-20 13:01:36 -04:00
|
|
|
nfa=max(100,1000-ntol)
|
|
|
|
nfb=min(2500,1000+ntol)
|
|
|
|
endif
|
2021-04-29 14:35:19 -04:00
|
|
|
nsnr0=-99 !Default snr for no decode
|
|
|
|
|
2021-05-08 13:58:43 -04:00
|
|
|
! NB: Frequency of ipk is now shifted to 1000 Hz.
|
2021-05-13 15:33:52 -04:00
|
|
|
call map65_mmdec(nutc,iwave,nqd,nsubmode,nfa,nfb,1000,ntol, &
|
2021-05-30 12:07:48 -04:00
|
|
|
newdat,nagain,max_drift,mycall,hiscall,hisgrid)
|
2021-05-24 11:25:04 -04:00
|
|
|
|
2021-05-15 09:46:00 -04:00
|
|
|
MHz=fcenter
|
|
|
|
freq0=MHz + 0.001*ikhz
|
2021-05-24 11:25:04 -04:00
|
|
|
|
2021-04-29 17:05:11 -04:00
|
|
|
if(nsnr0.gt.-99) then
|
2021-05-17 13:40:04 -04:00
|
|
|
nq65df=nint(1000*(0.001*k0*df+nkhz_center-48.0+1.000-1.27046-ikhz))-nfcal
|
2021-05-20 13:01:36 -04:00
|
|
|
nq65df=nq65df + nfreq0 - 1000
|
2021-06-18 14:16:16 -04:00
|
|
|
npol=nint(poldeg)
|
|
|
|
if(nxant.ne.0) then
|
|
|
|
npol=npol-45
|
|
|
|
if(npol.lt.0) npol=npol+180
|
|
|
|
endif
|
|
|
|
call txpol(xpol,msg0(1:22),mygrid,npol,nxant,ntxpol,cp)
|
2021-05-20 18:40:06 -04:00
|
|
|
if(nqd.eq.1 .and. abs(nq65df-mousedf).lt.ntol) then
|
2021-06-18 14:16:16 -04:00
|
|
|
write(line,1020) ikhz,nq65df,npol,nutc,xdt0,nsnr0,msg0(1:27),cq0, &
|
|
|
|
ntxpol,cp
|
|
|
|
1020 format('!',i3.3,i5,i4,i6.4,f5.1,i5,' : ',a27,a3,i4,1x,a1)
|
2021-05-13 13:13:21 -04:00
|
|
|
write(*,1100) trim(line)
|
|
|
|
1100 format(a)
|
|
|
|
endif
|
|
|
|
|
|
|
|
! Write to lu 26, for Messages and Band Map windows
|
2021-06-18 14:16:16 -04:00
|
|
|
|
|
|
|
cmode=': '
|
|
|
|
cmode(2:2)=char(ichar('A') + mode_q65-1)
|
|
|
|
write(26,1014) freq0,nq65df,0,0,0,xdt0,npol,0, &
|
|
|
|
nsnr0,nutc,msg0(1:22),':',cp,cmode
|
|
|
|
1014 format(f8.3,i5,3i3,f5.1,i4,i3,i4,i5.4,4x,a22,1x,2a1,2x,a2)
|
2021-04-13 14:46:31 -04:00
|
|
|
|
2021-04-28 10:13:42 -04:00
|
|
|
! Write to file map65_rx.log:
|
2021-06-18 14:16:16 -04:00
|
|
|
write(21,1110) freq0,nq65df,xdt0,npol,nsnr0,nutc,msg0(1:28),cq0
|
2021-04-28 10:13:42 -04:00
|
|
|
1110 format(f8.3,i5,f5.1,2i4,i5.4,2x,a28,': A',2x,a3)
|
2021-04-29 17:05:11 -04:00
|
|
|
endif
|
2021-04-28 14:14:54 -04:00
|
|
|
|
|
|
|
900 close(13)
|
|
|
|
close(17)
|
|
|
|
call flush(6)
|
2021-05-14 19:37:14 -04:00
|
|
|
idec=-1
|
|
|
|
read(cq0(2:2),*) idec
|
2021-04-28 14:14:54 -04:00
|
|
|
|
|
|
|
return
|
2021-04-07 09:30:28 -04:00
|
|
|
end subroutine q65b
|