Increase height of status-bar labels.

Compute samfac values; put them into "lab5" (for K1JT only).
Ransomize the rand() seed on SoundOutThread startup.
Increase the DT search range.  (This still needs optimization.)



git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@2724 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Joe Taylor 2012-11-13 20:23:03 +00:00
parent cb697c0ee0
commit 0d58ad7b9c
8 changed files with 69 additions and 19 deletions

View File

@ -3,6 +3,7 @@ subroutine peakdf9(c0,npts8,nsps8,istart,foffset,idfpk)
complex c0(0:npts8-1)
complex zsum
include 'jt9sync.f90'
save
twopi=8.0*atan(1.0)
df=1500.0/nsps8

View File

@ -3,13 +3,16 @@ subroutine peakdt9(c0,npts8,nsps8,istart,foffset,idtpk)
complex c0(0:npts8-1)
complex zsum
include 'jt9sync.f90'
save
twopi=8.0*atan(1.0)
smax=0.
tstep=0.0625*nsps8/1500.0
idtmax=2.5/tstep
f0=foffset
dphi=twopi*f0/1500.0
do idt=-5,5
do idt=-idtmax,idtmax
i0=istart + 0.0625*nsps8*idt
sum=0.
do j=1,16

View File

@ -36,17 +36,15 @@ subroutine spec9(c0,npts8,nsps,fpk0,fpk,xdt,snrdb,i1SoftSymbols)
foffset=fpk0
istart=1520
call peakdf9(c1,npts8,nsps8,istart,foffset,idf)
fpk=fpk0 + idf*0.1*1500.0/nsps8
foffset=foffset + idf*0.1*1500.0/nsps8
call peakdt9(c1,npts8,nsps8,istart,foffset,idt)
istart=istart + 0.0625*nsps8*idt
xdt=istart/1500.0 - 1.0
fshift=foffset
call peakdf9(c1,npts8,nsps8,istart,foffset,idf)
fpk=fpk0 + idf*0.1*1500.0/nsps8
foffset=foffset + idf*0.1*1500.0/nsps8
twopi=8.0*atan(1.0)
dphi=twopi*fshift/1500.0
dphi=twopi*foffset/1500.0
nfft=nsps8
nsym=min((npts8-istart)/nsps8,85)
@ -56,7 +54,12 @@ subroutine spec9(c0,npts8,nsps,fpk0,fpk,xdt,snrdb,i1SoftSymbols)
k=k+1
ia=(j-1)*nsps8 + istart
ib=ia+nsps8-1
c(0:nfft-1)=c1(ia:ib)
! c(0:nfft-1)=c1(ia:ib)
do i=0,nfft-1
c(i)=0.
if(ia+i.ge.0 .and. ia+i.lt.2700000-1) c(i)=c1(ia+i)
enddo
phi=0.
do i=0,nfft-1

View File

@ -547,28 +547,34 @@ void MainWindow::createStatusBar() //createStatusBar
{
lab1 = new QLabel("Receiving");
lab1->setAlignment(Qt::AlignHCenter);
lab1->setMinimumSize(QSize(80,10));
lab1->setMinimumSize(QSize(80,18));
lab1->setStyleSheet("QLabel{background-color: #00ff00}");
lab1->setFrameStyle(QFrame::Panel | QFrame::Sunken);
statusBar()->addWidget(lab1);
lab2 = new QLabel("");
lab2->setAlignment(Qt::AlignHCenter);
lab2->setMinimumSize(QSize(90,10));
lab2->setMinimumSize(QSize(90,18));
lab2->setFrameStyle(QFrame::Panel | QFrame::Sunken);
statusBar()->addWidget(lab2);
lab3 = new QLabel("");
lab3->setAlignment(Qt::AlignHCenter);
lab3->setMinimumSize(QSize(80,10));
lab3->setMinimumSize(QSize(80,18));
lab3->setFrameStyle(QFrame::Panel | QFrame::Sunken);
statusBar()->addWidget(lab3);
lab4 = new QLabel("");
lab4->setAlignment(Qt::AlignHCenter);
lab4->setMinimumSize(QSize(50,10));
lab4->setMinimumSize(QSize(50,18));
lab4->setFrameStyle(QFrame::Panel | QFrame::Sunken);
statusBar()->addWidget(lab4);
lab5 = new QLabel("");
lab5->setAlignment(Qt::AlignHCenter);
lab5->setMinimumSize(QSize(50,18));
lab5->setFrameStyle(QFrame::Panel | QFrame::Sunken);
statusBar()->addWidget(lab5);
}
void MainWindow::on_tolSpinBox_valueChanged(int i) //tolSpinBox
@ -1040,6 +1046,14 @@ void MainWindow::guiUpdate()
}
m_hsym0=khsym;
m_sec0=nsec;
if(m_myCall=="K1JT") {
char s[20];
double t1=soundInThread.samFacIn();
double t2=1.0;
if(soundOutThread.isRunning()) t2=soundOutThread.samFacOut();
sprintf(s,"%6.4f %6.4f",t1,t2);
lab5->setText(s);
}
}
iptt0=iptt;
btxok0=btxok;

View File

@ -27,6 +27,7 @@ extern struct {
typedef struct
{
int kin; //Parameters sent to/from the portaudio callback function
int ncall;
bool bzero;
bool monitoring;
} paUserData;
@ -49,8 +50,7 @@ extern "C" int a2dCallback( const void *inputBuffer, void *outputBuffer,
(void) userData;
int nbytes,k;
// if(framesToProcess != -99) return paContinue; //###
udata->ncall++;
if( (statusFlags&paInputOverflow) != 0) {
qDebug() << "Input Overflow";
}
@ -81,6 +81,7 @@ void SoundInThread::run() //SoundInThread::run()
paUserData udata;
udata.kin=0; //Buffer pointer
udata.ncall=0; //Number of callbacks
udata.bzero=false; //Flag to request reset of kin
udata.monitoring=m_monitoring;
@ -119,13 +120,19 @@ void SoundInThread::run() //SoundInThread::run()
int nBusy=0;
int nstep0=0;
int nsps0=0;
qint64 ms0 = QDateTime::currentMSecsSinceEpoch();
//---------------------------------------------- Soundcard input loop
while (!qe) {
qe = quitExecution;
if (qe) break;
udata.monitoring=m_monitoring;
qint64 ms = QDateTime::currentMSecsSinceEpoch() % 86400000;
qint64 ms = QDateTime::currentMSecsSinceEpoch();
m_SamFacIn=1.0;
if(udata.ncall>100) {
m_SamFacIn=udata.ncall*FRAMES_PER_BUFFER*1000.0/(12000.0*(ms-ms0-50));
}
ms=ms % 86400000;
nsec = ms/1000; // Time according to this computer
ntr = nsec % m_TRperiod;
@ -184,3 +191,8 @@ int SoundInThread::mstep()
{
return m_step;
}
double SoundInThread::samFacIn()
{
return m_SamFacIn;
}

View File

@ -28,6 +28,7 @@ public:
void setMonitoring(bool b);
void setPeriod(int ntrperiod, int nsps);
int mstep();
double samFacIn();
signals:
void readyForFFT(int k);
@ -38,14 +39,13 @@ public slots:
void quit();
private:
bool m_monitoring;
double m_SamFacIn; //(Input sample rate)/12000.0
qint32 m_step;
qint32 m_nDevIn;
qint32 m_TRperiod;
qint32 m_TRperiod0;
qint32 m_nsps;
bool m_monitoring;
};
extern "C" {

View File

@ -16,6 +16,7 @@ typedef struct //Parameters sent to or received from callback function
int nsps;
int ntrperiod;
int ntxfreq;
int ncall;
bool txOK;
bool txMute;
bool bRestart;
@ -39,10 +40,10 @@ extern "C" int d2aCallback(const void *inputBuffer, void *outputBuffer,
static double snr;
static double fac;
static int ic=0;
static int isym0=-99;
static short int i2;
int isym;
udata->ncall++;
if(udata->bRestart) {
// Time according to this computer
qint64 ms = QDateTime::currentMSecsSinceEpoch() % 86400000;
@ -50,6 +51,7 @@ extern "C" int d2aCallback(const void *inputBuffer, void *outputBuffer,
if(mstr<1000) return 0;
ic=(mstr-1000)*48;
udata->bRestart=false;
srand(mstr); //Initialize random seed
}
isym=ic/(4*udata->nsps); //Actual fsample=48000
if(isym>=85) return 1;
@ -108,6 +110,7 @@ void SoundOutThread::run()
udata.nsps=m_nsps;
udata.ntrperiod=m_TRperiod;
udata.ntxfreq=m_txFreq;
udata.ncall=0;
udata.txOK=false;
udata.txMute=m_txMute;
udata.bRestart=true;
@ -129,6 +132,7 @@ void SoundOutThread::run()
const PaStreamInfo* p=Pa_GetStreamInfo(outStream);
outputLatency = p->outputLatency;
bool qe = quitExecution;
qint64 ms0 = QDateTime::currentMSecsSinceEpoch();
//---------------------------------------------- Soundcard output loop
while (!qe) {
@ -141,6 +145,12 @@ void SoundOutThread::run()
udata.ntxfreq=m_txFreq;
udata.txOK=m_txOK;
udata.txMute=m_txMute;
m_SamFacOut=1.0;
if(udata.ncall>400) {
qint64 ms = QDateTime::currentMSecsSinceEpoch();
m_SamFacOut=udata.ncall*FRAMES_PER_BUFFER*1000.0/(48000.0*(ms-ms0-50));
}
msleep(100);
}
Pa_StopStream(outStream);
@ -169,3 +179,8 @@ void SoundOutThread::setTxSNR(double snr)
{
m_txsnrdb=snr;
}
double SoundOutThread::samFacOut()
{
return m_SamFacOut;
}

View File

@ -28,11 +28,13 @@ public:
void setPeriod(int ntrperiod, int nsps);
void setTxFreq(int n);
void setTxSNR(double snr);
double samFacOut();
bool quitExecution; //If true, thread exits gracefully
// Private members
private:
double m_txsnrdb; //if < 0, add noise to Tx audio
double m_SamFacOut; //(Output sample rate)/48000.0
qint32 m_nDevOut; //Output device number
qint32 m_TRperiod; //T/R period (s)
qint32 m_nsps; //Samples per symbol (at 12000 Hz)