Much code cleanup: remove unised variables and code.

Include # channels in audio device offerings.
Start implementing "msgsent" correctly.  (Not finished!)
Include Date in UTC display.
Use the properly computer snrdb.


git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@2718 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Joe Taylor 2012-11-12 16:33:45 +00:00
parent 508009db5e
commit 5d030bd413
17 changed files with 47 additions and 112 deletions

View File

@ -13,7 +13,6 @@ extern struct {
int ndiskdat; //1 ==> data read from *.wav file
int ntrperiod; //TR period (seconds)
int nfqso; //User-selected QSO freq (kHz)
int nagain; //1 ==> decode only at fQSO +/- Tol
int newdat; //1 ==> new data, must do long FFT
int npts8; //npts for c0() array
int nfb; //High decode limit (kHz)

View File

@ -8,7 +8,7 @@
//----------------------------------------------------------- DevSetup()
DevSetup::DevSetup(QWidget *parent) : QDialog(parent)
{
ui.setupUi(this); //setup the dialog form
ui.setupUi(this); //setup the dialog form
m_restartSoundIn=false;
m_restartSoundOut=false;
}
@ -30,26 +30,11 @@ void DevSetup::initDlg()
char pa_device_name[128];
char pa_device_hostapi[128];
/*
getDev(&numDevices,hostAPI_DeviceName,minChan,maxChan,minSpeed,maxSpeed);
k=0;
for(id=0; id<numDevices; id++) {
if(48000 >= minSpeed[id] && 48000 <= maxSpeed[id]) {
m_inDevList[k]=id;
k++;
sprintf(s,"%2d %d %-49s",id,maxChan[id],hostAPI_DeviceName[id]);
QString t(s);
ui.comboBoxSndIn->addItem(t);
valid_devices++;
}
}
*/
k=0;
for(id=0; id<numDevices; id++ ) {
pdi=Pa_GetDeviceInfo(id);
nchin=pdi->maxInputChannels;
if(nchin>=2) {
if(nchin>0) {
m_inDevList[k]=id;
k++;
sprintf((char*)(pa_device_name),"%s",pdi->name);
@ -68,7 +53,7 @@ void DevSetup::initDlg()
p=strstr(pa_device_hostapi,"WDM-KS");
if(p!=NULL) p1=(char*)"WDM-KS";
sprintf(p2,"%2d %-8s %-39s",id,p1,pa_device_name);
sprintf(p2,"%2d %d %-8s %-39s",id,nchin,p1,pa_device_name);
QString t(p2);
ui.comboBoxSndIn->addItem(t);
}
@ -78,7 +63,7 @@ void DevSetup::initDlg()
for(id=0; id<numDevices; id++ ) {
pdi=Pa_GetDeviceInfo(id);
nchout=pdi->maxOutputChannels;
if(nchout>=2) {
if(nchout>0) {
m_outDevList[k]=id;
k++;
sprintf((char*)(pa_device_name),"%s",pdi->name);
@ -97,7 +82,7 @@ void DevSetup::initDlg()
p=strstr(pa_device_hostapi,"WDM-KS");
if(p!=NULL) p1=(char*)"WDM-KS";
sprintf(p2,"%2d %-8s %-39s",id,p1,pa_device_name);
sprintf(p2,"%2d %d %-8s %-39s",id,nchout,p1,pa_device_name);
QString t(p2);
ui.comboBoxSndOut->addItem(t);
}

View File

@ -29,7 +29,7 @@
<x>10</x>
<y>34</y>
<width>421</width>
<height>216</height>
<height>221</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
@ -320,6 +320,13 @@
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_8">
<property name="text">
<string> Dev Ch API Name</string>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>

View File

@ -6,7 +6,6 @@
#include "commons.h"
void getfile(QString fname, int ntrperiod);
void savetf2(QString fname, int ntrperiod);
float gran();
int ptt(int* nport, int* ntx, int* iptt);

View File

@ -1,8 +1,6 @@
subroutine decoder(ntrSeconds,ndepth,nRxLog,c00)
! 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.
! Decoder for JT9.
! NB: For unknown reason, ***MUST*** be compiled by g95 with -O0 !!!
parameter (NMAX=1800*12000) !Total sample intervals per 30 minutes
@ -15,7 +13,7 @@ subroutine decoder(ntrSeconds,ndepth,nRxLog,c00)
integer*2 id2
complex c0(NDMAX),c00(NDMAX)
common/jt9com/ss0(184,NSMAX),savg(NSMAX),id2(NMAX),nutc0,ndiskdat, &
ntr,nfqso,nagain,newdat,npts80,nfb,ntol,kin,nsynced,ndecoded
ntr,nfqso,newdat,npts80,nfb,ntol,kin,nsynced,ndecoded
common/jt9comB/ss(184,NSMAX),c0
logical first
data first/.true./
@ -55,12 +53,10 @@ subroutine decoder(ntrSeconds,ndepth,nRxLog,c00)
endif
if(nsps.eq.0) stop 'Error: bad TRperiod' !Better: return an error code###
! Now do the decoding
kstep=nsps/2
tstep=kstep/12000.0
! Get sync, approx freq
call sync9(ss,tstep,df3,ntol,nfqso,ccfred,ia,ib,ipk)
call sync9(ss,tstep,df3,ntol,nfqso,ccfred,ia,ib,ipk) ! Get sync, approx freq
open(13,file='decoded.txt',status='unknown')
rewind 13
@ -81,7 +77,8 @@ subroutine decoder(ntrSeconds,ndepth,nRxLog,c00)
if((i.eq.ipk .or. ccfred(i).ge.3.0) .and. f.gt.fgood+10.0*df8) then
call spec9(c0,npts8,nsps,f,fpk,xdt,snrdb,i1SoftSymbols)
call decode9(i1SoftSymbols,limit,nlim,msg)
snr=10.0*log10(ccfred(i)) - 10.0*log10(2500.0/df3) + 2.0
! snr=10.0*log10(ccfred(i)) - 10.0*log10(2500.0/df3) + 2.0
snr=snrdb
sync=ccfred(i) - 2.0
if(sync.lt.0.0) sync=0.0
nsync=sync

View File

@ -23,6 +23,7 @@ subroutine genjt9(message,msgsent,i4tone)
call packmsg(message,i4Msg6BitWords) !Pack message into 12 6-bit bytes
call unpackmsg(i4Msg6BitWords,msgsent) !Unpack to get msgsent
if(i4tone(1).eq.-99) go to 999
call entail(i4Msg6BitWords,i1Msg8BitBytes) !Add tail, convert to 8-bit bytes
nsym2=206
call encode232(i1Msg8BitBytes,nsym2,i1EncodedBits) !Encode K=32, r=1/2
@ -41,5 +42,5 @@ subroutine genjt9(message,msgsent,i4tone)
endif
enddo
return
999 return
end subroutine genjt9

View File

@ -19,7 +19,7 @@ program jt9
integer*2 id2
complex c0(NDMAX)
common/jt9com/ss(184,NSMAX),savg(NSMAX),id2(NMAX),nutc,ndiskdat, &
ntr,mousefqso,nagain,newdat,nfa,nfb,ntol,kin
ntr,mousefqso,newdat,nfa,nfb,ntol,kin
nargs=iargc()
if(nargs.lt.1) then

View File

@ -74,7 +74,7 @@ subroutine m65c(dd,ss,savg,nparams0)
character*12 mycall,hiscall
character*6 mygrid,hisgrid
character*20 datetime
common/npar/fcenter,nutc,idphi,mousedf,mousefqso,nagain, &
common/npar/fcenter,nutc,idphi,mousedf,mousefqso, &
ndepth,ndiskdat,neme,newdat,nfa,nfb,nfcal,nfshift, &
mcall3,nkeep,ntol,nxant,nrxlog,nfsample,nxpol,mode65, &
mycall,mygrid,hiscall,hisgrid,datetime

View File

@ -1,19 +1,11 @@
integer ii(16) !Locations of sync symbols
! data ii/1,6,11,16,21,26,31,39,45,51,57,63,69,75,81,85/
data ii/ 1,2,5,10,16,23,33,35,51,52,55,60,66,73,83,85/
integer ii2(16) !Locations of sync half-symbols
! data ii2/1,11,21,31,41,51,61,77,89,101,113,125,137,149,161,169/
integer ii2(16) !Locations of sync half-symbols
data ii2/1,3,9,19,31,45,65,69,101,103,109,119,131,145,165,169/
integer isync(85) !Sync vector
! data isync/ &
! 1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0, &
! 1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,1,0, &
! 0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0, &
! 0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0, &
! 1,0,0,0,1/
data isync/ &
1,1,0,0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0, &
0,0,1,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0, &

View File

@ -84,10 +84,9 @@ subroutine spec9(c0,npts8,nsps,fpk0,fpk,xdt,snrdb,i1SoftSymbols)
ave=sum/(69*7)
ssym=ssym/ave
sig=sig/69.
snr=sig/ave
df8=1500.0/nsps8
snrdb=db(snr) - db(2500.0/df8)
! print*,ave,sig,snr,df8,snrdb
t=max(1.0,sig/ave - 1.0)
snrdb=db(t) - db(2500.0/df8)
m0=3
ntones=8

View File

@ -33,7 +33,7 @@ subroutine symspec(k,ntrperiod,nsps,ingain,nb,nbslider,pxdb,s,red, &
integer*2 id2
complex c0(NDMAX)
common/jt9com/ss(184,NSMAX),savg(NSMAX),id2(NMAX),nutc,ndiskdat, &
ntr,mousefqso,nagain,newdat,nfa,nfb,ntol,kin
ntr,mousefqso,newdat,nfa,nfb,ntol,kin
data rms/999.0/,k0/99999999/,ntrperiod0/0/,nfft3z/0/
save

View File

@ -86,13 +86,11 @@ MainWindow::MainWindow(QWidget *parent) :
m_auto=false;
m_waterfallAvg = 1;
m_network = true;
m_txFirst=false;
m_txMute=false;
btxok=false;
m_restart=false;
m_transmitting=false;
m_killAll=false;
m_widebandDecode=false;
m_ntx=1;
m_myCall="K1JT";
@ -322,7 +320,7 @@ void MainWindow::readSettings()
//-------------------------------------------------------------- dataSink()
void MainWindow::dataSink(int k)
{
static float s[NSMAX],red[NSMAX],splot[NSMAX];
static float s[NSMAX],red[NSMAX];
static int n=0;
static int ihsym=0;
static int nzap=0;
@ -354,7 +352,7 @@ void MainWindow::dataSink(int k)
&df3, &ihsym, &nzap, &slimit, lstrong, c0, &npts8);
if(ihsym <=0) return;
QString t;
m_pctZap=nzap/178.3;
m_pctZap=nzap*100.0/m_nsps;
t.sprintf(" Rx noise: %5.1f %5.1f %% ",px,m_pctZap);
lab3->setText(t);
ui->xThermo->setValue((double)px); //Update the thermometer
@ -362,38 +360,11 @@ void MainWindow::dataSink(int k)
g_pWideGraph->dataSink2(s,red,df3,ihsym,m_diskData,lstrong);
}
//Average over specified number of spectra
if (n==0) {
for (int i=0; i<NSMAX; i++)
splot[i]=s[i];
} else {
for (int i=0; i<NSMAX; i++)
splot[i] += s[i];
}
n++;
if (n>=m_waterfallAvg) {
for (int i=0; i<NSMAX; i++) {
splot[i] /= n; //Normalize the average
}
// Time according to this computer
qint64 ms = QDateTime::currentMSecsSinceEpoch() % 86400000;
int ntr = (ms/1000) % m_TRperiod;
if((m_diskData && ihsym <= m_waterfallAvg) || (!m_diskData && ntr<ntr0)) {
for (int i=0; i<NSMAX; i++) {
splot[i] = 1.e30;
}
}
ntr0=ntr;
n=0;
}
// This is a bit strange. Why do we need the "-3" ???
if(ihsym == m_hsymStop-3) {
m_dataAvailable=true;
jt9com_.npts8=(ihsym*m_nsps)/16;
jt9com_.newdat=1;
jt9com_.nagain=0;
QDateTime t = QDateTime::currentDateTimeUtc();
m_dateTime=t.toString("yyyy-MMM-dd hh:mm");
decode(); //Start the decoder
@ -620,7 +591,6 @@ void MainWindow::closeEvent(QCloseEvent*)
void MainWindow::OnExit()
{
g_pWideGraph->saveSettings();
m_killAll=true;
qApp->exit(0); // Exit the event loop
}
@ -731,7 +701,8 @@ void MainWindow::diskDat() //diskDat()
k=(n+1)*kstep;
jt9com_.npts8=k/8;
dataSink(k);
if(n%10 == 1 or n == m_hsymStop) qApp->processEvents(); //Keep GUI responsive
if(n%10 == 1 or n == m_hsymStop)
qApp->processEvents(); //Keep GUI responsive
}
}
@ -839,7 +810,6 @@ void MainWindow::on_DecodeButton_clicked() //Decode request
{
if(!m_decoderBusy) {
jt9com_.newdat=0;
jt9com_.nagain=1;
decode();
}
}
@ -849,7 +819,6 @@ void MainWindow::freezeDecode(int n) //freezeDecode()
static int ntol[] = {1,2,5,10,20,50,100,200,500,1000};
if(!m_decoderBusy) {
jt9com_.newdat=0;
jt9com_.nagain=1;
int i;
if(m_mode=="JT9-1") i=4;
if(m_mode=="JT9-2") i=4;
@ -869,7 +838,7 @@ void MainWindow::decode() //decode()
decodeBusy(true);
ui->DecodeButton->setStyleSheet(m_pbdecoding_style1);
if(jt9com_.nagain==0 && (!m_diskData)) {
if(!m_diskData) {
qint64 ms = QDateTime::currentMSecsSinceEpoch() % 86400000;
int imin=ms/60000;
int ihr=imin/60;
@ -927,7 +896,7 @@ void MainWindow::guiUpdate()
int nsec=ms/1000;
double tsec=0.001*ms;
double t2p=fmod(tsec,2*m_TRperiod);
bool bTxTime = t2p >= tx1 && t2p < tx2;
bool bTxTime = (t2p >= tx1) && (t2p < tx2);
if(m_auto) {
@ -969,10 +938,10 @@ void MainWindow::guiUpdate()
if(m_ntx == 6) ba=ui->tx6->text().toLocal8Bit();
ba2msg(ba,message);
ba2msg(ba,msgsent);
// ba2msg(ba,msgsent);
int len1=22;
int len2=22;
genjt9_(message,msgsent,itone,len1,len2);
genjt9_(message,msgsent,itone,len1,len1);
msgsent[22]=0;
if(m_restart) {
QFile f("wsjtx_tx.log");
f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append);
@ -989,7 +958,7 @@ void MainWindow::guiUpdate()
if(iptt==1 && iptt0==0) nc1=-9; // TxDelay = 0.8 s
if(nc1 <= 0) nc1++;
if(nc1 == 0) {
ui->xThermo->setValue(0.0); //Set the Thermos to zero
ui->xThermo->setValue(0.0); //Set Thermo to zero
m_monitoring=false;
soundInThread.setMonitoring(false);
btxok=true;
@ -1062,7 +1031,8 @@ void MainWindow::guiUpdate()
}
m_setftx=0;
QString utc = " " + t.time().toString() + " ";
QString utc = t.date().toString("yyyy MMM dd") + "\n " +
t.time().toString() + " ";
ui->labUTC->setText(utc);
if(!m_monitoring and !m_diskData) {
ui->xThermo->setValue(0.0);
@ -1340,6 +1310,7 @@ void MainWindow::msgtype(QString t, QLineEdit* tx) //msgtype()
char message[23];
char msgsent[23];
int len1=22;
int jtone[1];
double samfac=1.0;
int nsendingsh=0;
int mwave;
@ -1347,7 +1318,8 @@ 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);
jtone[0]=-99;
genjt9_(message,msgsent,jtone,len1,len1);
nsendingsh=0;
QPalette p(tx->palette());
if(nsendingsh==1) {

View File

@ -1,16 +1,11 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QtGui>
#include <QLabel>
#include <QTimer>
#include <QDateTime>
#include <QHash>
#include "soundin.h"
#include "soundout.h"
#include "commons.h"
#include "sleep.h"
#define NFFT 32768
//--------------------------------------------------------------- MainWindow
namespace Ui {
@ -24,7 +19,6 @@ class MainWindow : public QMainWindow
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
bool m_network;
public slots:
void showSoundInError(const QString& errorMsg);
@ -149,7 +143,6 @@ private:
bool m_auto;
bool m_txMute;
bool m_restart;
bool m_killAll;
bool m_startAnother;
bool m_saveSynced;
bool m_saveDecoded;
@ -159,31 +152,22 @@ private:
bool m_NB;
bool m_call3Modified;
bool m_dataAvailable;
char m_decoded[80];
float m_pctZap;
QRect m_wideGraphGeom;
QLabel* lab1; // labels in status bar
QLabel* lab2;
QLabel* lab3;
QLabel* lab4;
QLabel* lab5;
QLabel* lab6;
QMessageBox msgBox0;
QFuture<void>* future1;
QFuture<void>* future2;
QFuture<void>* future3;
QFutureWatcher<void>* watcher1;
QFutureWatcher<void>* watcher2;
QFutureWatcher<void>* watcher3;
QProcess proc_m65;
QString m_path;
QString m_pbdecoding_style1;
QString m_pbmonitor_style;

View File

@ -491,12 +491,12 @@ p, li { white-space: pre-wrap; }
<property name="maximumSize">
<size>
<width>150</width>
<height>40</height>
<height>60</height>
</size>
</property>
<property name="font">
<font>
<pointsize>20</pointsize>
<pointsize>16</pointsize>
</font>
</property>
<property name="frameShape">
@ -505,6 +505,9 @@ p, li { white-space: pre-wrap; }
<property name="text">
<string> 01:23:45 </string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>

View File

@ -73,8 +73,6 @@ void CPlotter::resizeEvent(QResizeEvent* ) //resizeEvent()
void CPlotter::paintEvent(QPaintEvent *) // paintEvent()
{
static int x00=-99;
if(m_paintEventBusy) return;
m_paintEventBusy=true;
QPainter painter(this);

View File

@ -14,7 +14,6 @@ extern struct {
int ndiskdat; //1 ==> data read from *.wav file
int ntrperiod; //TR period (seconds)
int mousefqso; //User-selected QSO freq (kHz)
int nagain; //1 ==> decode only at fQSO +/- Tol
int newdat; //1 ==> new data, must do long FFT
int npts8; //npts in c0() array
int nfb; //High decode limit (kHz)

View File

@ -1,6 +1,6 @@
[Setup]
AppName=wsjtx
AppVerName=wsjtx Version 0.2 r2713
AppVerName=wsjtx Version 0.3 r2717
AppCopyright=Copyright (C) 2001-2012 by Joe Taylor, K1JT
DefaultDirName=c:\wsjtx
DefaultGroupName=wsjtx