SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
downchannelizer.h
Go to the documentation of this file.
1 // Copyright (C) 2016-2019 F4EXB //
3 // written by Edouard Griffiths //
4 // //
5 // This program is free software; you can redistribute it and/or modify //
6 // it under the terms of the GNU General Public License as published by //
7 // the Free Software Foundation as version 3 of the License, or //
8 // (at your option) any later version. //
9 // //
10 // This program is distributed in the hope that it will be useful, //
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
13 // GNU General Public License V3 for more details. //
14 // //
15 // You should have received a copy of the GNU General Public License //
16 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
18 
19 #ifndef SDRBASE_DSP_DOWNCHANNELIZER_H
20 #define SDRBASE_DSP_DOWNCHANNELIZER_H
21 
22 #include <dsp/basebandsamplesink.h>
23 #include <list>
24 #include <vector>
25 #include <QMutex>
26 #include "export.h"
27 #include "util/message.h"
29 
30 #define DOWNCHANNELIZER_HB_FILTER_ORDER 48
31 
32 class MessageQueue;
33 
35  Q_OBJECT
36 public:
39 
40  public:
41  MsgChannelizerNotification(int samplerate, qint64 frequencyOffset) :
42  Message(),
43  m_sampleRate(samplerate),
44  m_frequencyOffset(frequencyOffset)
45  { }
46 
47  int getSampleRate() const { return m_sampleRate; }
48  qint64 getFrequencyOffset() const { return m_frequencyOffset; }
49 
50  static MsgChannelizerNotification* create(int samplerate, qint64 frequencyOffset)
51  {
52  return new MsgChannelizerNotification(samplerate, frequencyOffset);
53  }
54 
55  private:
58  };
59 
62 
63  public:
64  MsgSetChannelizer(unsigned int log2Decim, unsigned int filterChainHash) :
65  Message(),
66  m_log2Decim(log2Decim),
67  m_filterChainHash(filterChainHash)
68  { }
69 
70  unsigned int getLog2Decim() const { return m_log2Decim; }
71  unsigned int getFilterChainHash() const { return m_filterChainHash; }
72 
73  private:
74  unsigned int m_log2Decim;
75  unsigned int m_filterChainHash;
76  };
77 
79  virtual ~DownChannelizer();
80 
81  void configure(MessageQueue* messageQueue, int sampleRate, int centerFrequency);
82  void set(MessageQueue* messageQueue, unsigned int log2Decim, unsigned int filterChainHash);
83  int getInputSampleRate() const { return m_inputSampleRate; }
84  int getRequestedCenterFrequency() const { return m_requestedCenterFrequency; }
85 
86  virtual void start();
87  virtual void stop();
88  virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly);
89  virtual bool handleMessage(const Message& cmd);
90 
91 protected:
92  struct FilterStage {
93  enum Mode {
96  ModeUpperHalf
97  };
98 
99 #ifdef SDR_RX_SAMPLE_24BIT
102 #else
105 #endif
106 
107  WorkFunction m_workFunction;
109  bool m_sse;
110 
111  FilterStage(Mode mode);
112  ~FilterStage();
113 
114  bool work(Sample* sample)
115  {
116  return (m_filter->*m_workFunction)(sample);
117  }
118  };
119  typedef std::list<FilterStage*> FilterStages;
120  FilterStages m_filterStages;
129  QMutex m_mutex;
130 
131  void applyConfiguration();
132  void applySetting(unsigned int log2Decim, unsigned int filterChainHash);
133  bool signalContainsChannel(Real sigStart, Real sigEnd, Real chanStart, Real chanEnd) const;
134  Real createFilterChain(Real sigStart, Real sigEnd, Real chanStart, Real chanEnd);
135  void setFilterChain(const std::vector<unsigned int>& stageIndexes);
136  void freeFilterChain();
137  void debugFilterChain();
138 
139 signals:
140  void inputSampleRateChanged();
141 };
142 
143 #endif // SDRBASE_DSP_DOWNCHANNELIZER_H
std::vector< Sample > SampleVector
Definition: dsptypes.h:96
unsigned int getFilterChainHash() const
MsgSetChannelizer(unsigned int log2Decim, unsigned int filterChainHash)
int getRequestedCenterFrequency() const
SampleVector m_sampleBuffer
FilterStages m_filterStages
#define MESSAGE_CLASS_DECLARATION
Definition: message.h:43
IntHalfbandFilterEO< qint32, qint32, DOWNCHANNELIZER_HB_FILTER_ORDER > * m_filter
std::list< FilterStage * > FilterStages
int getInputSampleRate() const
bool work(Sample *sample)
#define SDRBASE_API
Definition: export.h:40
BasebandSampleSink * m_sampleSink
Demodulator.
MsgChannelizerNotification(int samplerate, qint64 frequencyOffset)
float Real
Definition: dsptypes.h:42
static MsgChannelizerNotification * create(int samplerate, qint64 frequencyOffset)