1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 09:48:45 -05:00

Channel Analyzer NG: created config structure with frequency and sample rates

This commit is contained in:
f4exb 2017-02-28 22:00:24 +01:00
parent 41d031f813
commit ce15d78e55
2 changed files with 49 additions and 14 deletions

View File

@ -32,16 +32,13 @@ ChannelAnalyzerNG::ChannelAnalyzerNG(BasebandSampleSink* sampleSink) :
m_Bandwidth = 5000;
m_LowCutoff = 300;
m_spanLog2 = 3;
m_inputSampleRate = 96000;
m_frequency = 0;
m_nco.setFreq(m_frequency, m_inputSampleRate);
m_undersampleCount = 0;
m_sum = 0;
m_usb = true;
m_ssb = true;
m_magsq = 0;
SSBFilter = new fftfilt(m_LowCutoff / m_inputSampleRate, m_Bandwidth / m_inputSampleRate, ssbFftLen);
DSBFilter = new fftfilt(m_Bandwidth / m_inputSampleRate, 2*ssbFftLen);
SSBFilter = new fftfilt(m_LowCutoff / m_running.m_inputSampleRate, m_Bandwidth / m_running.m_inputSampleRate, ssbFftLen);
DSBFilter = new fftfilt(m_Bandwidth / m_running.m_inputSampleRate, 2*ssbFftLen);
}
ChannelAnalyzerNG::~ChannelAnalyzerNG()
@ -141,12 +138,14 @@ bool ChannelAnalyzerNG::handleMessage(const Message& cmd)
{
DownChannelizer::MsgChannelizerNotification& notif = (DownChannelizer::MsgChannelizerNotification&) cmd;
m_inputSampleRate = notif.getSampleRate();
m_nco.setFreq(-notif.getFrequencyOffset(), m_inputSampleRate);
m_config.m_inputSampleRate = notif.getSampleRate();
m_config.m_frequency = notif.getFrequencyOffset();
qDebug() << "ChannelAnalyzerNG::handleMessage: MsgChannelizerNotification: m_sampleRate: " << m_inputSampleRate
<< " frequencyOffset: " << notif.getFrequencyOffset();
qDebug() << "ChannelAnalyzerNG::handleMessage: MsgChannelizerNotification:"
<< " m_sampleRate: " << m_config.m_inputSampleRate
<< " frequencyOffset: " << m_config.m_frequency;
apply();
return true;
}
else if (MsgConfigureChannelAnalyzer::match(cmd))
@ -178,8 +177,7 @@ bool ChannelAnalyzerNG::handleMessage(const Message& cmd)
m_Bandwidth = bandwidth;
m_LowCutoff = lowCutoff;
SSBFilter->create_filter(m_LowCutoff / m_inputSampleRate, m_Bandwidth / m_inputSampleRate);
DSBFilter->create_dsb_filter(m_Bandwidth / m_inputSampleRate);
apply();
m_spanLog2 = cfg.getSpanLog2();
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;
}

View File

@ -39,7 +39,7 @@ public:
int spanLog2,
bool ssb);
int getSampleRate() const { return m_inputSampleRate; }
int getSampleRate() const { return m_running.m_inputSampleRate; }
Real getMagSq() const { return m_magsq; }
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_LowCutoff;
int m_spanLog2;
int m_undersampleCount;
fftfilt::cmplx m_sum;
int m_inputSampleRate;
int m_frequency;
bool m_usb;
bool m_ssb;
Real m_magsq;
@ -107,6 +121,8 @@ private:
BasebandSampleSink* m_sampleSink;
SampleVector m_sampleBuffer;
QMutex m_settingsMutex;
void apply(bool force = false);
};
#endif // INCLUDE_CHANALYZERNG_H