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.
basebandsamplesource.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_BASEBANDSAMPLESOURCE_H_
20 #define SDRBASE_DSP_BASEBANDSAMPLESOURCE_H_
21 
22 #include <QObject>
23 #include "dsp/dsptypes.h"
24 #include "dsp/samplesourcefifo.h"
25 #include "export.h"
26 #include "util/messagequeue.h"
27 
28 class Message;
29 
30 class SDRBASE_API BasebandSampleSource : public QObject {
31  Q_OBJECT
32 public:
34  virtual ~BasebandSampleSource();
35 
36  virtual void start() = 0;
37  virtual void stop() = 0;
38  virtual void pull(Sample& sample) = 0;
39  virtual void pullAudio(int nbSamples) { (void) nbSamples; }
40 
42  void feed(SampleSourceFifo* sampleFifo, int nbSamples)
43  {
44  SampleVector::iterator writeAt;
45  sampleFifo->getWriteIterator(writeAt);
46  pullAudio(nbSamples); // Pre-fetch input audio samples this is mandatory to keep things running smoothly
47 
48  for (int i = 0; i < nbSamples; i++)
49  {
50  pull((*writeAt));
51  sampleFifo->bumpIndex(writeAt);
52  }
53  }
54 
55  SampleSourceFifo& getSampleSourceFifo() { return m_sampleFifo; }
56 
57  virtual bool handleMessage(const Message& cmd) = 0;
58 
59  MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; }
60  virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
61  MessageQueue *getMessageQueueToGUI() { return m_guiMessageQueue; }
62  void setDeviceSampleSourceFifo(SampleSourceFifo *deviceSampleFifo);
63 
64 protected:
69 
70  void handleWriteToFifo(SampleSourceFifo *sampleFifo, int nbSamples);
71 
72 protected slots:
73  void handleInputMessages();
74  void handleWriteToFifo(int nbSamples);
75  void handleWriteToDeviceFifo(int nbSamples);
76 };
77 
78 #endif /* SDRBASE_DSP_BASEBANDSAMPLESOURCE_H_ */
virtual void pullAudio(int nbSamples)
MessageQueue * getInputMessageQueue()
Get the queue for asynchronous inbound communication.
void bumpIndex(SampleVector::iterator &writeAt)
copy current item to second buffer and bump write index - write phase 2
int32_t i
Definition: decimators.h:244
virtual void setMessageQueueToGUI(MessageQueue *queue)
SampleSourceFifo * m_deviceSampleFifo
Reference to the device FIFO for single channel processing.
SampleSourceFifo m_sampleFifo
Internal FIFO for multi-channel processing.
MessageQueue * getMessageQueueToGUI()
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
MessageQueue m_inputMessageQueue
Queue for asynchronous inbound communication.
void feed(SampleSourceFifo *sampleFifo, int nbSamples)
#define SDRBASE_API
Definition: export.h:40
void getWriteIterator(SampleVector::iterator &writeAt)
get iterator to current item for update - write phase 1
SampleSourceFifo & getSampleSourceFifo()