1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-25 17:28:50 -05:00

Set channel analyzer bandwidth before decimation to channelizer input sample rate

This commit is contained in:
f4exb 2015-07-12 09:32:54 +02:00
parent 76c2843a39
commit c624ad0e13
6 changed files with 19 additions and 5 deletions

View File

@ -9,11 +9,13 @@ class MessageQueue;
class IntHalfbandFilter; class IntHalfbandFilter;
class SDRANGELOVE_API Channelizer : public SampleSink { class SDRANGELOVE_API Channelizer : public SampleSink {
Q_OBJECT
public: public:
Channelizer(SampleSink* sampleSink); Channelizer(SampleSink* sampleSink);
~Channelizer(); ~Channelizer();
void configure(MessageQueue* messageQueue, int sampleRate, int centerFrequency); void configure(MessageQueue* messageQueue, int sampleRate, int centerFrequency);
int getInputSampleRate() const { return m_inputSampleRate; }
void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly); void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly);
void start(); void start();
@ -54,6 +56,9 @@ protected:
bool signalContainsChannel(Real sigStart, Real sigEnd, Real chanStart, Real chanEnd) const; bool signalContainsChannel(Real sigStart, Real sigEnd, Real chanStart, Real chanEnd) const;
Real createFilterChain(Real sigStart, Real sigEnd, Real chanStart, Real chanEnd); Real createFilterChain(Real sigStart, Real sigEnd, Real chanStart, Real chanEnd);
void freeFilterChain(); void freeFilterChain();
signals:
void inputSampleRateChanged();
}; };
#endif // INCLUDE_CHANNELIZER_H #endif // INCLUDE_CHANNELIZER_H

View File

@ -123,7 +123,7 @@ bool ChannelAnalyzer::handleMessage(Message* cmd)
if(DSPSignalNotification::match(cmd)) { if(DSPSignalNotification::match(cmd)) {
DSPSignalNotification* signal = (DSPSignalNotification*)cmd; DSPSignalNotification* signal = (DSPSignalNotification*)cmd;
//fprintf(stderr, "%d samples/sec, %lld Hz offset", signal->getSampleRate(), signal->getFrequencyOffset()); fprintf(stderr, "ChannelAnalyzer::handleMessage: %d samples/sec, %lld Hz offset\n", signal->getSampleRate(), signal->getFrequencyOffset());
m_sampleRate = signal->getSampleRate(); m_sampleRate = signal->getSampleRate();
m_nco.setFreq(-signal->getFrequencyOffset(), m_sampleRate); m_nco.setFreq(-signal->getFrequencyOffset(), m_sampleRate);
cmd->completed(); cmd->completed();

View File

@ -108,6 +108,11 @@ void ChannelAnalyzerGUI::viewChanged()
applySettings(); applySettings();
} }
void ChannelAnalyzerGUI::channelSampleRateChanged()
{
setNewRate(m_spanLog2);
}
void ChannelAnalyzerGUI::on_deltaMinus_clicked(bool minus) void ChannelAnalyzerGUI::on_deltaMinus_clicked(bool minus)
{ {
int deltaFrequency = m_channelMarker->getCenterFrequency(); int deltaFrequency = m_channelMarker->getCenterFrequency();
@ -256,6 +261,7 @@ ChannelAnalyzerGUI::ChannelAnalyzerGUI(PluginAPI* pluginAPI, QWidget* parent) :
m_spectrumScopeComboVis = new SpectrumScopeComboVis(m_spectrumVis, m_scopeVis); m_spectrumScopeComboVis = new SpectrumScopeComboVis(m_spectrumVis, m_scopeVis);
m_channelAnalyzer = new ChannelAnalyzer(m_spectrumScopeComboVis); m_channelAnalyzer = new ChannelAnalyzer(m_spectrumScopeComboVis);
m_channelizer = new Channelizer(m_channelAnalyzer); m_channelizer = new Channelizer(m_channelAnalyzer);
connect(m_channelizer, SIGNAL(inputSampleRateChanged()), this, SLOT(channelSampleRateChanged()));
m_threadedSampleSink = new ThreadedSampleSink(m_channelizer); m_threadedSampleSink = new ThreadedSampleSink(m_channelizer);
m_pluginAPI->addSampleSink(m_threadedSampleSink); m_pluginAPI->addSampleSink(m_threadedSampleSink);
@ -360,7 +366,7 @@ void ChannelAnalyzerGUI::applySettings()
ui->deltaFrequency->setValue(abs(m_channelMarker->getCenterFrequency())); ui->deltaFrequency->setValue(abs(m_channelMarker->getCenterFrequency()));
ui->deltaMinus->setChecked(m_channelMarker->getCenterFrequency() < 0); ui->deltaMinus->setChecked(m_channelMarker->getCenterFrequency() < 0);
m_channelizer->configure(m_threadedSampleSink->getMessageQueue(), m_channelizer->configure(m_threadedSampleSink->getMessageQueue(),
48000, m_channelizer->getInputSampleRate(),
m_channelMarker->getCenterFrequency()); m_channelMarker->getCenterFrequency());
m_channelAnalyzer->configure(m_threadedSampleSink->getMessageQueue(), m_channelAnalyzer->configure(m_threadedSampleSink->getMessageQueue(),
ui->BW->value() * 100.0, ui->BW->value() * 100.0,

View File

@ -37,6 +37,7 @@ public:
private slots: private slots:
void viewChanged(); void viewChanged();
void channelSampleRateChanged();
void on_deltaFrequency_changed(quint64 value); void on_deltaFrequency_changed(quint64 value);
void on_deltaMinus_clicked(bool minus); void on_deltaMinus_clicked(bool minus);
void on_BW_valueChanged(int value); void on_BW_valueChanged(int value);

View File

@ -3,7 +3,7 @@
#include "dsp/dspcommands.h" #include "dsp/dspcommands.h"
//#include <cstdio> //#include <cstdio>
//#include <iostream> #include <iostream>
Channelizer::Channelizer(SampleSink* sampleSink) : Channelizer::Channelizer(SampleSink* sampleSink) :
m_sampleSink(sampleSink), m_sampleSink(sampleSink),
@ -73,6 +73,7 @@ bool Channelizer::handleMessage(Message* cmd)
if(!m_sampleSink->handleMessage(signal)) if(!m_sampleSink->handleMessage(signal))
signal->completed(); signal->completed();
} }
emit inputSampleRateChanged();
return true; return true;
} else if(DSPConfigureChannelizer::match(cmd)) { } else if(DSPConfigureChannelizer::match(cmd)) {
DSPConfigureChannelizer* chan = (DSPConfigureChannelizer*)cmd; DSPConfigureChannelizer* chan = (DSPConfigureChannelizer*)cmd;
@ -100,13 +101,12 @@ void Channelizer::applyConfiguration()
m_inputSampleRate / -2, m_inputSampleRate / 2, m_inputSampleRate / -2, m_inputSampleRate / 2,
m_requestedCenterFrequency - m_requestedOutputSampleRate / 2, m_requestedCenterFrequency + m_requestedOutputSampleRate / 2); m_requestedCenterFrequency - m_requestedOutputSampleRate / 2, m_requestedCenterFrequency + m_requestedOutputSampleRate / 2);
m_currentOutputSampleRate = m_inputSampleRate / (1 << m_filterStages.size()); m_currentOutputSampleRate = m_inputSampleRate / (1 << m_filterStages.size());
/*
std::cerr << "Channelizer::applyConfiguration in=" << m_inputSampleRate std::cerr << "Channelizer::applyConfiguration in=" << m_inputSampleRate
<< ", req=" << m_requestedOutputSampleRate << ", req=" << m_requestedOutputSampleRate
<< ", out=" << m_currentOutputSampleRate << ", out=" << m_currentOutputSampleRate
<< ", fc=" << m_currentCenterFrequency << ", fc=" << m_currentCenterFrequency
<< std::endl; << std::endl;
*/
} }
Channelizer::FilterStage::FilterStage(Mode mode) : Channelizer::FilterStage::FilterStage(Mode mode) :

View File

@ -62,6 +62,8 @@ void GLScope::setDSPEngine(DSPEngine* dspEngine)
void GLScope::setSampleRate(int sampleRate) { void GLScope::setSampleRate(int sampleRate) {
m_sampleRate = sampleRate; m_sampleRate = sampleRate;
m_configChanged = true;
update();
emit sampleRateChanged(m_sampleRate); emit sampleRateChanged(m_sampleRate);
} }