mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2025-03-29 07:28:54 -04:00
Working on a better way to get DT, f0, f1, f2, ...
git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@2772 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
parent
8c74fccc5f
commit
3ce1ead2f4
@ -5,7 +5,7 @@ program jt9sim
|
|||||||
parameter (NMAX=1800*12000)
|
parameter (NMAX=1800*12000)
|
||||||
integer ihdr(11)
|
integer ihdr(11)
|
||||||
integer*2 iwave !Generated waveform (no noise)
|
integer*2 iwave !Generated waveform (no noise)
|
||||||
real*8 f0,f,dt,twopi,phi,dphi,baud,fspan
|
real*8 f0,f,dt,twopi,phi,dphi,baud,fspan,fsample,freq
|
||||||
character msg*22,msg0*22,message*22,msgsent*22,arg*8,fname*11
|
character msg*22,msg0*22,message*22,msgsent*22,arg*8,fname*11
|
||||||
|
|
||||||
integer*4 i4tone(85) !Channel symbols (values 0-8)
|
integer*4 i4tone(85) !Channel symbols (values 0-8)
|
||||||
@ -106,7 +106,7 @@ program jt9sim
|
|||||||
1020 format(i3,i4,f10.3,f7.1,2x,a22)
|
1020 format(i3,i4,f10.3,f7.1,2x,a22)
|
||||||
|
|
||||||
phi=0.
|
phi=0.
|
||||||
baud=12000.0/nsps
|
baud=12000.d0/nsps
|
||||||
k=12000 !Start audio at t = 1.0 s
|
k=12000 !Start audio at t = 1.0 s
|
||||||
do isym=1,85
|
do isym=1,85
|
||||||
freq=f + i4tone(isym)*baud
|
freq=f + i4tone(isym)*baud
|
||||||
|
259
lib/jt9test.f90
259
lib/jt9test.f90
@ -1,120 +1,181 @@
|
|||||||
program jt9test
|
program jt9test
|
||||||
|
|
||||||
! Decoder for JT9.
|
! Decoder for JT9. Can run stand-alone, reading data from *.wav files;
|
||||||
|
! or as the back end of wsjt-x, with data placed in a shared memory region.
|
||||||
|
|
||||||
|
! NB: For unknown reason, ***MUST*** be compiled by g95 with -O0 !!!
|
||||||
|
|
||||||
|
character*80 arg,infile
|
||||||
parameter (NMAX=1800*12000) !Total sample intervals per 30 minutes
|
parameter (NMAX=1800*12000) !Total sample intervals per 30 minutes
|
||||||
parameter (NDMAX=1800*1500) !Sample intervals at 1500 Hz rate
|
parameter (NDMAX=1800*1500) !Sample intervals at 1500 Hz rate
|
||||||
parameter (NSMAX=22000) !Max length of saved spectra
|
parameter (NSMAX=22000) !Max length of saved spectra
|
||||||
|
integer*4 ihdr(11)
|
||||||
|
real*4 s(NSMAX)
|
||||||
|
real*4 ccfred(NSMAX)
|
||||||
|
logical*1 lstrong(0:1023)
|
||||||
|
integer*1 i1SoftSymbols(207)
|
||||||
character*22 msg
|
character*22 msg
|
||||||
character*33 line
|
character*33 line
|
||||||
character*80 fmt,fmt14
|
integer*2 id2
|
||||||
real*4 ccfred(NSMAX)
|
complex c0
|
||||||
integer*1 i1SoftSymbols(207)
|
complex c1(0:2700000)
|
||||||
integer ii(1)
|
common/jt9com/ss(184,NSMAX),savg(NSMAX),c0(NDMAX),id2(NMAX),nutc,ndiskdat, &
|
||||||
complex c0(NDMAX)
|
ntr,mousefqso,newdat,nfa,nfb,ntol,kin,nzhsym,nsynced,ndecoded
|
||||||
! common/jt9com/ss0(184,NSMAX),savg(NSMAX),id2(NMAX),nutc0,ndiskdat, &
|
|
||||||
! ntr,nfqso,newdat,npts80,nfb,ntol,kin,nzhsym,nsynced,ndecoded
|
|
||||||
! common/jt9comB/ss(184,NSMAX),c0
|
|
||||||
common/tracer/limtrace,lu
|
common/tracer/limtrace,lu
|
||||||
|
|
||||||
|
nargs=iargc()
|
||||||
|
if(nargs.lt.1) then
|
||||||
|
print*,'Usage: jt9 TRperiod file1 [file2 ...]'
|
||||||
|
print*,' Reads data from *.wav files.'
|
||||||
|
print*,''
|
||||||
|
print*,' jt9 -s'
|
||||||
|
print*,' Gets data from shared memory region.'
|
||||||
|
go to 999
|
||||||
|
endif
|
||||||
|
call getarg(1,arg)
|
||||||
|
if(arg(1:2).eq.'-s') then
|
||||||
|
! call jt9a
|
||||||
|
! call ftnquit
|
||||||
|
go to 999
|
||||||
|
endif
|
||||||
|
read(arg,*) ntrperiod
|
||||||
|
|
||||||
|
ifile1=2
|
||||||
|
|
||||||
limtrace=0
|
limtrace=0
|
||||||
lu=12
|
lu=12
|
||||||
open(12,file='timer.out',status='unknown')
|
nfa=1000
|
||||||
open(13,file='decoded.txt',status='unknown')
|
nfb=2000
|
||||||
open(14,file='wsjtx_rx.log',status='unknown',position='append')
|
ntol=500
|
||||||
call timer('decoder ',0)
|
nfqso=1500
|
||||||
|
newdat=1
|
||||||
|
nb=0
|
||||||
|
nbslider=100
|
||||||
|
limit=20000
|
||||||
|
ndiskdat=1
|
||||||
|
|
||||||
1 read(61,end=999) ipk,ia,ib,ccfred(ia:ib),nsps,npts8,c0(1:npts8)
|
do ifile=ifile1,nargs
|
||||||
print*,ipk,ia,ib,nsps,npts8
|
call getarg(ifile,infile)
|
||||||
ntrMinutes=1
|
open(10,file=infile,access='stream',status='old',err=998)
|
||||||
|
read(10) ihdr
|
||||||
|
i1=index(infile,'.wav')
|
||||||
|
read(infile(i1-4:i1-1),*,err=1) nutc0
|
||||||
|
go to 2
|
||||||
|
1 nutc0=0
|
||||||
|
2 nsps=0
|
||||||
|
if(ntrperiod.eq.1) then
|
||||||
|
nsps=6912
|
||||||
|
nzhsym=181
|
||||||
|
else if(ntrperiod.eq.2) then
|
||||||
|
nsps=15360
|
||||||
|
nzhsym=178
|
||||||
|
else if(ntrperiod.eq.5) then
|
||||||
|
nsps=40960
|
||||||
|
nzhsym=172
|
||||||
|
else if(ntrperiod.eq.10) then
|
||||||
|
nsps=82944
|
||||||
|
nzhsym=171
|
||||||
|
else if(ntrperiod.eq.30) then
|
||||||
|
nsps=252000
|
||||||
|
nzhsym=167
|
||||||
|
endif
|
||||||
|
if(nsps.eq.0) stop 'Error: bad TRperiod'
|
||||||
|
|
||||||
nsynced=0
|
kstep=nsps/2
|
||||||
ndecoded=0
|
tstep=kstep/12000.0
|
||||||
limit=200
|
k=0
|
||||||
if(ndepth.ge.2) limit=2000
|
nhsym0=-999
|
||||||
if(ndepth.ge.3) limit=20000
|
npts=(60*ntrperiod-6)*12000
|
||||||
|
if(ifile.eq.ifile1) then
|
||||||
nsps=0
|
open(12,file='timer.out',status='unknown')
|
||||||
if(ntrMinutes.eq.1) then
|
call timer('jt9 ',0)
|
||||||
nsps=6912
|
|
||||||
df3=1500.0/2048.0
|
|
||||||
fmt='(i4.4,i4,i5,f6.1,f8.0,f6.1,3x,a22)'
|
|
||||||
fmt14='(i4.4,i4,i5,f6.1,f8.0,f6.1,i8,3x,a22)'
|
|
||||||
else if(ntrMinutes.eq.2) then
|
|
||||||
nsps=15360
|
|
||||||
df3=1500.0/2048.0
|
|
||||||
fmt='(i4.4,i4,i5,f6.1,f8.1,f6.2,3x,a22)'
|
|
||||||
fmt14='(i4.4,i4,i5,f6.1,f8.1,f6.2,i8,3x,a22)'
|
|
||||||
else if(ntrMinutes.eq.5) then
|
|
||||||
nsps=40960
|
|
||||||
df3=1500.0/6144.0
|
|
||||||
fmt='(i4.4,i4,i5,f6.1,f8.1,f6.2,3x,a22)'
|
|
||||||
fmt14='(i4.4,i4,i5,f6.1,f8.1,f6.2,i8,3x,a22)'
|
|
||||||
else if(ntrMinutes.eq.10) then
|
|
||||||
nsps=82944
|
|
||||||
df3=1500.0/12288.0
|
|
||||||
fmt='(i4.4,i4,i5,f6.1,f8.2,f6.2,3x,a22)'
|
|
||||||
fmt14='(i4.4,i4,i5,f6.1,f8.2,f6.2,i8,3x,a22)'
|
|
||||||
else if(ntrMinutes.eq.30) then
|
|
||||||
nsps=252000
|
|
||||||
df3=1500.0/32768.0
|
|
||||||
fmt='(i4.4,i4,i5,f6.1,f8.2,f6.2,3x,a22)'
|
|
||||||
fmt14='(i4.4,i4,i5,f6.1,f8.2,f6.2,i8,3x,a22)'
|
|
||||||
endif
|
|
||||||
if(nsps.eq.0) stop 'Error: bad TRperiod' !Better: return an error code###
|
|
||||||
|
|
||||||
fgood=0.
|
|
||||||
df8=1500.0/(nsps/8)
|
|
||||||
sbest=0.
|
|
||||||
|
|
||||||
10 ii=maxloc(ccfred(ia:ib))
|
|
||||||
i=ii(1) + ia - 1
|
|
||||||
f=(i-1)*df3
|
|
||||||
if((i.eq.ipk .or. ccfred(i).ge.3.0) .and. abs(f-fgood).gt.10.0*df8) then
|
|
||||||
call timer('spec9 ',0)
|
|
||||||
call spec9(c0,npts8,nsps,f,fpk,xdt,snr,i1SoftSymbols)
|
|
||||||
call timer('spec9 ',1)
|
|
||||||
|
|
||||||
call timer('decode9 ',0)
|
|
||||||
call decode9(i1SoftSymbols,limit,nlim,msg)
|
|
||||||
call timer('decode9 ',1)
|
|
||||||
|
|
||||||
sync=ccfred(i) - 2.0
|
|
||||||
if(sync.lt.0.0) sync=0.0
|
|
||||||
nsync=sync
|
|
||||||
if(nsync.gt.10) nsync=10
|
|
||||||
nsnr=nint(snr)
|
|
||||||
drift=0.0
|
|
||||||
|
|
||||||
if(ccfred(i).gt.sbest .and. fgood.eq.0.0) then
|
|
||||||
sbest=ccfred(i)
|
|
||||||
write(line,fmt) nutc,nsync,nsnr,xdt,1000.0+fpk,drift
|
|
||||||
if(nsync.gt.0) nsynced=1
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if(msg.ne.' ') then
|
! do i=1,npts
|
||||||
write(13,fmt) nutc,nsync,nsnr,xdt,1000.0+fpk,drift,msg
|
! id2(i)=100.0*sin(6.283185307*1600.0*i/12000.0)
|
||||||
write(14,fmt14) nutc,nsync,nsnr,xdt,1000.0+fpk,drift,nlim,msg
|
! enddo
|
||||||
fgood=f
|
|
||||||
nsynced=1
|
do iblk=1,npts/kstep
|
||||||
ndecoded=1
|
k=iblk*kstep
|
||||||
ccfred(max(ia,i):min(ib,i+8))=0.
|
call timer('read_wav',0)
|
||||||
|
read(10,end=10) id2(k-kstep+1:k)
|
||||||
|
call timer('read_wav',1)
|
||||||
|
|
||||||
|
nhsym=(k-2048)/kstep
|
||||||
|
if(nhsym.ge.1 .and. nhsym.ne.nhsym0) then
|
||||||
|
! Emit signal readyForFFT
|
||||||
|
ingain=0
|
||||||
|
call timer('symspec ',0)
|
||||||
|
call symspec(k,ntrperiod,nsps,ingain,nb,nbslider,pxdb, &
|
||||||
|
s,ccfred,df3,ihsym,nzap,slimit,lstrong,npts8)
|
||||||
|
call timer('symspec ',1)
|
||||||
|
nhsym0=nhsym
|
||||||
|
if(ihsym.ge.184) go to 10
|
||||||
|
endif
|
||||||
|
enddo
|
||||||
|
10 close(10)
|
||||||
|
|
||||||
|
nsps8=nsps/8
|
||||||
|
c1(0:npts8-1)=conjg(c0(1:npts8))
|
||||||
|
call test9(c1,npts8,nsps8)
|
||||||
|
|
||||||
|
iz=1000.0/df3
|
||||||
|
nutc=nutc0
|
||||||
|
|
||||||
|
call timer('sync9 ',0)
|
||||||
|
call sync9(ss,nzhsym,tstep,df3,ntol,nfqso,ccfred,ia,ib,ipk) !Get sync, freq
|
||||||
|
call timer('sync9 ',1)
|
||||||
|
|
||||||
|
fgood=0.
|
||||||
|
df8=1500.0/(nsps/8)
|
||||||
|
sbest=0.
|
||||||
|
do i=ia,ib
|
||||||
|
f=(i-1)*df3
|
||||||
|
if((i.eq.ipk .or. ccfred(i).ge.3.0) .and. f.gt.fgood+10.0*df8) then
|
||||||
|
call timer('spec9 ',0)
|
||||||
|
call spec9(c0,npts8,nsps,f,fpk,xdt,snrdb,i1SoftSymbols)
|
||||||
|
call timer('spec9 ',1)
|
||||||
|
|
||||||
|
call timer('decode9 ',0)
|
||||||
|
call decode9(i1SoftSymbols,limit,nlim,msg)
|
||||||
|
call timer('decode9 ',1)
|
||||||
|
snr=snrdb
|
||||||
|
sync=ccfred(i) - 2.0
|
||||||
|
if(sync.lt.0.0) sync=0.0
|
||||||
|
nsync=sync
|
||||||
|
if(nsync.gt.10) nsync=10
|
||||||
|
nsnr=nint(snr)
|
||||||
|
width=0.0
|
||||||
|
|
||||||
|
if(ccfred(i).gt.sbest .and. fgood.eq.0.0) then
|
||||||
|
sbest=ccfred(i)
|
||||||
|
write(line,1010) nutc,nsync,nsnr,xdt,1000.0+fpk,width
|
||||||
|
if(nsync.gt.0) nsynced=1
|
||||||
|
endif
|
||||||
|
|
||||||
|
if(msg.ne.' ') then
|
||||||
|
write(*,1010) nutc,nsync,nsnr,xdt,1000.0+fpk,width,msg
|
||||||
|
1010 format(i4.4,i4,i5,f6.1,f8.2,f6.2,3x,a22)
|
||||||
|
fgood=f
|
||||||
|
nsynced=1
|
||||||
|
ndecoded=1
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
enddo
|
||||||
|
|
||||||
|
if(fgood.eq.0.0) then
|
||||||
|
write(*,1020) line
|
||||||
|
1020 format(a33)
|
||||||
endif
|
endif
|
||||||
endif
|
|
||||||
ccfred(i)=0.
|
|
||||||
if(maxval(ccfred(ia:ib)).gt.3.0) go to 10
|
|
||||||
|
|
||||||
if(fgood.eq.0.0) then
|
enddo
|
||||||
write(13,1020) line
|
|
||||||
write(14,1020) line
|
|
||||||
1020 format(a33)
|
|
||||||
endif
|
|
||||||
|
|
||||||
call flush(13)
|
call timer('jt9 ',1)
|
||||||
call flush(14)
|
call timer('jt9 ',101)
|
||||||
go to 1
|
! call ftnquit
|
||||||
|
go to 999
|
||||||
|
|
||||||
999 call timer('decoder ',1)
|
998 print*,'Cannot open file:'
|
||||||
call timer('decoder ',101)
|
print*,infile
|
||||||
|
|
||||||
end program jt9test
|
999 end program jt9test
|
||||||
|
@ -99,7 +99,6 @@ subroutine spec9(c0,npts8,nsps,fpk0,fpk,xdt,snrdb,i1SoftSymbols)
|
|||||||
snrdb=db(t) - db(2500.0/df8) - 5.0
|
snrdb=db(t) - db(2500.0/df8) - 5.0
|
||||||
|
|
||||||
m0=3
|
m0=3
|
||||||
ntones=8
|
|
||||||
k=0
|
k=0
|
||||||
do j=1,69
|
do j=1,69
|
||||||
smax=0.
|
smax=0.
|
||||||
|
53
lib/test9.f90
Normal file
53
lib/test9.f90
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
subroutine test9(c0,npts8,nsps8)
|
||||||
|
|
||||||
|
parameter (NMAX=128*864)
|
||||||
|
complex c0(0:npts8-1)
|
||||||
|
complex c1(0:NMAX-1)
|
||||||
|
complex c2(0:4096-1)
|
||||||
|
complex z
|
||||||
|
real p(0:3300)
|
||||||
|
include 'jt9sync.f90'
|
||||||
|
|
||||||
|
c1(0:npts8-1)=c0 !Copy c0 into c1
|
||||||
|
c1(npts8:)=0. !Zero the rest of c1
|
||||||
|
nfft1=NMAX !Forward FFT length
|
||||||
|
call four2a(c1,nfft1,1,-1,1) !Forward FFT
|
||||||
|
|
||||||
|
ndown=54 !Downsample factor
|
||||||
|
nfft2=nfft1/ndown !Backward FFT length
|
||||||
|
nh2=nfft2/2
|
||||||
|
fac=1.e-5
|
||||||
|
c2(0:nh2)=fac*c1(0:nh2)
|
||||||
|
c2(nh2+1:nh2+nh2-1)=fac*c1(nfft1-nh2+1:nfft1-1)
|
||||||
|
call four2a(c2,nfft2,1,1,1) !Backward FFT
|
||||||
|
|
||||||
|
nspsd=nsps8/ndown
|
||||||
|
nz=npts8/ndown
|
||||||
|
p=0.
|
||||||
|
i0=5*nspsd
|
||||||
|
do i=0,nz-1
|
||||||
|
z=sum(c2(max(i-(nspsd-1),0):i)) !Integrate
|
||||||
|
p(i0+i)=real(z)**2 + aimag(z)**2 !Symbol power at freq=0
|
||||||
|
! write(51,3001) i,p(i)
|
||||||
|
enddo
|
||||||
|
|
||||||
|
iz=85*nspsd
|
||||||
|
fac0=1.0/69.0
|
||||||
|
fac1=1.0/16.0
|
||||||
|
lagmax=13*nspsd
|
||||||
|
do lag=0,lagmax
|
||||||
|
ss=0.
|
||||||
|
do i=0,iz-1
|
||||||
|
if(isync(1+i/nspsd).eq.1) then
|
||||||
|
ss=ss + fac1*p(i+lag) !Add the sync powers
|
||||||
|
else
|
||||||
|
ss=ss - fac0*p(i+lag) !Subtract the non-sync powers
|
||||||
|
endif
|
||||||
|
enddo
|
||||||
|
write(52,3001) lag,ss
|
||||||
|
3001 format(i5,f12.3)
|
||||||
|
enddo
|
||||||
|
|
||||||
|
return
|
||||||
|
end subroutine test9
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
//---------------------------------------------------------------- MainWindow
|
//--------------------------------------------------------------- MainWindow
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
#include "devsetup.h"
|
#include "devsetup.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user