FT4: Subtraction is basically working.

This commit is contained in:
Steve Franke 2019-04-18 14:16:39 -05:00
parent be72461142
commit e8d17a9898
11 changed files with 472 additions and 453 deletions

View File

@ -1,11 +1,11 @@
subroutine ft4_downsample(iwave,newdata,f0,c)
subroutine ft4_downsample(dd,newdata,f0,c)
! Input: i*2 data in iwave() at sample rate 12000 Hz
! Input: real data in dd() at sample rate 12000 Hz
! Output: Complex data in c(), sampled at 1200 Hz
include 'ft4_params.f90'
parameter (NFFT2=NMAX/16)
integer*2 iwave(NMAX)
real dd(NMAX)
complex c(0:NMAX/NDOWN-1)
complex c1(0:NFFT2-1)
complex cx(0:NMAX/2)
@ -33,7 +33,7 @@ subroutine ft4_downsample(iwave,newdata,f0,c)
endif
if(newdata) then
x=iwave
x=dd
call four2a(x,NMAX,1,-1,0) !r2c FFT to freq domain
endif
i0=nint(f0/df)

View File

@ -9,7 +9,7 @@ parameter (NN2=NS+ND+2) !Total channel symbols (105)
parameter (NSPS=512) !Samples per symbol at 12000 S/s
parameter (NZ=NSPS*NN) !Sync and Data samples (52736)
parameter (NZ2=NSPS*NN2) !Total samples in shaped waveform (53760)
parameter (NMAX=5*12000) !Samples in iwave (60,000)
parameter (NMAX=18*3456) !Samples in iwave
parameter (NFFT1=2048, NH1=NFFT1/2) !Length of FFTs for symbol spectra
parameter (NSTEP=NSPS) !Coarse time-sync step size
parameter (NHSYM=(NMAX-NFFT1)/NSTEP) !Number of symbol spectra (1/4-sym steps)

View File

@ -63,7 +63,7 @@ program ft4sim
n3=-1
call pack77(msg37,i3,n3,c77)
read(c77,'(77i1)') msgbits
call genft4(msg37,0,msgsent37,itone)
call genft4(msg37,0,msgsent37,msgbits,itone)
write(*,*)
write(*,'(a9,a37,3x,a7,i1,a1,i1)') 'Message: ',msgsent37,'i3.n3: ',i3,'.',n3
write(*,1000) f0,xdt,txt,snrdb

View File

@ -15,6 +15,7 @@ program ft4sim_mult
real wave(NZZ)
real tmp(NZZ)
integer itone(NN)
integer*1 msgbits(77)
integer*2 iwave(NZZ) !Generated full-length waveform
integer icos4(4)
data icos4/0,1,3,2/
@ -62,7 +63,7 @@ program ft4sim_mult
i3=-1
n3=-1
call pack77(msg37,i3,n3,c77)
call genft4(msg37,0,msgsent37,itone)
call genft4(msg37,0,msgsent37,msgbits,itone)
nwave0=(NN+2)*NSPS
icmplx=0
call gen_ft4wave(itone,NN,NSPS,12000.0,f0,cwave0,wave0,icmplx,nwave0)

View File

@ -1,4 +1,4 @@
subroutine genft4(msg0,ichk,msgsent,i4tone)
subroutine genft4(msg0,ichk,msgsent,msgbits,i4tone)
! Encode an FT4 message
! Input:
@ -52,8 +52,16 @@ subroutine genft4(msg0,ichk,msgsent,i4tone)
call unpack77(c77,0,msgsent,unpk77_success) !Unpack to get msgsent
if(ichk.eq.1) go to 999
read(c77,"(77i1)") msgbits
msgbits=mod(msgbits+rvec,2)
read(c77,'(77i1)',err=1) msgbits
if(unpk77_success) go to 2
1 msgbits=0
itone=0
msgsent='*** bad message *** '
go to 999
entry get_ft4_tones_from_77bits(msgbits,i4tone)
2 msgbits=mod(msgbits+rvec,2)
call encode174_91(msgbits,codeword)
! Grayscale mapping:

View File

@ -1,4 +1,4 @@
subroutine getcandidates4(id,fa,fb,syncmin,nfqso,maxcand,savg,candidate, &
subroutine getcandidates4(dd,fa,fb,syncmin,nfqso,maxcand,savg,candidate, &
ncand,sbase)
include 'ft4_params.f90'
@ -9,7 +9,7 @@ subroutine getcandidates4(id,fa,fb,syncmin,nfqso,maxcand,savg,candidate, &
real window(NFFT1)
complex cx(0:NH1)
real candidate(3,maxcand)
integer*2 id(NMAX)
real dd(NMAX)
integer indx(NH1)
integer ipk(1)
equivalence (x,cx)
@ -33,7 +33,7 @@ subroutine getcandidates4(id,fa,fb,syncmin,nfqso,maxcand,savg,candidate, &
ia=(j-1)*NSTEP + 1
ib=ia+NFFT1-1
if(ib.gt.NMAX) exit
x=fac*id(ia:ib)*window
x=fac*dd(ia:ib)*window
call four2a(x,NFFT1,1,-1,0) !r2c FFT
do i=1,NH1
s(i,j)=real(cx(i))**2 + aimag(cx(i))**2

View File

@ -9,22 +9,23 @@ subroutine subtractft4(dd,itone,f0,dt)
use timer_module, only: timer
parameter (NMAX=6*12000,NFRAME=(103+2)*79)
parameter (NMAX=18*3456,NFRAME=(103+2)*512)
parameter (NFFT=NMAX,NFILT=1400)
! parameter (NFFT=NMAX,NFILT=400)
real*4 dd(NMAX), window(-NFILT/2:NFILT/2), xjunk
complex cref,camp,cfilt,cw
integer itone(79)
integer itone(103)
logical first
data first/.true./
common/heap8/cref(NFRAME),camp(NMAX),cfilt(NMAX),cw(NMAX),xjunk(NFRAME)
save first
nstart=dt*12000+1
nsym=79
nsps=1920
nstart=dt*12000+1-512
nsym=103
nsps=512
fs=12000.0
icmplx=1
bt=1.0 ! Temporary compromise?
bt=1.0
call gen_ft4wave(itone,nsym,nsps,fs,f0,cref,xjunk,icmplx,NFRAME)
camp=0.
do i=1,nframe

View File

@ -52,6 +52,7 @@ contains
real bmeta(2*NN),bmetb(2*NN),bmetc(2*NN)
real a(5)
real dd(NZZ)
real llr(2*ND),llra(2*ND),llrb(2*ND),llrc(2*ND),llrd(2*ND)
real s2(0:255)
real candidate(3,100)
@ -64,6 +65,7 @@ contains
integer*1 message77(77),rvec(77),apmask(2*ND),cw(2*ND)
integer*1 hbits(2*NN)
integer graymap(0:3)
integer i4tone(103)
integer ip(1)
integer nappasses(0:5) ! # of decoding passes for QSO States 0-5
integer naptypes(0:5,4) ! nQSOProgress, decoding pass
@ -199,25 +201,27 @@ contains
mycall0=mycall
hiscall0=hiscall
endif
candidate=0.0
ncand=0
syncmin=1.2
maxcand=100
ndecodes=0
decodes=' '
fa=nfa
fb=nfb
dd=iwave
do isp = 1,2
candidate=0.0
ncand=0
call timer('getcand4',0)
call getcandidates4(iwave,fa,fb,syncmin,nfqso,maxcand,savg,candidate, &
call getcandidates4(dd,fa,fb,syncmin,nfqso,maxcand,savg,candidate, &
ncand,sbase)
call timer('getcand4',1)
ndecodes=0
dobigfft=.true.
do icand=1,ncand
f0=candidate(1,icand)
snr=candidate(3,icand)-1.0
call timer('ft4_down',0)
call ft4_downsample(iwave,dobigfft,f0,cd2) !Downsample to 32 Sam/Sym
call ft4_downsample(dd,dobigfft,f0,cd2) !Downsample to 32 Sam/Sym
call timer('ft4_down',1)
if(dobigfft) dobigfft=.false.
sum2=sum(cd2*conjg(cd2))/(real(NZZ)/real(NDOWN))
@ -257,10 +261,8 @@ contains
enddo
f0=f0+real(idfbest)
if( f0.le.10.0 .or. f0.ge.4990.0 ) cycle
! write(*,3002) smax,ibest/750.0,f0
!3002 format('b',3f8.2)
call timer('ft4down ',0)
call ft4_downsample(iwave,dobigfft,f0,cb) !Final downsample, corrected f0
call ft4_downsample(dd,dobigfft,f0,cb) !Final downsample, corrected f0
call timer('ft4down ',1)
sum2=sum(abs(cb)**2)/(real(NSS)*NN)
if(sum2.gt.0.0) cb=cb/sqrt(sum2)
@ -459,6 +461,11 @@ contains
message77=mod(message77+rvec,2) ! remove rvec scrambling
write(c77,'(77i1)') message77(1:77)
call unpack77(c77,1,message,unpk77_success)
if(unpk77_success) then
call get_ft4_tones_from_77bits(message77,i4tone)
dt=real(ibest)/750.0
call subtractft4(dd,i4tone,f0,dt)
endif
idupe=0
do i=1,ndecodes
if(decodes(i).eq.message) idupe=1
@ -480,7 +487,7 @@ contains
endif
enddo !Sequence estimation
enddo !Candidate list
enddo !Subtraction loop
return
end subroutine decode

View File

@ -396,7 +396,7 @@ subroutine ft8b(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, &
cycle
endif
nbadcrc=0 ! If we get this far: valid codeword, valid (i3,n3), nonquirky message.
call get_tones_from_77bits(message77,itone)
call get_ft8_tones_from_77bits(message77,itone)
if(lsubtract) call subtractft8(dd0,itone,f1,xdt)
xsig=0.0
xnoi=0.0

View File

@ -25,7 +25,7 @@ subroutine genft8(msg,i3,n3,msgsent,msgbits,itone)
msgsent='*** bad message *** '
go to 900
entry get_tones_from_77bits(msgbits,itone)
entry get_ft8_tones_from_77bits(msgbits,itone)
2 call encode174_91(msgbits,codeword) !Encode the test message

View File

@ -99,7 +99,7 @@ extern "C" {
void genft8_(char* msg, int* i3, int* n3, char* msgsent, char ft8msgbits[],
int itone[], fortran_charlen_t, fortran_charlen_t);
void genft4_(char* msg, int* ichk, char* msgsent, int itone[],
void genft4_(char* msg, int* ichk, char* msgsent, char ft4msgbits[], int itone[],
fortran_charlen_t, fortran_charlen_t);
void gen_ft8wave_(int itone[], int* nsym, int* nsps, float* bt, float* fsample, float* f0,
@ -3739,7 +3739,9 @@ void MainWindow::guiUpdate()
}
if(m_modeTx=="FT4") {
int ichk=0;
genft4_(message, &ichk, msgsent, const_cast<int *>(itone), 37, 37);
char ft4msgbits[77];
genft4_(message, &ichk, msgsent, const_cast<char *> (ft4msgbits),
const_cast<int *>(itone), 37, 37);
int nsym=103;
int nsps=4*512;
float fsample=48000.0;