sdrangel/plugins/channeltx/udpsink/udpsink.h

173 wiersze
5.4 KiB
C
Czysty Zwykły widok Historia

2017-08-13 23:39:26 +00:00
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2017 Edouard Griffiths, F4EXB //
// //
// 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 PLUGINS_CHANNELTX_UDPSINK_UDPSINK_H_
#define PLUGINS_CHANNELTX_UDPSINK_UDPSINK_H_
#include <QObject>
#include "dsp/basebandsamplesource.h"
#include "dsp/basebandsamplesink.h"
2017-08-14 08:59:05 +00:00
#include "dsp/interpolator.h"
#include "dsp/nco.h"
2017-08-13 23:39:26 +00:00
#include "util/message.h"
class UDPSinkGUI;
class UDPSink : public BasebandSampleSource {
Q_OBJECT
public:
enum SampleFormat {
FormatS16LE,
FormatNFM,
FormatNFMMono,
FormatLSB,
FormatUSB,
FormatLSBMono,
FormatUSBMono,
FormatAMMono,
FormatNone
};
UDPSink(MessageQueue* uiMessageQueue, UDPSinkGUI* udpSinkGUI, BasebandSampleSink* spectrum);
virtual ~UDPSink();
virtual void start();
virtual void stop();
virtual void pull(Sample& sample);
virtual bool handleMessage(const Message& cmd);
void configure(MessageQueue* messageQueue,
SampleFormat sampleFormat,
Real inputSampleRate,
Real rfBandwidth,
int fmDeviation,
QString& udpAddress,
2017-08-14 08:59:05 +00:00
int udpPort,
bool channelMute);
2017-08-13 23:39:26 +00:00
private:
class MsgUDPSinkConfigure : public Message {
MESSAGE_CLASS_DECLARATION
public:
SampleFormat getSampleFormat() const { return m_sampleFormat; }
Real getInputSampleRate() const { return m_inputSampleRate; }
Real getRFBandwidth() const { return m_rfBandwidth; }
int getFMDeviation() const { return m_fmDeviation; }
const QString& getUDPAddress() const { return m_udpAddress; }
int getUDPPort() const { return m_udpPort; }
2017-08-14 08:59:05 +00:00
bool getChannelMute() const { return m_channelMute; }
2017-08-13 23:39:26 +00:00
static MsgUDPSinkConfigure* create(SampleFormat
sampleFormat,
Real inputSampleRate,
Real rfBandwidth,
int fmDeviation,
QString& udpAddress,
2017-08-14 08:59:05 +00:00
int udpPort,
bool channelMute)
2017-08-13 23:39:26 +00:00
{
return new MsgUDPSinkConfigure(sampleFormat,
inputSampleRate,
rfBandwidth,
fmDeviation,
udpAddress,
2017-08-14 08:59:05 +00:00
udpPort,
channelMute);
2017-08-13 23:39:26 +00:00
}
private:
SampleFormat m_sampleFormat;
Real m_inputSampleRate;
Real m_rfBandwidth;
int m_fmDeviation;
QString m_udpAddress;
int m_udpPort;
2017-08-14 08:59:05 +00:00
bool m_channelMute;
2017-08-13 23:39:26 +00:00
MsgUDPSinkConfigure(SampleFormat sampleFormat,
Real inputSampleRate,
Real rfBandwidth,
int fmDeviation,
QString& udpAddress,
2017-08-14 08:59:05 +00:00
int udpPort,
bool channelMute) :
2017-08-13 23:39:26 +00:00
Message(),
m_sampleFormat(sampleFormat),
m_inputSampleRate(inputSampleRate),
m_rfBandwidth(rfBandwidth),
m_fmDeviation(fmDeviation),
m_udpAddress(udpAddress),
2017-08-14 08:59:05 +00:00
m_udpPort(udpPort),
m_channelMute(channelMute)
2017-08-13 23:39:26 +00:00
{ }
};
struct Config {
int m_basebandSampleRate;
Real m_outputSampleRate;
int m_sampleFormat;
Real m_inputSampleRate;
qint64 m_inputFrequencyOffset;
Real m_rfBandwidth;
int m_fmDeviation;
2017-08-14 08:59:05 +00:00
bool m_channelMute;
2017-08-13 23:39:26 +00:00
QString m_udpAddressStr;
quint16 m_udpPort;
Config() :
2017-08-14 08:59:05 +00:00
m_basebandSampleRate(48000),
m_outputSampleRate(48000),
2017-08-13 23:39:26 +00:00
m_sampleFormat(0),
2017-08-14 08:59:05 +00:00
m_inputSampleRate(48000),
2017-08-13 23:39:26 +00:00
m_inputFrequencyOffset(0),
2017-08-14 08:59:05 +00:00
m_rfBandwidth(12500),
m_fmDeviation(1.0),
m_channelMute(false),
2017-08-13 23:39:26 +00:00
m_udpAddressStr("127.0.0.1"),
m_udpPort(9999)
{}
};
Config m_config;
Config m_running;
2017-08-14 08:59:05 +00:00
NCO m_carrierNco;
Complex m_modSample;
2017-08-13 23:39:26 +00:00
MessageQueue* m_uiMessageQueue;
UDPSinkGUI* m_udpSinkGUI;
BasebandSampleSink* m_spectrum;
2017-08-14 08:59:05 +00:00
Interpolator m_interpolator;
Real m_interpolatorDistance;
Real m_interpolatorDistanceRemain;
bool m_interpolatorConsumed;
2017-08-13 23:39:26 +00:00
QMutex m_settingsMutex;
2017-08-14 08:59:05 +00:00
void apply(bool force);
void modulateSample();
2017-08-13 23:39:26 +00:00
};
#endif /* PLUGINS_CHANNELTX_UDPSINK_UDPSINK_H_ */