diff --git a/commons.h b/commons.h index 6e151a2a9..ed1c95d98 100644 --- a/commons.h +++ b/commons.h @@ -6,40 +6,9 @@ extern "C" { extern struct { //This is "common/datcom/..." in Fortran - float d2[30*48000]; //Raw data + short int d2[30*48000]; //Raw data int kin; int ndiskdat; - /* - float ss[4*322*NFFT]; //Half-symbol spectra at 0,45,90,135 deg pol - float savg[4*NFFT]; //Avg spectra at 0,45,90,135 deg pol - double fcenter; //Center freq from Linrad (MHz) - int nutc; //UTC as integer, HHMM - int idphi; //Phase correction for Y pol'n, degrees - int mousedf; //User-selected DF - int mousefqso; //User-selected QSO freq (kHz) - int nagain; //1 ==> decode only at fQSO +/- Tol - int ndepth; //How much hinted decoding to do? - int ndiskdat; //1 ==> data read from *.tf2 or *.iq file - int neme; //Hinted decoding tries only for EME calls - int newdat; //1 ==> new data, must do long FFT - int nfa; //Low decode limit (kHz) - int nfb; //High decode limit (kHz) - int nfcal; //Frequency correction, for calibration (Hz) - int nfshift; //Shift of displayed center freq (kHz) - int mcall3; //1 ==> CALL3.TXT has been modified - int ntimeout; //Max for timeouts in Messages and BandMap - int ntol; //+/- decoding range around fQSO (Hz) - int nxant; //1 ==> add 45 deg to measured pol angle - int map65RxLog; //Flags to control log files - int nfsample; //Input sample rate - int nxpol; //1 if using xpol antennas, 0 otherwise - int mode65; //JT65 sub-mode: A=1, B=2, C=4 - char mycall[12]; - char mygrid[6]; - char hiscall[12]; - char hisgrid[6]; - char datetime[20]; - */ } datcom_; } diff --git a/getfile.cpp b/getfile.cpp index fb40430ca..f14f8ed5a 100644 --- a/getfile.cpp +++ b/getfile.cpp @@ -25,6 +25,22 @@ void getfile(QString fname, bool xpol, int dbDgrd) void savewav(QString fname) { + struct { + char ariff[4]; + int nchunk; + char awave[4]; + char afmt[4]; + int lenfmt; + short int nfmt2; + short int nchan2; + int nsamrate; + int nbytesec; + short int nbytesam2; + short int nbitsam2; + char adata[4]; + int ndata; + } hdr; + int npts=30*48000; // qint16* buf=(qint16*)malloc(2*npts); char name[80]; @@ -33,8 +49,33 @@ void savewav(QString fname) if(fp != NULL) { // Write a WAV header -// fwrite(&datcom_.fcenter,sizeof(datcom_.fcenter),1,fp); + hdr.ariff[0]='R'; + hdr.ariff[1]='I'; + hdr.ariff[2]='F'; + hdr.ariff[3]='F'; + hdr.nchunk=0; + hdr.awave[0]='W'; + hdr.awave[0]='A'; + hdr.awave[0]='V'; + hdr.awave[0]='E'; + hdr.afmt[0]='f'; + hdr.afmt[1]='m'; + hdr.afmt[2]='t'; + hdr.afmt[3]=' '; + hdr.lenfmt=16; + hdr.nfmt2=1; + hdr.nchan2=1; + hdr.nsamrate=48000; + hdr.nbytesec=2*48000; + hdr.nbytesam2=2; + hdr.nbitsam2=16; + hdr.adata[0]='d'; + hdr.adata[1]='a'; + hdr.adata[2]='t'; + hdr.adata[3]='a'; + hdr.ndata=2*npts; + fwrite(&hdr,sizeof(hdr),1,fp); // memcpy(datcom_.d2,buf,2*npts); // fwrite(buf,2,npts,fp); fwrite(datcom_.d2,2,npts,fp); diff --git a/mainwindow.cpp b/mainwindow.cpp index 00f8294d9..0953c5504 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -174,7 +174,7 @@ MainWindow::MainWindow(QWidget *parent) : border-style: outset; border-width: 1px; border-radius: 5px; \ border-color: black; min-width: 5em; padding: 3px;}"; - genStdMsgs(""); + genStdMsgs("-26"); on_actionWide_Waterfall_triggered(); //### if(m_mode=="JT65A") on_actionJT65A_triggered(); @@ -401,6 +401,8 @@ void MainWindow::dataSink(int k) static int nwrite=0; static int k0=99999999; static float px=0.0; + static float sq0=0.0; + static float sqave=1000.0; if(k < k0) { nwrite=0; @@ -414,13 +416,17 @@ void MainWindow::dataSink(int k) datcom_.ndiskdat=0; } - double sq=0.0; + float sq=0.0; float x; + float fac=1.0/30.0; for(int i=0; i<6192; i++) { - x=datcom_.d2[k-6192+i]; + x=fac*datcom_.d2[k-6192+i]; sq += x*x; } - px = 10.0*log10(sq/6192.0) + 70.0; // Why +70 ??? + sqave=0.5*(sq+sq0); + sq0=sq; +// qDebug() << "rms:" << sqrt(sq/6192.0); + px = 10.0*log10(sqave/6192.0); if(px>60.0) px=60.0; if(px<0.0) px=0.0; QString t; @@ -466,8 +472,12 @@ void MainWindow::dataSink(int k) if(m_saveAll) { QDateTime t = QDateTime::currentDateTimeUtc(); m_dateTime=t.toString("yyyy-MMM-dd hh:mm"); - QString fname=m_saveDir + "/" + t.date().toString("yyMMdd") + "_" + - t.time().toString("hhmm") + ".wav"; + QString fname=m_saveDir + "/" + m_hisCall + "_" + + t.date().toString("yyMMdd") + "_" + + t.time().toString("hhmmss") + ".wav"; + int i0=fname.indexOf(".wav"); + if(fname.mid(i0-2,2)=="29") fname=fname.mid(0,i0-2)+"00.wav"; + if(fname.mid(i0-2,2)=="59") fname=fname.mid(0,i0-2)+"30.wav"; *future2 = QtConcurrent::run(savewav, fname); watcher2->setFuture(*future2); } @@ -616,13 +626,13 @@ void MainWindow::keyPressEvent( QKeyEvent *e ) //keyPressEvent break; case Qt::Key_G: if(e->modifiers() & Qt::AltModifier) { - genStdMsgs(""); + genStdMsgs("-26"); break; } case Qt::Key_L: if(e->modifiers() & Qt::ControlModifier) { lookup(); - genStdMsgs(""); + genStdMsgs("-26"); break; } } @@ -852,7 +862,7 @@ void MainWindow::diskWriteFinished() //diskWriteFinished { // qDebug() << "diskWriteFinished"; } - //Delete ../save/*.tf2 + //Delete ../save/*.wav void MainWindow::on_actionDelete_all_wav_files_in_SaveDir_triggered() { int i; @@ -868,7 +878,7 @@ void MainWindow::on_actionDelete_all_wav_files_in_SaveDir_triggered() for(f=files.begin(); f!=files.end(); ++f) { fname=*f; i=(fname.indexOf(".wav")); - if(i==11) dir.remove(fname); + if(i>10) dir.remove(fname); } } } @@ -1399,6 +1409,7 @@ void MainWindow::doubleClickOnCall(QString hiscall, bool ctrl) QString rpt=""; if(ctrl) rpt=t2.mid(23,3); lookup(); + rpt="-26"; genStdMsgs(rpt); if(t2.indexOf(m_myCall)>0) { m_ntx=2; diff --git a/mainwindow.ui b/mainwindow.ui index 551d8ca2f..575492715 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -7,7 +7,7 @@ 0 0 616 - 477 + 460 @@ -244,7 +244,7 @@ p, li { white-space: pre-wrap; } - + 0 @@ -257,19 +257,19 @@ p, li { white-space: pre-wrap; } 180 - + 1 - + 60.000000000000000 - + 0.000000000000000 - + 8 - + 0.000000000000000 @@ -530,19 +530,6 @@ p, li { white-space: pre-wrap; } - - - - - 70 - 16777215 - - - - Set Tx Freq - - - @@ -559,44 +546,6 @@ p, li { white-space: pre-wrap; } - - - - NB - - - - - - - false - - - - 0 - 0 - - - - - 70 - 16777215 - - - - 0 - - - 100 - - - 40 - - - Qt::Horizontal - - -