2015-11-19 02:55:58 -05:00
|
|
|
#ifndef INCLUDE_UDPSRC_H
|
|
|
|
#define INCLUDE_UDPSRC_H
|
2015-11-18 21:27:37 -05:00
|
|
|
|
|
|
|
#include <QMutex>
|
|
|
|
#include <QHostAddress>
|
|
|
|
#include "dsp/samplesink.h"
|
|
|
|
#include "dsp/nco.h"
|
|
|
|
#include "dsp/fftfilt.h"
|
|
|
|
#include "dsp/interpolator.h"
|
|
|
|
#include "util/message.h"
|
|
|
|
|
2015-11-19 02:55:58 -05:00
|
|
|
#define udpFftLen 2048
|
2015-11-18 21:27:37 -05:00
|
|
|
|
2015-12-01 20:28:31 -05:00
|
|
|
class QUdpSocket;
|
2015-11-18 21:27:37 -05:00
|
|
|
class UDPSrcGUI;
|
|
|
|
|
|
|
|
class UDPSrc : public SampleSink {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum SampleFormat {
|
|
|
|
FormatSSB,
|
|
|
|
FormatNFM,
|
|
|
|
FormatS16LE,
|
|
|
|
FormatNone
|
|
|
|
};
|
|
|
|
|
|
|
|
UDPSrc(MessageQueue* uiMessageQueue, UDPSrcGUI* udpSrcGUI, SampleSink* spectrum);
|
|
|
|
virtual ~UDPSrc();
|
|
|
|
|
2015-12-01 20:28:31 -05:00
|
|
|
void configure(MessageQueue* messageQueue, SampleFormat sampleFormat, Real outputSampleRate, Real rfBandwidth, QString& udpAddress, int udpPort, int boost);
|
2015-11-18 21:27:37 -05:00
|
|
|
void setSpectrum(MessageQueue* messageQueue, bool enabled);
|
|
|
|
Real getMagSq() const { return m_magsq; }
|
|
|
|
|
|
|
|
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly);
|
|
|
|
virtual void start();
|
|
|
|
virtual void stop();
|
|
|
|
virtual bool handleMessage(const Message& cmd);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
class MsgUDPSrcConfigure : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
SampleFormat getSampleFormat() const { return m_sampleFormat; }
|
|
|
|
Real getOutputSampleRate() const { return m_outputSampleRate; }
|
|
|
|
Real getRFBandwidth() const { return m_rfBandwidth; }
|
2015-12-01 20:28:31 -05:00
|
|
|
const QString& getUDPAddress() const { return m_udpAddress; }
|
2015-11-19 02:55:58 -05:00
|
|
|
int getUDPPort() const { return m_udpPort; }
|
2015-11-18 21:27:37 -05:00
|
|
|
int getBoost() const { return m_boost; }
|
|
|
|
|
2015-12-01 20:28:31 -05:00
|
|
|
static MsgUDPSrcConfigure* create(SampleFormat sampleFormat, Real sampleRate, Real rfBandwidth, QString& udpAddress, int udpPort, int boost)
|
2015-11-18 21:27:37 -05:00
|
|
|
{
|
2015-12-01 20:28:31 -05:00
|
|
|
return new MsgUDPSrcConfigure(sampleFormat, sampleRate, rfBandwidth, udpAddress, udpPort, boost);
|
2015-11-18 21:27:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
SampleFormat m_sampleFormat;
|
|
|
|
Real m_outputSampleRate;
|
|
|
|
Real m_rfBandwidth;
|
2015-12-01 20:28:31 -05:00
|
|
|
QString m_udpAddress;
|
2015-11-19 02:55:58 -05:00
|
|
|
int m_udpPort;
|
2015-11-18 21:27:37 -05:00
|
|
|
int m_boost;
|
|
|
|
|
2015-12-01 20:28:31 -05:00
|
|
|
MsgUDPSrcConfigure(SampleFormat sampleFormat, Real outputSampleRate, Real rfBandwidth, QString& udpAddress, int udpPort, int boost) :
|
2015-11-18 21:27:37 -05:00
|
|
|
Message(),
|
|
|
|
m_sampleFormat(sampleFormat),
|
|
|
|
m_outputSampleRate(outputSampleRate),
|
|
|
|
m_rfBandwidth(rfBandwidth),
|
2015-12-01 20:28:31 -05:00
|
|
|
m_udpAddress(udpAddress),
|
2015-11-19 02:55:58 -05:00
|
|
|
m_udpPort(udpPort),
|
2015-11-18 21:27:37 -05:00
|
|
|
m_boost(boost)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
class MsgUDPSrcSpectrum : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
bool getEnabled() const { return m_enabled; }
|
|
|
|
|
|
|
|
static MsgUDPSrcSpectrum* create(bool enabled)
|
|
|
|
{
|
|
|
|
return new MsgUDPSrcSpectrum(enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool m_enabled;
|
|
|
|
|
|
|
|
MsgUDPSrcSpectrum(bool enabled) :
|
|
|
|
Message(),
|
|
|
|
m_enabled(enabled)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
MessageQueue* m_uiMessageQueue;
|
2015-11-19 02:55:58 -05:00
|
|
|
UDPSrcGUI* m_udpSrcGUI;
|
2015-12-01 20:28:31 -05:00
|
|
|
QUdpSocket *m_socket;
|
2015-11-18 21:27:37 -05:00
|
|
|
|
|
|
|
int m_inputSampleRate;
|
|
|
|
|
|
|
|
int m_sampleFormat;
|
|
|
|
Real m_outputSampleRate;
|
|
|
|
Real m_rfBandwidth;
|
2015-12-01 20:28:31 -05:00
|
|
|
QHostAddress m_udpAddress;
|
|
|
|
quint16 m_udpPort;
|
2015-11-18 21:27:37 -05:00
|
|
|
int m_boost;
|
|
|
|
Real m_magsq;
|
|
|
|
|
|
|
|
Real m_scale;
|
|
|
|
Complex m_last, m_this;
|
|
|
|
|
|
|
|
NCO m_nco;
|
|
|
|
Interpolator m_interpolator;
|
|
|
|
Real m_sampleDistanceRemain;
|
2015-11-19 02:55:58 -05:00
|
|
|
fftfilt* UDPFilter;
|
2015-11-18 21:27:37 -05:00
|
|
|
|
|
|
|
SampleVector m_sampleBuffer;
|
|
|
|
SampleVector m_sampleBufferSSB;
|
|
|
|
SampleSink* m_spectrum;
|
|
|
|
bool m_spectrumEnabled;
|
|
|
|
|
|
|
|
quint32 m_nextSSBId;
|
|
|
|
quint32 m_nextS16leId;
|
|
|
|
|
|
|
|
QMutex m_settingsMutex;
|
|
|
|
};
|
|
|
|
|
2015-11-19 02:55:58 -05:00
|
|
|
#endif // INCLUDE_UDPSRC_H
|