2016-10-17 02:58:49 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2016 F4EXB //
|
|
|
|
// written by Edouard Griffiths //
|
|
|
|
// //
|
|
|
|
// This program is free software; you can redistribute it and/or modify //
|
|
|
|
// it under the terms of the GNU General Public License as published by //
|
|
|
|
// the Free Software Foundation as version 3 of the License, or //
|
|
|
|
// //
|
|
|
|
// This program is distributed in the hope that it will be useful, //
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
|
|
// GNU General Public License V3 for more details. //
|
|
|
|
// //
|
|
|
|
// You should have received a copy of the GNU General Public License //
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef SDRBASE_DSP_DOWNCHANNELIZER_H
|
|
|
|
#define SDRBASE_DSP_DOWNCHANNELIZER_H
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2016-10-02 16:29:04 -04:00
|
|
|
#include <dsp/basebandsamplesink.h>
|
2014-05-18 11:52:39 -04:00
|
|
|
#include <list>
|
2015-09-06 04:21:06 -04:00
|
|
|
#include <QMutex>
|
2018-03-20 08:49:21 -04:00
|
|
|
#include "export.h"
|
2015-08-19 16:12:52 -04:00
|
|
|
#include "util/message.h"
|
2018-05-07 19:35:08 -04:00
|
|
|
#include "dsp/inthalfbandfiltereo.h"
|
2016-10-29 11:01:02 -04:00
|
|
|
|
|
|
|
#define DOWNCHANNELIZER_HB_FILTER_ORDER 48
|
2014-05-18 11:52:39 -04:00
|
|
|
|
|
|
|
class MessageQueue;
|
|
|
|
|
2018-03-03 14:23:38 -05:00
|
|
|
class SDRBASE_API DownChannelizer : public BasebandSampleSink {
|
2015-07-12 03:32:54 -04:00
|
|
|
Q_OBJECT
|
2014-05-18 11:52:39 -04:00
|
|
|
public:
|
2018-11-13 10:02:26 -05:00
|
|
|
class SDRBASE_API MsgChannelizerNotification : public Message {
|
2015-08-19 16:12:52 -04:00
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
MsgChannelizerNotification(int samplerate, qint64 frequencyOffset) :
|
|
|
|
Message(),
|
|
|
|
m_sampleRate(samplerate),
|
|
|
|
m_frequencyOffset(frequencyOffset)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
int getSampleRate() const { return m_sampleRate; }
|
|
|
|
qint64 getFrequencyOffset() const { return m_frequencyOffset; }
|
|
|
|
|
2017-12-28 23:14:40 -05:00
|
|
|
static MsgChannelizerNotification* create(int samplerate, qint64 frequencyOffset)
|
|
|
|
{
|
|
|
|
return new MsgChannelizerNotification(samplerate, frequencyOffset);
|
|
|
|
}
|
|
|
|
|
2015-08-19 16:12:52 -04:00
|
|
|
private:
|
|
|
|
int m_sampleRate;
|
|
|
|
qint64 m_frequencyOffset;
|
|
|
|
};
|
|
|
|
|
2016-10-02 16:29:04 -04:00
|
|
|
DownChannelizer(BasebandSampleSink* sampleSink);
|
2016-10-02 15:52:39 -04:00
|
|
|
virtual ~DownChannelizer();
|
2014-05-18 11:52:39 -04:00
|
|
|
|
|
|
|
void configure(MessageQueue* messageQueue, int sampleRate, int centerFrequency);
|
2015-07-12 03:32:54 -04:00
|
|
|
int getInputSampleRate() const { return m_inputSampleRate; }
|
2018-02-24 21:22:30 -05:00
|
|
|
int getRequestedCenterFrequency() const { return m_requestedCenterFrequency; }
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2015-08-13 23:00:28 -04:00
|
|
|
virtual void start();
|
|
|
|
virtual void stop();
|
2015-08-25 02:24:23 -04:00
|
|
|
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly);
|
2015-08-13 23:00:28 -04:00
|
|
|
virtual bool handleMessage(const Message& cmd);
|
2014-05-18 11:52:39 -04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
struct FilterStage {
|
|
|
|
enum Mode {
|
|
|
|
ModeCenter,
|
|
|
|
ModeLowerHalf,
|
|
|
|
ModeUpperHalf
|
|
|
|
};
|
|
|
|
|
2018-01-22 02:46:05 -05:00
|
|
|
#ifdef SDR_RX_SAMPLE_24BIT
|
2018-05-07 19:35:08 -04:00
|
|
|
typedef bool (IntHalfbandFilterEO<qint64, qint64, DOWNCHANNELIZER_HB_FILTER_ORDER>::*WorkFunction)(Sample* s);
|
|
|
|
IntHalfbandFilterEO<qint64, qint64, DOWNCHANNELIZER_HB_FILTER_ORDER>* m_filter;
|
2016-11-07 12:51:32 -05:00
|
|
|
#else
|
2018-05-07 19:35:08 -04:00
|
|
|
typedef bool (IntHalfbandFilterEO<qint32, qint32, DOWNCHANNELIZER_HB_FILTER_ORDER>::*WorkFunction)(Sample* s);
|
|
|
|
IntHalfbandFilterEO<qint32, qint32, DOWNCHANNELIZER_HB_FILTER_ORDER>* m_filter;
|
2016-11-07 12:51:32 -05:00
|
|
|
#endif
|
2018-05-01 16:02:30 -04:00
|
|
|
|
2014-05-18 11:52:39 -04:00
|
|
|
WorkFunction m_workFunction;
|
2017-05-11 20:41:51 -04:00
|
|
|
Mode m_mode;
|
|
|
|
bool m_sse;
|
2014-05-18 11:52:39 -04:00
|
|
|
|
|
|
|
FilterStage(Mode mode);
|
|
|
|
~FilterStage();
|
|
|
|
|
|
|
|
bool work(Sample* sample)
|
|
|
|
{
|
|
|
|
return (m_filter->*m_workFunction)(sample);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
typedef std::list<FilterStage*> FilterStages;
|
|
|
|
FilterStages m_filterStages;
|
2016-10-17 02:58:49 -04:00
|
|
|
BasebandSampleSink* m_sampleSink; //!< Demodulator
|
2014-05-18 11:52:39 -04:00
|
|
|
int m_inputSampleRate;
|
|
|
|
int m_requestedOutputSampleRate;
|
|
|
|
int m_requestedCenterFrequency;
|
|
|
|
int m_currentOutputSampleRate;
|
|
|
|
int m_currentCenterFrequency;
|
|
|
|
SampleVector m_sampleBuffer;
|
2015-09-06 04:21:06 -04:00
|
|
|
QMutex m_mutex;
|
2014-05-18 11:52:39 -04:00
|
|
|
|
|
|
|
void applyConfiguration();
|
|
|
|
bool signalContainsChannel(Real sigStart, Real sigEnd, Real chanStart, Real chanEnd) const;
|
|
|
|
Real createFilterChain(Real sigStart, Real sigEnd, Real chanStart, Real chanEnd);
|
|
|
|
void freeFilterChain();
|
2017-05-11 20:41:51 -04:00
|
|
|
void debugFilterChain();
|
2015-07-12 03:32:54 -04:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void inputSampleRateChanged();
|
2014-05-18 11:52:39 -04:00
|
|
|
};
|
|
|
|
|
2016-10-17 02:58:49 -04:00
|
|
|
#endif // SDRBASE_DSP_DOWNCHANNELIZER_H
|