From b689f177fe980006dbeebc5573a32b31e8210ddd Mon Sep 17 00:00:00 2001 From: Joe Taylor <k1jt@arrl.org> Date: Fri, 31 Aug 2012 18:29:54 +0000 Subject: [PATCH] Tx may now be correct for B2, C2 modes. Still working on decoder. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/map65@2548 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- libm65/decode0.f90 | 2 +- libm65/gen65.f90 | 6 +++--- libm65/m65.f90 | 28 ++++++++++++++++------------ libm65/map65a.f90 | 2 +- libm65/mapsim.f90 | 8 ++++---- mainwindow.cpp | 16 +++++++++++----- mainwindow.h | 5 +++-- soundout.cpp | 12 +++++------- 8 files changed, 44 insertions(+), 35 deletions(-) diff --git a/libm65/decode0.f90 b/libm65/decode0.f90 index e0c8deed2..1fe773e53 100644 --- a/libm65/decode0.f90 +++ b/libm65/decode0.f90 @@ -54,7 +54,7 @@ subroutine decode0(dd,ss,savg,nstandalone) call map65a(dd,ss,savg,newdat,nutc,fcenter,ntol,idphi,nfa,nfb, & mousedf,mousefqso,nagain,ndecdone,ndiskdat,nfshift,ndphi, & nfcal,nkeep,mcall3b,nsum,nsave,nxant,rmsdd,mycall,mygrid, & - neme,ndepth,hiscall,hisgrid,nhsym,nfsample,nxpol,mode65) + neme,ndepth,hiscall,hisgrid,nhsym,nfsample,nxpol,mode65,nfast) call timer('map65a ',1) call timer('decode0 ',1) diff --git a/libm65/gen65.f90 b/libm65/gen65.f90 index 92c45e7fe..87944305e 100644 --- a/libm65/gen65.f90 +++ b/libm65/gen65.f90 @@ -1,4 +1,4 @@ -subroutine gen65(message,mode65,samfac,nsendingsh,msgsent,iwave,nwave) +subroutine gen65(message,mode65,nfast,samfac,nsendingsh,msgsent,iwave,nwave) ! Encodes a JT65 message into a wavefile. ! Executes in 17 ms on opti-745. @@ -41,9 +41,9 @@ subroutine gen65(message,mode65,samfac,nsendingsh,msgsent,iwave,nwave) call interleave63(sent,1) !Apply interleaving call graycode(sent,63,1) !Apply Gray code nsym=126 !Symbols per transmission - nsps=4096 + nsps=4096/nfast else - nsym=32 + nsym=32/nfast nsps=16384 nsendingsh=1 !Flag for shorthand message endif diff --git a/libm65/m65.f90 b/libm65/m65.f90 index e963745a1..c8f508ee9 100644 --- a/libm65/m65.f90 +++ b/libm65/m65.f90 @@ -20,12 +20,12 @@ program m65 nfast,nsave,mycall,mygrid,hiscall,hisgrid,datetime nargs=iargc() - if(nargs.lt.1) then - print*,'Usage: m65 [95238] file1 [file2 ...]' - print*,' Reads data from *.tf2 files.' + if(nargs.lt.1 .or. nargs.eq.2) then + print*,'Usage: m65 <submode> <95238|96000> file1 [file2 ...]' + print*,' (Reads data from *.tf2 files.)' print*,'' print*,' m65 -s' - print*,' Gets data from shared memory region.' + print*,' (Gets data from MAP65, via shared memory region.)' go to 999 endif call getarg(1,arg) @@ -34,16 +34,20 @@ program m65 call ftnquit go to 999 endif + if(arg(1:1).eq.'A') mode65=1 + if(arg(1:1).eq.'B') mode65=2 + if(arg(1:1).eq.'C') mode65=4 + nfast=1 + if(arg(2:2).eq.'2') nfast=2 nfsample=96000 - nxpol=1 - mode65=2 - ifile1=1 + call getarg(2,arg) if(arg.eq.'95238') then nfsample=95238 - call getarg(2,arg) - ifile1=2 + call getarg(3,arg) endif + nxpol=1 + ifile1=3 limtrace=0 lu=12 nfa=100 @@ -69,7 +73,7 @@ program m65 k=0 fcenter=144.125d0 mousedf=0 - mousefqso=125 + mousefqso=126 newdat=1 mycall='K1JT' @@ -95,8 +99,8 @@ program m65 ! Emit signal readyForFFT call timer('symspec ',0) fgreen=-13.0 - iqadjust=1 - iqapply=1 + iqadjust=0 + iqapply=0 nbslider=100 gainx=0.9962 gainy=1.0265 diff --git a/libm65/map65a.f90 b/libm65/map65a.f90 index 21694d4a5..7e54e0bb7 100644 --- a/libm65/map65a.f90 +++ b/libm65/map65a.f90 @@ -1,7 +1,7 @@ subroutine map65a(dd,ss,savg,newdat,nutc,fcenter,ntol,idphi,nfa,nfb, & mousedf,mousefqso,nagain,ndecdone,ndiskdat,nfshift,ndphi, & nfcal,nkeep,mcall3b,nsum,nsave,nxant,rmsdd,mycall,mygrid, & - neme,ndepth,hiscall,hisgrid,nhsym,nfsample,nxpol,mode65) + neme,ndepth,hiscall,hisgrid,nhsym,nfsample,nxpol,mode65,nfast) ! Processes timf2 data from Linrad to find and decode JT65 signals. diff --git a/libm65/mapsim.f90 b/libm65/mapsim.f90 index 7da83ac07..547bbed4c 100644 --- a/libm65/mapsim.f90 +++ b/libm65/mapsim.f90 @@ -57,8 +57,8 @@ program mapsim open(12,file='msgs.txt',status='old') write(*,1000) -1000 format(' N freq S/N pol Message'/ & - '-----------------------------------------------') +1000 format('File N freq S/N pol Message'/ & + '---------------------------------------------------') do ifile=1,nfiles nmin=ifile-1 @@ -93,8 +93,8 @@ program mapsim snrdbx=snrdb if(snrdb.ge.-1.0) snrdbx=-15.0 - 15.0*(isig-1.0)/nsigs sig=sqrt(2.2*2500.0/96000.0) * 10.0**(0.05*snrdbx) - write(*,1020) isig,0.001*f,snrdbx,nint(pol),msgsent -1020 format(i3,f8.3,f7.1,i5,2x,a22) + write(*,1020) ifile,isig,0.001*f,snrdbx,nint(pol),msgsent +1020 format(i3,i4,f8.3,f7.1,i5,2x,a22) phi=0. i0=fsample*(3.5d0+0.05d0*(isig-1)) diff --git a/mainwindow.cpp b/mainwindow.cpp index 97a26141c..0475a63cb 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1354,7 +1354,7 @@ void MainWindow::guiUpdate() int khsym=0; double tx1=0.0; - double tx2=126.0*4096.0/11025.0 + 1.8; //### depend on TxDelay? ### + double tx2=126.0*4096.0/(m_nfast*11025.0) + 1.8; //### depend on TxDelay? if(!m_txFirst) { tx1 += m_TRperiod; @@ -1363,8 +1363,8 @@ void MainWindow::guiUpdate() qint64 ms = QDateTime::currentMSecsSinceEpoch() % 86400000; int nsec=ms/1000; double tsec=0.001*ms; - double t120=fmod(tsec,120.0); - bool bTxTime = t120 >= tx1 && t120 < tx2; + double t2p=fmod(tsec,120.0/m_nfast); + bool bTxTime = t2p >= tx1 && t2p < tx2; if(m_auto) { if(bTxTime and iptt==0 and !m_txMute) { @@ -1399,9 +1399,11 @@ void MainWindow::guiUpdate() ba2msg(ba,message); int len1=22; int mode65=m_mode65; + int nfast=m_nfast; double samfac=1.0; - gen65_(message,&mode65,&samfac,&nsendingsh,msgsent,iwave,&nwave,len1,len1); + gen65_(message,&mode65,&nfast,&samfac,&nsendingsh,msgsent,iwave, + &nwave,len1,len1); msgsent[22]=0; if(m_restart) { @@ -1819,7 +1821,9 @@ void MainWindow::msgtype(QString t, QLineEdit* tx) //msgtype() int i1=t.indexOf(" OOO"); QByteArray s=t.toUpper().toLocal8Bit(); ba2msg(s,message); - gen65_(message,&mode65,&samfac,&nsendingsh,msgsent,iwave,&mwave,len1,len1); + int nfast=m_nfast; + gen65_(message,&mode65,&nfast,&samfac,&nsendingsh,msgsent,iwave, + &mwave,len1,len1); QPalette p(tx->palette()); if(nsendingsh==1) { @@ -1990,6 +1994,7 @@ void MainWindow::on_actionJT65B2_triggered() m_nfast=2; m_TRperiod=30; soundInThread.setPeriod(m_TRperiod); + soundOutThread.setPeriod(m_TRperiod); g_pWideGraph->setMode65(m_mode65); lab5->setText(m_mode); ui->actionJT65B2->setChecked(true); @@ -2002,6 +2007,7 @@ void MainWindow::on_actionJT65C2_triggered() m_nfast=2; m_TRperiod=30; soundInThread.setPeriod(m_TRperiod); + soundOutThread.setPeriod(m_TRperiod); g_pWideGraph->setMode65(m_mode65); lab5->setText(m_mode); ui->actionJT65C2->setChecked(true); diff --git a/mainwindow.h b/mainwindow.h index d5b8f7ea5..a68effa3f 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -274,8 +274,9 @@ extern "C" { float* py, float s[], int* nkhz, int* nhsym, int* nzap, float* slimit, uchar lstrong[]); - void gen65_(char* msg, int* mode65, double* samfac, int* nsendingsh, - char* msgsent, short iwave[], int* nwave, int len1, int len2); + void gen65_(char* msg, int* mode65, int* nfast, double* samfac, + int* nsendingsh, char* msgsent, short iwave[], int* nwave, + int len1, int len2); int ptt_(int* nport, int* itx, int* iptt); } diff --git a/soundout.cpp b/soundout.cpp index f0101ce2f..780147fa6 100644 --- a/soundout.cpp +++ b/soundout.cpp @@ -30,7 +30,7 @@ extern "C" int d2aCallback(const void *inputBuffer, void *outputBuffer, unsigned int i,n; static int ic=0; static bool btxok0=false; - static int nminStart=0; + static int nStart=0; double tsec,tstart; int nsec; int nTRperiod=udata->nTRperiod; @@ -45,12 +45,12 @@ extern "C" int d2aCallback(const void *inputBuffer, void *outputBuffer, tstart=tsec - n*nTRperiod - 1.0; if(tstart<1.0) { - ic=0; //Start of minute, set starting index to 0 - nminStart=n; + ic=0; //Start of Tx cycle, set starting index to 0 + nStart=n; } else { - if(n != nminStart) { //Late start in new minute: compute starting index + if(n != nStart) { //Late start in new Tx cycle: compute starting index ic=(int)(tstart*11025.0); - nminStart=n; + nStart=n; } } } @@ -95,14 +95,12 @@ void SoundOutThread::run() outParam.hostApiSpecificStreamInfo=NULL; udata.nTRperiod=m_TRperiod; - paerr=Pa_IsFormatSupported(NULL,&outParam,11025.0); if(paerr<0) { qDebug() << "PortAudio says requested output format not supported."; qDebug() << paerr; return; } - paerr=Pa_OpenStream(&outStream, //Output stream NULL, //No input parameters &outParam, //Output parameters