mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-26 17:58:43 -05:00
Channel Analyzer NG: created config structure with frequency and sample rates
This commit is contained in:
parent
41d031f813
commit
ce15d78e55
@ -32,16 +32,13 @@ ChannelAnalyzerNG::ChannelAnalyzerNG(BasebandSampleSink* sampleSink) :
|
|||||||
m_Bandwidth = 5000;
|
m_Bandwidth = 5000;
|
||||||
m_LowCutoff = 300;
|
m_LowCutoff = 300;
|
||||||
m_spanLog2 = 3;
|
m_spanLog2 = 3;
|
||||||
m_inputSampleRate = 96000;
|
|
||||||
m_frequency = 0;
|
|
||||||
m_nco.setFreq(m_frequency, m_inputSampleRate);
|
|
||||||
m_undersampleCount = 0;
|
m_undersampleCount = 0;
|
||||||
m_sum = 0;
|
m_sum = 0;
|
||||||
m_usb = true;
|
m_usb = true;
|
||||||
m_ssb = true;
|
m_ssb = true;
|
||||||
m_magsq = 0;
|
m_magsq = 0;
|
||||||
SSBFilter = new fftfilt(m_LowCutoff / m_inputSampleRate, m_Bandwidth / m_inputSampleRate, ssbFftLen);
|
SSBFilter = new fftfilt(m_LowCutoff / m_running.m_inputSampleRate, m_Bandwidth / m_running.m_inputSampleRate, ssbFftLen);
|
||||||
DSBFilter = new fftfilt(m_Bandwidth / m_inputSampleRate, 2*ssbFftLen);
|
DSBFilter = new fftfilt(m_Bandwidth / m_running.m_inputSampleRate, 2*ssbFftLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
ChannelAnalyzerNG::~ChannelAnalyzerNG()
|
ChannelAnalyzerNG::~ChannelAnalyzerNG()
|
||||||
@ -141,12 +138,14 @@ bool ChannelAnalyzerNG::handleMessage(const Message& cmd)
|
|||||||
{
|
{
|
||||||
DownChannelizer::MsgChannelizerNotification& notif = (DownChannelizer::MsgChannelizerNotification&) cmd;
|
DownChannelizer::MsgChannelizerNotification& notif = (DownChannelizer::MsgChannelizerNotification&) cmd;
|
||||||
|
|
||||||
m_inputSampleRate = notif.getSampleRate();
|
m_config.m_inputSampleRate = notif.getSampleRate();
|
||||||
m_nco.setFreq(-notif.getFrequencyOffset(), m_inputSampleRate);
|
m_config.m_frequency = notif.getFrequencyOffset();
|
||||||
|
|
||||||
qDebug() << "ChannelAnalyzerNG::handleMessage: MsgChannelizerNotification: m_sampleRate: " << m_inputSampleRate
|
qDebug() << "ChannelAnalyzerNG::handleMessage: MsgChannelizerNotification:"
|
||||||
<< " frequencyOffset: " << notif.getFrequencyOffset();
|
<< " m_sampleRate: " << m_config.m_inputSampleRate
|
||||||
|
<< " frequencyOffset: " << m_config.m_frequency;
|
||||||
|
|
||||||
|
apply();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (MsgConfigureChannelAnalyzer::match(cmd))
|
else if (MsgConfigureChannelAnalyzer::match(cmd))
|
||||||
@ -178,8 +177,7 @@ bool ChannelAnalyzerNG::handleMessage(const Message& cmd)
|
|||||||
m_Bandwidth = bandwidth;
|
m_Bandwidth = bandwidth;
|
||||||
m_LowCutoff = lowCutoff;
|
m_LowCutoff = lowCutoff;
|
||||||
|
|
||||||
SSBFilter->create_filter(m_LowCutoff / m_inputSampleRate, m_Bandwidth / m_inputSampleRate);
|
apply();
|
||||||
DSBFilter->create_dsb_filter(m_Bandwidth / m_inputSampleRate);
|
|
||||||
|
|
||||||
m_spanLog2 = cfg.getSpanLog2();
|
m_spanLog2 = cfg.getSpanLog2();
|
||||||
m_ssb = cfg.getSSB();
|
m_ssb = cfg.getSSB();
|
||||||
@ -206,3 +204,24 @@ bool ChannelAnalyzerNG::handleMessage(const Message& cmd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChannelAnalyzerNG::apply(bool force)
|
||||||
|
{
|
||||||
|
if ((m_running.m_frequency != m_config.m_frequency) ||
|
||||||
|
(m_running.m_inputSampleRate != m_config.m_inputSampleRate) ||
|
||||||
|
force)
|
||||||
|
{
|
||||||
|
m_nco.setFreq(-m_config.m_frequency, m_config.m_inputSampleRate);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((m_running.m_channelSampleRate != m_config.m_channelSampleRate) ||
|
||||||
|
force)
|
||||||
|
{
|
||||||
|
SSBFilter->create_filter(m_LowCutoff / m_config.m_channelSampleRate, m_Bandwidth / m_config.m_channelSampleRate);
|
||||||
|
DSBFilter->create_dsb_filter(m_Bandwidth / m_config.m_channelSampleRate);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_running.m_frequency = m_config.m_frequency;
|
||||||
|
m_running.m_channelSampleRate = m_config.m_channelSampleRate;
|
||||||
|
m_running.m_inputSampleRate = m_config.m_inputSampleRate;
|
||||||
|
}
|
||||||
|
@ -39,7 +39,7 @@ public:
|
|||||||
int spanLog2,
|
int spanLog2,
|
||||||
bool ssb);
|
bool ssb);
|
||||||
|
|
||||||
int getSampleRate() const { return m_inputSampleRate; }
|
int getSampleRate() const { return m_running.m_inputSampleRate; }
|
||||||
Real getMagSq() const { return m_magsq; }
|
Real getMagSq() const { return m_magsq; }
|
||||||
|
|
||||||
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly);
|
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly);
|
||||||
@ -89,13 +89,27 @@ private:
|
|||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct Config
|
||||||
|
{
|
||||||
|
int m_frequency;
|
||||||
|
int m_inputSampleRate;
|
||||||
|
int m_channelSampleRate;
|
||||||
|
|
||||||
|
Config() :
|
||||||
|
m_frequency(0),
|
||||||
|
m_inputSampleRate(96000),
|
||||||
|
m_channelSampleRate(96000)
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
|
Config m_config;
|
||||||
|
Config m_running;
|
||||||
|
|
||||||
Real m_Bandwidth;
|
Real m_Bandwidth;
|
||||||
Real m_LowCutoff;
|
Real m_LowCutoff;
|
||||||
int m_spanLog2;
|
int m_spanLog2;
|
||||||
int m_undersampleCount;
|
int m_undersampleCount;
|
||||||
fftfilt::cmplx m_sum;
|
fftfilt::cmplx m_sum;
|
||||||
int m_inputSampleRate;
|
|
||||||
int m_frequency;
|
|
||||||
bool m_usb;
|
bool m_usb;
|
||||||
bool m_ssb;
|
bool m_ssb;
|
||||||
Real m_magsq;
|
Real m_magsq;
|
||||||
@ -107,6 +121,8 @@ private:
|
|||||||
BasebandSampleSink* m_sampleSink;
|
BasebandSampleSink* m_sampleSink;
|
||||||
SampleVector m_sampleBuffer;
|
SampleVector m_sampleBuffer;
|
||||||
QMutex m_settingsMutex;
|
QMutex m_settingsMutex;
|
||||||
|
|
||||||
|
void apply(bool force = false);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INCLUDE_CHANALYZERNG_H
|
#endif // INCLUDE_CHANALYZERNG_H
|
||||||
|
Loading…
Reference in New Issue
Block a user