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.
upchannelizer.h
Go to the documentation of this file.
1 // Copyright (C) 2016 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_UPCHANNELIZER_H_
20 #define SDRBASE_DSP_UPCHANNELIZER_H_
21 
23 #include <vector>
24 #include <QMutex>
25 #include "export.h"
26 #include "util/message.h"
27 #ifdef USE_SSE4_1
29 #else
31 #endif
32 
33 #define UPCHANNELIZER_HB_FILTER_ORDER 96
34 
35 class MessageQueue;
36 
38  Q_OBJECT
39 public:
42 
43  public:
44  MsgChannelizerNotification(int basebandSampleRate, int samplerate, qint64 frequencyOffset) :
45  Message(),
46  m_basebandSampleRate(basebandSampleRate),
47  m_sampleRate(samplerate),
48  m_frequencyOffset(frequencyOffset)
49  { }
50 
51  int getBasebandSampleRate() const { return m_basebandSampleRate; }
52  int getSampleRate() const { return m_sampleRate; }
53  qint64 getFrequencyOffset() const { return m_frequencyOffset; }
54 
55  static MsgChannelizerNotification* create(int basebandSampleRate, int samplerate, qint64 frequencyOffset)
56  {
57  return new MsgChannelizerNotification(basebandSampleRate, samplerate, frequencyOffset);
58  }
59 
60  private:
64  };
65 
68 
69  public:
70  MsgSetChannelizer(unsigned int log2Interp, unsigned int filterChainHash) :
71  Message(),
72  m_log2interp(log2Interp),
73  m_filterChainHash(filterChainHash)
74  { }
75 
76  unsigned int getLog2Interp() const { return m_log2interp; }
77  unsigned int getFilterChainHash() const { return m_filterChainHash; }
78 
79  private:
80  unsigned int m_log2interp;
81  unsigned int m_filterChainHash;
82  };
83 
85  virtual ~UpChannelizer();
86 
87  void configure(MessageQueue* messageQueue, int sampleRate, int centerFrequency);
88  void set(MessageQueue* messageQueue, unsigned int log2Interp, unsigned int filterChainHash);
89  int getOutputSampleRate() const { return m_outputSampleRate; }
90 
91  virtual void start();
92  virtual void stop();
93  virtual void pull(Sample& sample);
94  virtual void pullAudio(int nbSamples) { if (m_sampleSource) m_sampleSource->pullAudio(nbSamples); }
95 
96  virtual bool handleMessage(const Message& cmd);
97 
98 protected:
99  struct FilterStage {
100  enum Mode {
103  ModeUpperHalf
104  };
105 
106 #ifdef USE_SSE4_1
107  typedef bool (IntHalfbandFilterEO1<UPCHANNELIZER_HB_FILTER_ORDER>::*WorkFunction)(Sample* sIn, Sample *sOut);
109 #else
112 #endif
113  WorkFunction m_workFunction;
114 
115  FilterStage(Mode mode);
116  ~FilterStage();
117 
118  bool work(Sample* sampleIn, Sample *sampleOut)
119  {
120  return (m_filter->*m_workFunction)(sampleIn, sampleOut);
121  }
122  };
123  typedef std::vector<FilterStage*> FilterStages;
124  FilterStages m_filterStages;
126  std::vector<Sample> m_stageSamples;
135  QMutex m_mutex;
136 
137  void applyConfiguration();
138  void applySetting(unsigned int log2Decim, unsigned int filterChainHash);
139  bool signalContainsChannel(Real sigStart, Real sigEnd, Real chanStart, Real chanEnd) const;
140  Real createFilterChain(Real sigStart, Real sigEnd, Real chanStart, Real chanEnd);
141  double setFilterChain(const std::vector<unsigned int>& stageIndexes);
142  void freeFilterChain();
143 
144 signals:
145  void outputSampleRateChanged();
146 };
147 
148 #endif /* SDRBASE_DSP_UPCHANNELIZER_H_ */
virtual void pullAudio(int nbSamples)
Definition: upchannelizer.h:94
FilterStages m_filterStages
std::vector< Sample > SampleVector
Definition: dsptypes.h:96
unsigned int getFilterChainHash() const
Definition: upchannelizer.h:77
int m_requestedInputSampleRate
int m_currentCenterFrequency
bool work(Sample *sampleIn, Sample *sampleOut)
BasebandSampleSource * m_sampleSource
Modulator.
IntHalfbandFilterDB< qint32, UPCHANNELIZER_HB_FILTER_ORDER > * m_filter
unsigned int getLog2Interp() const
Definition: upchannelizer.h:76
MsgChannelizerNotification(int basebandSampleRate, int samplerate, qint64 frequencyOffset)
Definition: upchannelizer.h:44
int getOutputSampleRate() const
Definition: upchannelizer.h:89
static MsgChannelizerNotification * create(int basebandSampleRate, int samplerate, qint64 frequencyOffset)
Definition: upchannelizer.h:55
#define MESSAGE_CLASS_DECLARATION
Definition: message.h:43
SampleVector m_sampleBuffer
bool m_filterChainSetMode
int m_requestedCenterFrequency
int m_currentInputSampleRate
std::vector< FilterStage * > FilterStages
MsgSetChannelizer(unsigned int log2Interp, unsigned int filterChainHash)
Definition: upchannelizer.h:70
#define SDRBASE_API
Definition: export.h:40
float Real
Definition: dsptypes.h:42
std::vector< Sample > m_stageSamples