From 8fbb6bac794d7b1b28996a108322cb11d1d8d300 Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Fri, 5 Oct 2012 17:13:21 +0000 Subject: [PATCH] Many changes. Waterfall plots now pretty much OK. (May want to limit displayed range to 1000 Hz.) Noise blanking may be working -- needs tests. Tx has been implemented. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@2648 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- lib/symspec.f90 | 4 +-- lib/timf2.f90 | 36 ++++++++++++++---------- mainwindow.cpp | 16 ++++++----- mainwindow.h | 2 +- plotter.cpp | 2 +- soundin.cpp | 6 ++-- soundout.cpp | 73 +++++++++++++++++++++++++++++++++++++------------ soundout.h | 2 +- 8 files changed, 95 insertions(+), 46 deletions(-) diff --git a/lib/symspec.f90 b/lib/symspec.f90 index 4269c8be8..3f9279742 100644 --- a/lib/symspec.f90 +++ b/lib/symspec.f90 @@ -70,7 +70,7 @@ subroutine symspec(k,ntrperiod,nsps,ndiskdat,nb,nbslider,pxdb,s,f0a,df3, & k0=k nzap=0 - sigmas=1.5*(10.0**(0.01*nbslider)) + 0.7 + sigmas=1.0*(10.0**(0.01*nbslider)) + 0.7 peaklimit=sigmas*max(10.0,rms) faclim=3.0 px=0. @@ -104,7 +104,7 @@ subroutine symspec(k,ntrperiod,nsps,ndiskdat,nb,nbslider,pxdb,s,f0a,df3, & !### ! if(nzap/178.lt.50 .and. (ndiskdat.eq.0 .or. ihsym.lt.280)) then if(nsum.le.0) nsum=1 - rms=sqrt(0.5*px/nsum) + rms=sqrt(px/nsum) ! endif pxdb=0. if(rms.gt.0.0) pxdb=20.0*log10(rms) diff --git a/lib/timf2.f90 b/lib/timf2.f90 index 04c0d61a0..13973535e 100644 --- a/lib/timf2.f90 +++ b/lib/timf2.f90 @@ -66,22 +66,30 @@ subroutine timf2(x0,k,nfft,nwindow,nb,peaklimit,faclim,x1, & cxt(0:nh)=cx(0:nh) ! Identify frequencies with strong signals. - - ntot=ntot+1 - if(mod(ntot,128).eq.5) then - call pctile(s,stmp,nh,50,xmedian) - slimit=faclim*xmedian - endif - - if(ntc.lt.12000/nfft) ntc=ntc+1 - uu=1.0/ntc - smax=0. +!### do i=0,nh p=real(cxt(i))**2 + aimag(cxt(i))**2 - s(i)=(1.0-uu)*s(i) + uu*p - lstrong(i)=(s(i).gt.slimit) - if(s(i).gt.smax) smax=s(i) + s(i)=p enddo + ave=sum(s(0:nh))/nh + lstrong(0:nh)=s(0:nh).gt.10.0*ave +!### + +! ntot=ntot+1 +! if(mod(ntot,128).eq.5) then +! call pctile(s,stmp,nh,50,xmedian) +! slimit=faclim*xmedian +! endif + +! if(ntc.lt.12000/nfft) ntc=ntc+1 +! uu=1.0/ntc +! smax=0. +! do i=0,nh +! p=real(cxt(i))**2 + aimag(cxt(i))**2 +! s(i)=(1.0-uu)*s(i) + uu*p +! lstrong(i)=(s(i).gt.slimit) +! if(s(i).gt.smax) smax=s(i) +! enddo nsigs=0 lprev=.false. @@ -146,7 +154,7 @@ subroutine timf2(x0,k,nfft,nwindow,nb,peaklimit,faclim,x1, & ! Compute power levels from weak data only do i=0,kstep-1 - px=px + xw(i)*xw(i) + px=px + xw(i)**2 enddo x1(0:kstep-1)=xw(0:kstep-1) + xs(0:kstep-1) !Recombine weak + strong diff --git a/mainwindow.cpp b/mainwindow.cpp index 5a1d8c25b..de71d08ec 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -8,7 +8,7 @@ #include "sleep.h" #include -short int iwave[30*48000]; //Wave file for Tx audio +int itone[85]; //Tx audio tones for 85 symbols int nwave; //Length of Tx waveform bool btxok; //True if OK to transmit double outputLatency; //Latency in seconds @@ -675,7 +675,7 @@ void MainWindow::on_actionOpen_triggered() //Open File m_diskData=true; int dbDgrd=0; *future1 = QtConcurrent::run(getfile, fname, m_TRperiod); - watcher1->setFuture(*future1); + watcher1->setFuture(*future1); // call diskDat() when done } } @@ -848,7 +848,8 @@ void MainWindow::guiUpdate() int khsym=0; double tx1=0.0; - double tx2=m_TRperiod; +// double tx2=m_TRperiod; + double tx2=1.0 + 85.0*m_nsps/12000.0; if(!m_txFirst) { tx1 += m_TRperiod; @@ -892,8 +893,9 @@ void MainWindow::guiUpdate() ba2msg(ba,message); ba2msg(ba,msgsent); - int len1=28; -// genjt9_(message,iwave,&nwave,len1); + int len1=22; + int len2=22; + genjt9_(message,&m_TRperiod,msgsent,itone,len1,len2); if(m_restart) { QFile f("wsjtx_tx.log"); f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append); @@ -983,7 +985,7 @@ void MainWindow::guiUpdate() ui->labUTC->setText(utc); if(!m_monitoring and !m_diskData) { ui->xThermo->setValue(0.0); // Set Rx level to 20 - lab2->setText(" Rx noise: 0.0 "); +// lab4->setText(" Rx noise: 0.0 "); } m_hsym0=khsym; m_sec0=nsec; @@ -1362,7 +1364,7 @@ void MainWindow::on_actionJT9_30_triggered() { m_mode="JT9-30"; m_TRperiod=1800; - m_nsps=250880; + m_nsps=252000; soundInThread.setPeriod(m_TRperiod,m_nsps); soundOutThread.setPeriod(m_TRperiod,m_nsps); g_pWideGraph->setPeriod(m_TRperiod,m_nsps); diff --git a/mainwindow.h b/mainwindow.h index 3c7b75e98..52c359f60 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -221,7 +221,7 @@ void symspec_(int* k, int* ntrperiod, int* nsps, int* ndiskdat, int* nb, int* m_NBslider, float* px, float s[], float* f0a, float* df3, int* nhsym, int* nzap, float* slimit, uchar lstrong[]); -void genJT9_(char* msg, char* msgsent, short itone[], int* nsym, +void genjt9_(char* msg, int* minutes, char* msgsent, int itone[], int len1, int len2); int ptt_(int* nport, int* itx, int* iptt); } diff --git a/plotter.cpp b/plotter.cpp index 5d4199be7..68fffcbc1 100644 --- a/plotter.cpp +++ b/plotter.cpp @@ -142,7 +142,7 @@ void CPlotter::draw(float swide[], int i0, float splot[]) //draw() m_line++; if(m_line == 13) { UTCstr(); - painter1.setPen(Qt::white); + painter1.setPen(Qt::red); painter1.drawText(5,10,m_sutc); } update(); //trigger a new paintEvent diff --git a/soundin.cpp b/soundin.cpp index a69253b9e..7e6cc7ff8 100644 --- a/soundin.cpp +++ b/soundin.cpp @@ -138,13 +138,15 @@ void SoundInThread::run() //SoundInThread::run() k=udata.kin; if(m_monitoring) { int kstep=m_nsps/2; - m_step=k/kstep; +// m_step=k/kstep; + m_step=(k-1)/kstep; if(m_step != nstep0) { if(m_dataSinkBusy) { nBusy++; } else { // m_dataSinkBusy=true; - emit readyForFFT(k); //Signal to compute new FFTs +// emit readyForFFT(k); //Signal to compute new FFTs + emit readyForFFT(k-1); //Signal to compute new FFTs } nstep0=m_step; } diff --git a/soundout.cpp b/soundout.cpp index 480ee1f1a..d394505e1 100644 --- a/soundout.cpp +++ b/soundout.cpp @@ -7,14 +7,16 @@ extern "C" { } extern float gran(); //Noise generator (for tests only) -extern short int iwave[120*12000]; //Wave file for Tx audio -extern int nwave; -extern bool btxok; +extern int itone[85]; //Tx audio tones for 85 symbols extern double outputLatency; typedef struct //Parameters sent to or received from callback function { - int dummy; + int nsps; + int ntrperiod; + bool txOK; + bool txMute; + bool bRestart; } paUserData; //--------------------------------------------------------------- d2aCallback @@ -26,20 +28,50 @@ extern "C" int d2aCallback(const void *inputBuffer, void *outputBuffer, { paUserData *udata=(paUserData*)userData; short *wptr = (short*)outputBuffer; - unsigned int i; - static int ic=0; - for(i=0 ; i nwave) i2=0; + static double twopi=6.283185307; + static double baud=12000.0/udata->nsps; + static double phi=0.0; + static double dphi; + static double freq; + static int ic=0; + static short int i2; + + if(udata->bRestart) { + // Time according to this computer + qint64 ms = QDateTime::currentMSecsSinceEpoch() % 86400000; + int mstr = ms % (1000*udata->ntrperiod ); + if(mstr<1000) return 0; + ic=(mstr-1000)*12; + qDebug() << "Start at:" << 0.001*mstr; + udata->bRestart=false; + } + int isym=ic/udata->nsps; + if(isym>=85) return 0; + freq=1500.0 + itone[isym]*baud; + dphi=twopi*freq/12000.0; +/* + if(ic<10000) qDebug() << "a" << ic << udata->nsps << itone[0] + << itone[1] << itone[2] << itone[3] << itone[4] + << itone[5] << itone[6] << itone[7] << itone[8] + << itone[9] << itone[10] << itone[11] << itone[12] + << itone[13] << itone[14] << itone[15] << itone[16]; + */ +// qDebug() << ic << isym << freq << dphi << phi << i2; + + for(int i=0 ; itwopi) phi -= twopi; + i2=32767.0*sin(phi); // i2 = 500.0*(i2/32767.0 + 5.0*gran()); //Add noise (tests only!) - if(!btxok) i2=0; + /* + if(udata->txMute) i2=0; + if(!udata->txOK) i2=0; + if(ic > 85*udata->nsps) i2=0; + */ *wptr++ = i2; //left ic++; } - if(ic >= nwave) { - ic=0; - } return 0; } @@ -64,8 +96,11 @@ void SoundOutThread::run() return; } -// udata.nwave=m_nwave; -// udata.btxok=false; + udata.nsps=m_nsps; + udata.ntrperiod=m_TRperiod; + udata.txOK=false; + udata.txMute=m_txMute; + udata.bRestart=true; paerr=Pa_OpenStream(&outStream, //Output stream NULL, //No input parameters @@ -89,9 +124,11 @@ void SoundOutThread::run() while (!qe) { qe = quitExecution; if (qe) break; -// udata.nwave=m_nwave; -// if(m_txOK) udata.btxok=1; -// if(!m_txOK) udata.btxok=0; + + udata.nsps=m_nsps; + udata.ntrperiod=m_TRperiod; + udata.txOK=m_txOK; + udata.txMute=m_txMute; msleep(100); } Pa_StopStream(outStream); diff --git a/soundout.h b/soundout.h index 9c5013406..546c23ad4 100644 --- a/soundout.h +++ b/soundout.h @@ -33,7 +33,7 @@ private: qint32 m_nDevOut; //Output device number bool m_txOK; //Enable Tx audio bool m_txMute; //Mute temporarily - qint32 m_TRperiod; //T/R period (30 or 60 s) + qint32 m_TRperiod; //T/R period (s) qint32 m_nsps; //Samples per symbol (at 12000 Hz) };