diff --git a/lib/decoder.f90 b/lib/decoder.f90 index 55356fc25..a3ce7962c 100644 --- a/lib/decoder.f90 +++ b/lib/decoder.f90 @@ -23,7 +23,7 @@ subroutine multimode_decoder(ss,id2,params,nfsample) end type counting_jt9_decoder real ss(184,NSMAX) - logical baddata,newdat65,newdat9,single_decode,bVHF + logical baddata,newdat65,newdat9,single_decode,bVHF,bad0 integer*2 id2(NTMAX*12000) type(params_block) :: params real*4 dd(NTMAX*12000) @@ -45,7 +45,29 @@ subroutine multimode_decoder(ss,id2,params,nfsample) rms=sqrt(dot_product(float(id2(300000:310000)), & float(id2(300000:310000)))/10000.0) - if(rms.lt.2.0) go to 800 + if(rms.lt.2.0) go to 800 + +! Zap data at start that might come from T/R switching transient? + nadd=100 + k=0 + bad0=.false. + do i=1,240 + sq=0. + do n=1,nadd + k=k+1 + sq=sq + float(id2(k))**2 + enddo + rms=sqrt(sq/nadd) + if(rms.gt.10000.0) then + bad0=.true. + kbad=k + rmsbad=rms + endif + enddo + if(bad0) then + nz=min(NTMAX*12000,kbad+100) + id2(1:nz)=0 + endif if (params%nagain) then open(13,file=trim(temp_dir)//'/decoded.txt',status='unknown', & @@ -90,7 +112,8 @@ subroutine multimode_decoder(ss,id2,params,nfsample) !$omp section if(params%nmode.eq.65 .or. params%nmode.eq.164 .or. & (params%nmode.eq.(65+9) .and. params%ntxmode.eq.65)) then -! We're in JT65 mode, or should do JT65 first +! We're in JT65 or QRA64 mode, or should do JT65 first + if(newdat65) dd(1:npts65)=id2(1:npts65) nf1=params%nfa nf2=params%nfb @@ -98,7 +121,7 @@ subroutine multimode_decoder(ss,id2,params,nfsample) call my_jt65%decode(jt65_decoded,dd,npts65,newdat65,params%nutc, & nf1,nf2,params%nfqso,ntol65,params%nsubmode,params%minsync, & logical(params%nagain),params%n2pass,logical(params%nrobust), & - ntrials,params%naggressive,params%ndepth, & + ntrials,params%naggressive,params%ndepth,params%emedelay, & logical(params%nclearave),params%mycall,params%hiscall, & params%hisgrid,params%nexp_decode) call timer('jt65a ',1) @@ -123,7 +146,7 @@ subroutine multimode_decoder(ss,id2,params,nfsample) call my_jt65%decode(jt65_decoded,dd,npts65,newdat65,params%nutc, & nf1,nf2,params%nfqso,ntol65,params%nsubmode,params%minsync, & logical(params%nagain),params%n2pass,logical(params%nrobust), & - ntrials,params%naggressive,params%ndepth, & + ntrials,params%naggressive,params%ndepth,params%emedelay, & logical(params%nclearave),params%mycall,params%hiscall, & params%hisgrid,params%nexp_decode) call timer('jt65a ',1) diff --git a/lib/jt65_decode.f90 b/lib/jt65_decode.f90 index 219ba32fe..b68dfafc6 100644 --- a/lib/jt65_decode.f90 +++ b/lib/jt65_decode.f90 @@ -37,7 +37,7 @@ contains subroutine decode(this,callback,dd0,npts,newdat,nutc,nf1,nf2,nfqso, & ntol,nsubmode,minsync,nagain,n2pass,nrobust,ntrials,naggressive, & - ndepth,clearave,mycall,hiscall,hisgrid,nexp_decode) + ndepth,emedelay,clearave,mycall,hiscall,hisgrid,nexp_decode) ! Process dd0() data to find and decode JT65 signals. @@ -48,7 +48,7 @@ contains class(jt65_decoder), intent(inout) :: this procedure(jt65_decode_callback) :: callback - real, intent(in) :: dd0(NZMAX) + real, intent(in) :: dd0(NZMAX),emedelay integer, intent(in) :: npts, nutc, nf1, nf2, nfqso, ntol & , nsubmode, minsync, n2pass, ntrials, naggressive, ndepth & , nexp_decode @@ -106,7 +106,7 @@ contains ! close(60) !### call qra64a(dd,npts,nutc,nf1,nf2,nfqso,ntol,mode64,minsync,ndepth, & - mycall,hiscall,hisgrid,sync,nsnr,dtx,nfreq,decoded,nft) + emedeley,mycall,hiscall,hisgrid,sync,nsnr,dtx,nfreq,decoded,nft) if (associated(this%callback)) then ndrift=0 nflip=1 diff --git a/lib/jt65_test.f90 b/lib/jt65_test.f90 index f146f82bd..e1eac4ded 100644 --- a/lib/jt65_test.f90 +++ b/lib/jt65_test.f90 @@ -32,8 +32,8 @@ contains nutc=nutc,nf1=nflow,nf2=nfhigh,nfqso=nfqso,ntol=ntol, & nsubmode=nsubmode, minsync=-1,nagain=.false.,n2pass=n2pass, & nrobust=nrobust,ntrials=ntrials,naggressive=naggressive, & - ndepth=ndepth,clearave=nclearave,mycall=mycall,hiscall=hiscall, & - hisgrid=hisgrid,nexp_decode=nexp_decode) + ndepth=ndepth,emedelay=0.0,clearave=nclearave,mycall=mycall, & + hiscall=hiscall,hisgrid=hisgrid,nexp_decode=nexp_decode) call timer('jt65a ',1) end subroutine test diff --git a/lib/qra64a.f90 b/lib/qra64a.f90 index d2014dbc2..1090f8e1f 100644 --- a/lib/qra64a.f90 +++ b/lib/qra64a.f90 @@ -1,5 +1,5 @@ subroutine qra64a(dd,npts,nutc,nf1,nf2,nfqso,ntol,mode64,minsync,ndepth, & - mycall_12,hiscall_12,hisgrid_6,sync,nsnr,dtx,nfreq,decoded,nft) + emedelay,mycall_12,hiscall_12,hisgrid_6,sync,nsnr,dtx,nfreq,decoded,nft) use packjt use timer_module, only: timer @@ -59,15 +59,17 @@ subroutine qra64a(dd,npts,nutc,nf1,nf2,nfqso,ntol,mode64,minsync,ndepth, & naptype=maxaptype call ana64(dd,npts,c00) + npts2=npts/2 call timer('sync64 ',0) - call sync64(c00,nf1,nf2,nfqso,ntol,mode64,dtx,f0,jpk0,sync,sync2,width) + call sync64(c00,nf1,nf2,nfqso,ntol,mode64,emedelay,dtx,f0,jpk0,sync, & + sync2,width) call timer('sync64 ',1) nfreq=nint(f0) + if(mode64.eq.1 .and. minsync.ge.0 .and. (sync-7.0).lt.minsync) go to 900 ! if((sync-3.4).lt.float(minsync) .or.width.gt.340.0) go to 900 a=0. a(1)=-f0 - npts2=npts/2 call twkfreq(c00,c0,npts2,6000.0,a) irc=-99 @@ -149,5 +151,8 @@ subroutine qra64a(dd,npts,nutc,nf1,nf2,nfqso,ntol,mode64,minsync,ndepth, & endif call timer('qra64a ',1) +! write(71,3001) nutc,dtx,f0,sync,sync2,width,minsync,decoded +!3001 format(i4.4,f7.2,4f8.1,i3,2x,a22) + return end subroutine qra64a diff --git a/lib/sync64.f90 b/lib/sync64.f90 index a22d94766..806af8bc8 100644 --- a/lib/sync64.f90 +++ b/lib/sync64.f90 @@ -1,4 +1,5 @@ -subroutine sync64(c0,nf1,nf2,nfqso,ntol,mode64,dtx,f0,jpk,sync,sync2,width) +subroutine sync64(c0,nf1,nf2,nfqso,ntol,mode64,emedelay,dtx,f0,jpk,sync, & + sync2,width) use timer_module, only: timer @@ -60,7 +61,7 @@ subroutine sync64(c0,nf1,nf2,nfqso,ntol,mode64,dtx,f0,jpk,sync,sync2,width) smaxall=0. jpk=0 ja=0 - jb=7.5*6000 + jb=(5.0+emedelay)*6000 jstep=100 ipk=0 kpk=0 @@ -100,9 +101,7 @@ subroutine sync64(c0,nf1,nf2,nfqso,ntol,mode64,dtx,f0,jpk,sync,sync2,width) call smo(s0b(ia:ib),iz,s0(ia:ib),nadd) enddo endif - if(j1.eq.ja) then - call averms(s0(ia+id:ib-id),iz-2*id,nskip,ave,rms) - endif + call averms(s0(ia+id:ib-id),iz-2*id,nskip,ave,rms) s=(maxval(s0(iaa:ibb))-ave)/rms ipk0=maxloc(s0(iaa:ibb)) ip=ipk0(1) + iaa - 1 @@ -116,7 +115,7 @@ subroutine sync64(c0,nf1,nf2,nfqso,ntol,mode64,dtx,f0,jpk,sync,sync2,width) endif call timer('sync64_2',1) enddo - + s0a=s0a+2.0 write(17) ia,ib,s0a(ia:ib) !Save data for red curve close(17) diff --git a/mainwindow.cpp b/mainwindow.cpp index d5718d878..4e0c33104 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1987,23 +1987,26 @@ void MainWindow::read_wav_file (QString const& fname) } } BWFFile file {QAudioFormat {}, fname}; - file.open (BWFFile::ReadOnly); - auto bytes_per_frame = file.format ().bytesPerFrame (); - qint64 max_bytes = std::min (std::size_t (m_TRperiod * RX_SAMPLE_RATE), - sizeof (dec_data.d2) / sizeof (dec_data.d2[0])) - * bytes_per_frame; - auto n = file.read (reinterpret_cast (dec_data.d2), + bool ok=file.open (BWFFile::ReadOnly); + if(ok) { + auto bytes_per_frame = file.format ().bytesPerFrame (); + qint64 max_bytes = std::min (std::size_t (m_TRperiod * RX_SAMPLE_RATE), + sizeof (dec_data.d2) / sizeof (dec_data.d2[0]))* bytes_per_frame; + auto n = file.read (reinterpret_cast (dec_data.d2), std::min (max_bytes, file.size ())); - int frames_read = n / bytes_per_frame; + int frames_read = n / bytes_per_frame; // zero unfilled remaining sample space - std::memset (&dec_data.d2[0] + n, 0, max_bytes - n); - if (11025 == file.format ().sampleRate ()) - { + std::memset (&dec_data.d2[0] + n, 0, max_bytes - n); + if (11025 == file.format ().sampleRate ()) { short sample_size = file.format ().sampleSize (); wav12_ (dec_data.d2, dec_data.d2, &frames_read, &sample_size); } - dec_data.params.kin = frames_read; - dec_data.params.newdat = 1; + dec_data.params.kin = frames_read; + dec_data.params.newdat = 1; + } else { + dec_data.params.kin = 0; + dec_data.params.newdat = 0; + } })); } @@ -2044,20 +2047,23 @@ void MainWindow::on_actionDecode_remaining_files_in_directory_triggered() void MainWindow::diskDat() //diskDat() { - int k; - int kstep=m_FFTSize; - m_diskData=true; + if(dec_data.params.kin>0) { + int k; + int kstep=m_FFTSize; + m_diskData=true; + float db=m_config.degrade(); + float bw=m_config.RxBandwidth(); + if(db > 0.0) degrade_snr_(dec_data.d2,&dec_data.params.kin,&db,&bw); - float db=m_config.degrade(); - float bw=m_config.RxBandwidth(); - if(db > 0.0) degrade_snr_(dec_data.d2,&dec_data.params.kin,&db,&bw); - - for(int n=1; n<=m_hsymStop; n++) { // Do the waterfall spectra - k=(n+1)*kstep; - if(k > dec_data.params.kin) break; - dec_data.params.npts8=k/8; - dataSink(k); - qApp->processEvents(); //Update the waterfall + for(int n=1; n<=m_hsymStop; n++) { // Do the waterfall spectra + k=(n+1)*kstep; + if(k > dec_data.params.kin) break; + dec_data.params.npts8=k/8; + dataSink(k); + qApp->processEvents(); //Update the waterfall + } + } else { + MessageBox::information_message(this, tr("No data read from disk. Wrong file format?")); } }