From 93224b3b31fc5653f879975c1e75320fe9ce7998 Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Thu, 5 Jul 2012 16:16:03 +0000 Subject: [PATCH] Changed soundin to i*2 rather than r*4. Activated saving of WAV files. (but so far, without headers). Tx waveform now uses sinc() pulses. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/jtms3@2489 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- commons.h | 2 +- getfile.cpp | 65 +++++++++------------------------------ libm65/genjtms3.f90 | 74 ++++++++++++++++++++++++++++++++++----------- mainwindow.cpp | 24 +++++++++------ soundin.cpp | 21 ++++--------- 5 files changed, 91 insertions(+), 95 deletions(-) diff --git a/commons.h b/commons.h index 161fb077e..6e151a2a9 100644 --- a/commons.h +++ b/commons.h @@ -6,7 +6,7 @@ extern "C" { extern struct { //This is "common/datcom/..." in Fortran - float d4[30*48000]; //Raw data + float d2[30*48000]; //Raw data int kin; int ndiskdat; /* diff --git a/getfile.cpp b/getfile.cpp index 098a6561b..fb40430ca 100644 --- a/getfile.cpp +++ b/getfile.cpp @@ -8,76 +8,39 @@ extern qint16 id[4*60*96000]; void getfile(QString fname, bool xpol, int dbDgrd) { - int npts=2*52*96000; - if(xpol) npts=2*npts; -// Degrade S/N by dbDgrd dB -- for tests only!! - float dgrd=0.0; - if(dbDgrd<0) dgrd = 23.0*sqrt(pow(10.0,-0.1*(double)dbDgrd) - 1.0); - float fac=23.0/sqrt(dgrd*dgrd + 23.0*23.0); - - memset(id,0,2*npts); char name[80]; strcpy(name,fname.toAscii()); FILE* fp=fopen(name,"rb"); + int npts=30*48000; + memset(datcom_.d2,0,2*npts); + if(fp != NULL) { -// fread(&datcom_.fcenter,sizeof(datcom_.fcenter),1,fp); - fread(id,2,npts,fp); - int j=0; - - if(dbDgrd<0) { - for(int i=0; i0) datcom_.nutc=100*fname.mid(i0-4,2).toInt() + - fname.mid(i0-2,2).toInt(); - */ } } void savewav(QString fname) { - /* - int npts=2*52*96000; - if(xpol) npts=2*npts; - - qint16* buf=(qint16*)malloc(2*npts); + int npts=30*48000; +// qint16* buf=(qint16*)malloc(2*npts); char name[80]; strcpy(name,fname.toAscii()); FILE* fp=fopen(name,"wb"); if(fp != NULL) { - fwrite(&datcom_.fcenter,sizeof(datcom_.fcenter),1,fp); - int j=0; - for(int i=0; i= (int)(29.5*48000) and nwrite==0) { + nwrite=1; 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"; *future2 = QtConcurrent::run(savewav, fname); watcher2->setFuture(*future2); } } + k0=k; soundInThread.m_dataSinkBusy=false; } @@ -861,9 +867,7 @@ void MainWindow::on_actionDelete_all_wav_files_in_SaveDir_triggered() QList::iterator f; for(f=files.begin(); f!=files.end(); ++f) { fname=*f; - i=(fname.indexOf(".tf2")); - if(i==11) dir.remove(fname); - i=(fname.indexOf(".iq")); + i=(fname.indexOf(".wav")); if(i==11) dir.remove(fname); } } diff --git a/soundin.cpp b/soundin.cpp index 0411c96d5..734a321c8 100644 --- a/soundin.cpp +++ b/soundin.cpp @@ -7,7 +7,7 @@ extern "C" { #include extern struct { - float d4[30*48000]; //This is "common/datcom/..." in fortran + short int d2[30*48000]; //This is "common/datcom/..." in fortran int kin; } datcom_; } @@ -46,22 +46,12 @@ extern "C" int a2dCallback( const void *inputBuffer, void *outputBuffer, udata->bzero=false; } - nbytes=4*framesToProcess; //Bytes per frame + nbytes=2*framesToProcess; //Bytes per frame k=udata->kin; - memcpy(&datcom_.d4[k],inputBuffer,nbytes); //Copy all samples to d4 + memcpy(&datcom_.d2[k],inputBuffer,nbytes); //Copy all samples to d2 udata->kin += framesToProcess; datcom_.kin=udata->kin; -/* - double sq=0.0; - float x; - for(i=0; ikin/48000.0 << rms; -*/ return paContinue; } @@ -80,7 +70,7 @@ void SoundInThread::run() //SoundInThread::run() inParam.device=m_nDevIn; //### Input Device Number ### inParam.channelCount=1; //Number of analog channels - inParam.sampleFormat=paFloat32; //Get floats from Portaudio + inParam.sampleFormat=paInt16; //Get i*2 from Portaudio inParam.suggestedLatency=0.05; inParam.hostApiSpecificStreamInfo=NULL; @@ -94,7 +84,7 @@ void SoundInThread::run() //SoundInThread::run() NULL, //No output parameters 48000.0, //Sample rate FRAMES_PER_BUFFER, //Frames per buffer -// paClipOff+paDitherOff, //No clipping or dithering +// paClipOff+paDitherOff, //No clipping or dithering paClipOff, //No clipping a2dCallback, //Input callbeck routine &udata); //userdata @@ -134,6 +124,7 @@ void SoundInThread::run() //SoundInThread::run() nBusy++; } else { // m_dataSinkBusy=true; +// qDebug() << "A" << k; emit readyForFFT(k); //Signal to compute new FFTs } nstep0=m_step;