1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
module qmap_q65_samples_mod
use iso_fortran_env, only: int16
implicit none
contains
subroutine build_q65_samples(k0,nfft2,df,iseq,iwave)
use cacb_mod, only: ca
integer, intent(in) :: k0,nfft2,iseq
real, intent(in) :: df
integer(int16), intent(out) :: iwave(:)
integer, parameter :: MAXFFT2=336000
complex cx(0:MAXFFT2-1),cz(0:MAXFFT2)
save cx,cz
integer i,j,ja,jb
real fac,r
fac=1.0/nfft2
cx(0:nfft2-1)=fac*ca(k0:k0+nfft2-1)
cz(0:MAXFFT2-1)=cx
cz(MAXFFT2)=0.
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.
call four2a(cz,2*nfft2,1,1,-1)
do i=0,nfft2-1
j=nfft2-1-i
iwave(2*i+2)=nint(real(cz(j)))
iwave(2*i+1)=nint(aimag(cz(j)))
enddo
iwave(2*nfft2+1:)=0
if(iseq.eq.1) iwave(1:360000)=iwave(360001:720000)
end subroutine build_q65_samples
end module qmap_q65_samples_mod
subroutine q65b(nutc,nqd,fcenter,nfcal,nfsample,ikhz,mousedf,ntol, &
ntrperiod,iseq,mycall0,hiscall0,hisgrid,mode_q65,f0,fqso,nkhz_center, &
newdat,nagain,bClickDecode,max_drift,offset,ndepth,datetime,nCFOM, &
ndop00,nhsym,idec)
! This routine provides an interface between QMAP and the Q65 decoder
! in WSJT-X. All arguments are input data obtained from the QMAP GUI.
! Raw Rx data are available as the 96 kHz complex spectrum ca(MAXFFT1)
! in cacb_mod. Decoded messages are sent back to the GUI.
use q65_decode
use wavhdr
use timer_module, only: timer
use map65_mmdec_mod, only: map65_mmdec
use qmap_decode_ipc, only: max_decode_rows, decode_row_length, &
ndecodes, result, result2
use iso_fortran_env, only: int16
use cacb_mod, only: init_cacb
use qmap_q65_samples_mod, only: build_q65_samples
parameter (MAXFFT1=5376000) !56*96000
parameter (MAXFFT2=336000) !56*6000 (downsampled by 1/16)
parameter (NMAX=60*12000)
parameter (RAD=57.2957795)
type(hdr) h
integer(int16) iwave(300*12000)
integer offset
real*8 fcenter,freq0,freq1
logical*1 bClickDecode
character*12 mycall0,hiscall0
character*12 mycall,hiscall
character*6 hisgrid
character*4 grid4
character*3 csubmode
character*17 fname
character(len=decode_row_length) ctmp
character*20 datetime,datetime1
data ifile/0/
save
call init_cacb(MAXFFT1)
if(mycall0(1:1).ne.' ') mycall=mycall0
if(hiscall0(1:1).ne.' ') hiscall=hiscall0
if(hisgrid(1:4).ne.' ') grid4=hisgrid(1:4)
! Find best frequency from sync_dat, the "orange sync curve".
df3=96000.0/32768.0
ipk=(1000.0*f0-1.0)/df3
if(nagain.ge.2) ipk = nint(1000.0*(fqso-nkhz_center+48.0)/df3)
nfft1=MAXFFT1
nfft2=MAXFFT2
df=96000.0/NFFT1
nh=nfft2/2
k0=nint((ipk*df3-1000.0)/df)
if(k0.lt.nh .or. k0.gt.MAXFFT1-nfft2+1) go to 900
call build_q65_samples(k0,nfft2,df,iseq,iwave)
nsubmode=mode_q65-1
nfa=990 !Tight limits around ipk for the wideband decode
nfb=1010
if(nagain.ge.1) then !For nagain>=1, use limits of +/- ntol
nfa=max(100,1000-ntol)
nfb=min(2500,1000+ntol)
endif
nsnr0=-99 !Default snr for no decode
csubmode(1:2)='60'
csubmode(3:3)=char(ichar('A')+nsubmode)
nhhmmss=100*nutc
nutc1=nutc
datetime(12:13)='00'
datetime1=datetime
if(ntrperiod.eq.30) then
csubmode(1:2)='30'
nhhmmss=100*nutc + iseq*30
nutc1=nhhmmss
if(iseq.eq.1) datetime1(12:13)='30'
endif
if(nagain.ge.2) then
ifile=ifile+1
write(fname,1000) ifile
1000 format('000000_',i6.6,'.wav')
open(27,file=fname,status='unknown',access='stream')
if(nagain.eq.2) then
h=default_header(12000,60*12000)
ia=1
ib=60*12000
else if(nagain.eq.3) then
h=default_header(12000,30*12000)
ia=1
ib=30*12000
else
h=default_header(12000,30*12000)
ia=30*12000 + 1
ib=60*12000
endif
write(27) h,iwave(ia:ib)
close(27)
go to 900
endif
! NB: Frequency of ipk is now shifted to 1000 Hz.
nagain2=0
call map65_mmdec(nutc1,iwave,nqd,ntrperiod,nsubmode,nfa,nfb,1000,ntol, &
newdat,nagain2,max_drift,ndepth,mycall,hiscall,hisgrid)
MHz=fcenter
freq0=MHz + 0.001d0*ikhz
if(nsnr0.gt.-99) then
do i=1,ndecodes !Check for dupes
i1=index(result(i)(42:),trim(msg0))
! If this is a dupe, don't save it again:
if(i1.gt.0 .and. (.not.bClickDecode .or. nhsym.eq.390)) go to 800
enddo
nq65df=nint(1000*(0.001*k0*df+nkhz_center-48.0+1.000-1.27046-ikhz))-nfcal
nq65df=nq65df + nfreq0 - 1000
ikhz1=ikhz
ndf=nq65df
if(ndf.gt.500) ikhz1=ikhz + (nq65df+500)/1000
if(ndf.lt.-500) ikhz1=ikhz + (nq65df-500)/1000
ndf=nq65df - 1000*(ikhz1-ikhz)
freq1=freq0 + 0.001d0*(ikhz1-ikhz)
frx=0.001*k0*df+nkhz_center-48.0+1.0 - 0.001*nfcal
fsked=frx - 0.001*ndop00/2.0 - 0.001*offset
ctmp=csubmode//' '//trim(msg0)
ndecodes=min(ndecodes+1,max_decode_rows)
write(result(ndecodes),1120) nhhmmss,frx,fsked,xdt0,nsnr0,trim(ctmp)
1120 format(i6.6,f9.3,f7.1,f7.2,i5,2x,a)
write(result2(ndecodes),1125) fsked !liveCQ
1125 format(f7.3) !liveCQ & changed from(f7.1) to give fsked Hz accuracy
write(12,1130) datetime1,trim(result(ndecodes)(7:))
1130 format(a13,1x,a)
result(ndecodes)=trim(result(ndecodes))//char(0)
result2(ndecodes)=trim(result2(ndecodes))//char(0)
800 idec=0
endif
900 flush(12)
return
end subroutine q65b
|