mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-10-31 15:47:10 -04:00
Working on implementing reference spectra.
git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6600 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
parent
499b95ebc2
commit
122b83e0c1
@ -387,6 +387,7 @@ set (wsjt_FSRCS
|
||||
lib/ps4.f90
|
||||
lib/readwav.f90
|
||||
lib/rectify_msk.f90
|
||||
lib/refspec.f90
|
||||
lib/savec2.f90
|
||||
lib/sec_midn.f90
|
||||
lib/setup65.f90
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "moc_Detector.cpp"
|
||||
|
||||
extern "C" {
|
||||
void fil4_(qint16*, qint32*, qint16*, qint32*, qint32*);
|
||||
void fil4_(qint16*, qint32*, qint16*, qint32*);
|
||||
}
|
||||
|
||||
Detector::Detector (unsigned frameRate, unsigned periodLengthInSeconds,
|
||||
@ -85,10 +85,8 @@ qint64 Detector::writeData (char const * data, qint64 maxSize)
|
||||
qint32 framesAfterDownSample (m_samplesPerFFT);
|
||||
if(framesToProcess==13824 and dec_data.params.kin>=0 and
|
||||
dec_data.params.kin < (NTMAX*12000 - framesAfterDownSample)) {
|
||||
int nrefspec=0;
|
||||
if(g_bRefSpec) nrefspec=1;
|
||||
fil4_(&m_buffer[0], &framesToProcess, &dec_data.d2[dec_data.params.kin],
|
||||
&framesAfterDownSample, &nrefspec);
|
||||
&framesAfterDownSample);
|
||||
dec_data.params.kin += framesAfterDownSample;
|
||||
} else {
|
||||
// qDebug() << "framesToProcess = " << framesToProcess;
|
||||
|
@ -3,8 +3,6 @@
|
||||
#include "AudioDevice.hpp"
|
||||
#include <QScopedArrayPointer>
|
||||
|
||||
extern bool g_bRefSpec;
|
||||
|
||||
//
|
||||
// output device that distributes data in predefined chunks via a signal
|
||||
//
|
||||
|
46
lib/fil4.f90
46
lib/fil4.f90
@ -1,4 +1,4 @@
|
||||
subroutine fil4(id1,n1,id2,n2,nrefspec)
|
||||
subroutine fil4(id1,n1,id2,n2)
|
||||
|
||||
! FIR lowpass filter designed using ScopeFIR
|
||||
|
||||
@ -12,15 +12,10 @@ subroutine fil4(id1,n1,id2,n2,nrefspec)
|
||||
|
||||
parameter (NTAPS=49)
|
||||
parameter (NDOWN=4) !Downsample ratio
|
||||
parameter (NFFT=13824,NH=NFFT/2)
|
||||
integer*2 id1(n1)
|
||||
integer*2 id2(*)
|
||||
real t(NTAPS)
|
||||
real x(NFFT)
|
||||
real s(0:NH)
|
||||
complex cx(0:NH)
|
||||
equivalence(x,cx)
|
||||
data t/NTAPS*0.0/,nrefspec0/-999/
|
||||
data t/NTAPS*0.0/
|
||||
|
||||
! Filter coefficients:
|
||||
real w(NTAPS)
|
||||
@ -38,13 +33,7 @@ subroutine fil4(id1,n1,id2,n2,nrefspec)
|
||||
-0.013752163325,-0.011720748164,-0.005202883094, 0.002613872664, &
|
||||
0.008706594219, 0.011363155076, 0.010161983649, 0.010051920210, &
|
||||
0.000861074040/
|
||||
save w,t,nsave,s,nrefspec0
|
||||
|
||||
if(nrefspec.ne.nrefspec0) then
|
||||
s=0.
|
||||
nsave=0
|
||||
nrefspec0=nrefspec
|
||||
endif
|
||||
save w,t
|
||||
|
||||
n2=n1/NDOWN
|
||||
if(n2*NDOWN.ne.n1) stop 'Error in fil4'
|
||||
@ -56,34 +45,5 @@ subroutine fil4(id1,n1,id2,n2,nrefspec)
|
||||
id2(i)=nint(dot_product(w,t))
|
||||
enddo
|
||||
|
||||
if(nrefspec.eq.1) then
|
||||
nsave=nsave+1
|
||||
x=0.001*id1
|
||||
call four2a(x,NFFT,1,-1,0) !r2c FFT
|
||||
|
||||
do i=1,NH
|
||||
s(i)=s(i) + real(cx(i))**2 + aimag(cx(i))**2
|
||||
enddo
|
||||
|
||||
if(mod(nsave,34).eq.0) then !About 9.8 sec
|
||||
df=48000.0/NFFT
|
||||
ia=nint(500.0/df)
|
||||
ib=nint(2500.0/df)
|
||||
call pctile(s(ia),ib-ia+1,50,xmed)
|
||||
db0=db(xmed)
|
||||
nhadd=10
|
||||
open(16,file='refspec.dat',status='unknown')
|
||||
do i=1,NH
|
||||
freq=i*df
|
||||
ia=max(1,i-nhadd)
|
||||
ib=min(NH,i+nhadd)
|
||||
smo=sum(s(ia:ib))/(ib-ia+1)
|
||||
write(16,1000) freq,db(smo)-db0
|
||||
1000 format(2f10.3)
|
||||
enddo
|
||||
close(16)
|
||||
endif
|
||||
endif
|
||||
|
||||
return
|
||||
end subroutine fil4
|
||||
|
17
lib/refspec.f90
Normal file
17
lib/refspec.f90
Normal file
@ -0,0 +1,17 @@
|
||||
subroutine refspec(id2,k)
|
||||
|
||||
! Input:
|
||||
! id2 raw 16-bit integer data, 12000 Hz sample rate
|
||||
! k pointer to the most recent new data
|
||||
|
||||
! Output (in common/c0com)
|
||||
! c0 complex data downsampled to 1500 Hz
|
||||
|
||||
parameter (NMAX=120*12000) !Total sample intervals per 30 minutes
|
||||
integer*2 id2(0:NMAX-1)
|
||||
|
||||
! write(*,3001) id2(k-3456:k-3456+9),k
|
||||
!3001 format(10i5,i10)
|
||||
|
||||
return
|
||||
end subroutine refspec
|
@ -99,6 +99,7 @@ extern "C" {
|
||||
void hash_calls_(char calls[], int* ih9, int len);
|
||||
void degrade_snr_(short d2[], int* n, float* db, float* bandwidth);
|
||||
void wav12_(short d2[], short d1[], int* nbytes, short* nbitsam2);
|
||||
void refspec_(short int d2[], int* k);
|
||||
}
|
||||
|
||||
int volatile itone[NUM_ISCAT_SYMBOLS]; //Audio tones for all Tx symbols
|
||||
@ -118,7 +119,6 @@ int fast_jh2;
|
||||
int narg[15];
|
||||
QVector<QColor> g_ColorTbl;
|
||||
bool g_single_decode;
|
||||
bool g_bRefSpec;
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -677,7 +677,7 @@ MainWindow::MainWindow(bool multiple, QSettings * settings, QSharedMemory *shdme
|
||||
}
|
||||
VHF_features_enabled(m_config.enable_VHF_features());
|
||||
g_single_decode=m_config.single_decode();
|
||||
g_bRefSpec=false;
|
||||
m_bRefSpec=false;
|
||||
|
||||
progressBar->setMaximum(m_TRperiod);
|
||||
m_modulator->setPeriod(m_TRperiod); // TODO - not thread safe
|
||||
@ -873,6 +873,10 @@ void MainWindow::dataSink(qint64 frames)
|
||||
static float px=0.0;
|
||||
static float df3;
|
||||
|
||||
int k (frames);
|
||||
refspec_(dec_data.d2,&k);
|
||||
// wspr_downsample_(dec_data.d2,&k);
|
||||
|
||||
if(m_diskData) {
|
||||
dec_data.params.ndiskdat=1;
|
||||
} else {
|
||||
@ -887,7 +891,6 @@ void MainWindow::dataSink(qint64 frames)
|
||||
// Get power, spectrum, and ihsym
|
||||
trmin=m_TRperiod/60;
|
||||
// int k (frames - 1);
|
||||
int k (frames);
|
||||
dec_data.params.nfa=m_wideGraph->nStartFreq();
|
||||
dec_data.params.nfb=m_wideGraph->Fmax();
|
||||
int nsps=m_nsps;
|
||||
@ -1475,9 +1478,9 @@ void MainWindow::on_stopButton_clicked() //stopButton
|
||||
{
|
||||
monitor (false);
|
||||
m_loopall=false;
|
||||
if(g_bRefSpec) {
|
||||
if(m_bRefSpec) {
|
||||
// msgBox("Reference spectrum saved.");
|
||||
g_bRefSpec=false;
|
||||
m_bRefSpec=false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -5342,7 +5345,7 @@ void MainWindow::fastPick(int x0, int x1, int y)
|
||||
|
||||
void MainWindow::on_actionSave_reference_spectrum_triggered()
|
||||
{
|
||||
g_bRefSpec=true;
|
||||
m_bRefSpec=true;
|
||||
}
|
||||
|
||||
void MainWindow::on_sbCQRxFreq_valueChanged(int n)
|
||||
|
@ -425,6 +425,7 @@ private:
|
||||
bool m_bFast9;
|
||||
bool m_bFastDecodeCalled;
|
||||
bool m_bDoubleClickAfterCQnnn;
|
||||
bool m_bRefSpec;
|
||||
float m_pctZap;
|
||||
|
||||
char m_msg[100][80];
|
||||
|
Loading…
Reference in New Issue
Block a user