diff --git a/include-gpl/dsp/channelizer.h b/include-gpl/dsp/channelizer.h index d988bd0b8..a45b21fed 100644 --- a/include-gpl/dsp/channelizer.h +++ b/include-gpl/dsp/channelizer.h @@ -2,6 +2,7 @@ #define INCLUDE_CHANNELIZER_H #include +#include #include "dsp/samplesink.h" #include "util/export.h" #include "util/message.h" @@ -70,6 +71,7 @@ protected: int m_currentOutputSampleRate; int m_currentCenterFrequency; SampleVector m_sampleBuffer; + QMutex m_mutex; void applyConfiguration(); bool signalContainsChannel(Real sigStart, Real sigEnd, Real chanStart, Real chanEnd) const; @@ -81,53 +83,3 @@ signals: }; #endif // INCLUDE_CHANNELIZER_H - -#if 0 - -#ifndef INCLUDE_CHANNELIZER_H -#define INCLUDE_CHANNELIZER_H - -#include "samplesink.h" -#include "spectrum.h" -#include "nco.h" -#include "interpolator.h" -#include "pidcontroller.h" -#include "hardware/audiofifo.h" - -class AudioOutput; - -class Channelizer : public SampleSink { -public: - Channelizer(); - ~Channelizer(); - -#if 0 - void setGLSpectrum(GLSpectrum* glSpectrum); -#endif - - size_t workUnitSize(); - size_t work(SampleVector::const_iterator begin, SampleVector::const_iterator end); - -private: -#if 0 - NCO m_nco; - Interpolator m_interpolator; - Real m_distance; - Interpolator m_interpolator2; - Real m_distance2; - - SampleVector m_buffer; - size_t m_bufferFill; - Complex m_lastSample; - - AudioOutput* m_audioOutput; - AudioFifo m_audioFifo; - Real m_resampler; - PIDController m_resamplerCtrl; - - Spectrum m_spectrum; -#endif -}; - -#endif // INCLUDE_CHANNELIZER_H -#endif diff --git a/sdrbase/dsp/channelizer.cpp b/sdrbase/dsp/channelizer.cpp index 23988779c..1481cd3fc 100644 --- a/sdrbase/dsp/channelizer.cpp +++ b/sdrbase/dsp/channelizer.cpp @@ -37,18 +37,29 @@ void Channelizer::feed(const SampleVector::const_iterator& begin, const SampleVe return; } - for(SampleVector::const_iterator sample = begin; sample != end; ++sample) { + m_mutex.lock(); + + for(SampleVector::const_iterator sample = begin; sample != end; ++sample) + { Sample s(*sample); FilterStages::iterator stage = m_filterStages.begin(); - while(stage != m_filterStages.end()) { + + for (; stage != m_filterStages.end(); ++stage) + { if(!(*stage)->work(&s)) + { break; - ++stage; + } } + if(stage == m_filterStages.end()) + { m_sampleBuffer.push_back(s); + } } + m_mutex.unlock(); + m_sampleSink->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), positiveOnly); m_sampleBuffer.clear(); } @@ -125,12 +136,16 @@ void Channelizer::applyConfiguration() return; } + m_mutex.lock(); + freeFilterChain(); m_currentCenterFrequency = createFilterChain( m_inputSampleRate / -2, m_inputSampleRate / 2, m_requestedCenterFrequency - m_requestedOutputSampleRate / 2, m_requestedCenterFrequency + m_requestedOutputSampleRate / 2); + m_mutex.unlock(); + m_currentOutputSampleRate = m_inputSampleRate / (1 << m_filterStages.size()); qDebug() << "Channelizer::applyConfiguration in=" << m_inputSampleRate