mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-16 05:11:49 -05:00
UDP Sink: use settings in sink (2)
This commit is contained in:
parent
da8c14791b
commit
24b1002360
@ -21,6 +21,8 @@
|
|||||||
#include "udpsinkmsg.h"
|
#include "udpsinkmsg.h"
|
||||||
#include "udpsink.h"
|
#include "udpsink.h"
|
||||||
|
|
||||||
|
MESSAGE_CLASS_DEFINITION(UDPSink::MsgConfigureUDPSink, Message)
|
||||||
|
MESSAGE_CLASS_DEFINITION(UDPSink::MsgConfigureChannelizer, Message)
|
||||||
MESSAGE_CLASS_DEFINITION(UDPSink::MsgUDPSinkConfigure, Message)
|
MESSAGE_CLASS_DEFINITION(UDPSink::MsgUDPSinkConfigure, Message)
|
||||||
MESSAGE_CLASS_DEFINITION(UDPSink::MsgUDPSinkSpectrum, Message)
|
MESSAGE_CLASS_DEFINITION(UDPSink::MsgUDPSinkSpectrum, Message)
|
||||||
MESSAGE_CLASS_DEFINITION(UDPSink::MsgResetReadIndex, Message)
|
MESSAGE_CLASS_DEFINITION(UDPSink::MsgResetReadIndex, Message)
|
||||||
@ -559,3 +561,82 @@ void UDPSink::apply(bool force)
|
|||||||
|
|
||||||
m_running = m_config;
|
m_running = m_config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UDPSink::applySettings(const UDPSinkSettings& settings, bool force)
|
||||||
|
{
|
||||||
|
if ((settings.m_inputFrequencyOffset != m_settings.m_inputFrequencyOffset) ||
|
||||||
|
(settings.m_outputSampleRate != m_settings.m_outputSampleRate) || force)
|
||||||
|
{
|
||||||
|
m_settingsMutex.lock();
|
||||||
|
m_carrierNco.setFreq(settings.m_inputFrequencyOffset, settings.m_outputSampleRate);
|
||||||
|
m_settingsMutex.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
if((settings.m_outputSampleRate != m_settings.m_outputSampleRate) ||
|
||||||
|
(settings.m_rfBandwidth != m_settings.m_rfBandwidth) ||
|
||||||
|
(settings.m_inputSampleRate != m_settings.m_inputSampleRate) || force)
|
||||||
|
{
|
||||||
|
m_settingsMutex.lock();
|
||||||
|
m_interpolatorDistanceRemain = 0;
|
||||||
|
m_interpolatorConsumed = false;
|
||||||
|
m_interpolatorDistance = (Real) settings.m_inputSampleRate / (Real) settings.m_outputSampleRate;
|
||||||
|
m_interpolator.create(48, settings.m_inputSampleRate, settings.m_rfBandwidth / 2.2, 3.0);
|
||||||
|
m_actualInputSampleRate = settings.m_inputSampleRate;
|
||||||
|
m_udpHandler.resetReadIndex();
|
||||||
|
m_sampleRateSum = 0.0;
|
||||||
|
m_sampleRateAvgCounter = 0;
|
||||||
|
m_spectrumChunkSize = settings.m_inputSampleRate * 0.05; // 50 ms chunk
|
||||||
|
m_spectrumChunkCounter = 0;
|
||||||
|
m_levelNbSamples = settings.m_inputSampleRate * 0.01; // every 10 ms
|
||||||
|
m_levelCalcCount = 0;
|
||||||
|
m_peakLevel = 0.0f;
|
||||||
|
m_levelSum = 0.0f;
|
||||||
|
m_udpHandler.resizeBuffer(settings.m_inputSampleRate);
|
||||||
|
m_inMovingAverage.resize(settings.m_inputSampleRate * 0.01, 1e-10); // 10 ms
|
||||||
|
m_squelchThreshold = settings.m_inputSampleRate * settings.m_squelchGate;
|
||||||
|
initSquelch(m_squelchOpen);
|
||||||
|
m_SSBFilter->create_filter(settings.m_lowCutoff / settings.m_inputSampleRate, settings.m_rfBandwidth / settings.m_inputSampleRate);
|
||||||
|
m_settingsMutex.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((settings.m_squelchGate != m_settings.m_squelchGate) || force)
|
||||||
|
{
|
||||||
|
m_squelchThreshold = settings.m_outputSampleRate * settings.m_squelchGate;
|
||||||
|
initSquelch(m_squelchOpen);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((settings.m_udpAddress != m_settings.m_udpAddress) ||
|
||||||
|
(settings.m_udpPort != m_settings.m_udpPort) || force)
|
||||||
|
{
|
||||||
|
m_settingsMutex.lock();
|
||||||
|
m_udpHandler.configureUDPLink(settings.m_udpAddress, settings.m_udpPort);
|
||||||
|
m_settingsMutex.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((settings.m_channelMute != m_settings.m_channelMute) || force)
|
||||||
|
{
|
||||||
|
if (!settings.m_channelMute) {
|
||||||
|
m_udpHandler.resetReadIndex();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((settings.m_autoRWBalance != m_settings.m_autoRWBalance) || force)
|
||||||
|
{
|
||||||
|
m_settingsMutex.lock();
|
||||||
|
m_udpHandler.setAutoRWBalance(settings.m_autoRWBalance);
|
||||||
|
|
||||||
|
if (!settings.m_autoRWBalance)
|
||||||
|
{
|
||||||
|
m_interpolatorDistanceRemain = 0;
|
||||||
|
m_interpolatorConsumed = false;
|
||||||
|
m_interpolatorDistance = (Real) settings.m_inputSampleRate / (Real) settings.m_outputSampleRate;
|
||||||
|
m_interpolator.create(48, settings.m_inputSampleRate, settings.m_rfBandwidth / 2.2, 3.0);
|
||||||
|
m_actualInputSampleRate = settings.m_inputSampleRate;
|
||||||
|
m_udpHandler.resetReadIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_settingsMutex.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_settings = settings;
|
||||||
|
}
|
||||||
|
@ -36,6 +36,53 @@ class UDPSink : public BasebandSampleSource {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
class MsgConfigureUDPSink : public Message {
|
||||||
|
MESSAGE_CLASS_DECLARATION
|
||||||
|
|
||||||
|
public:
|
||||||
|
const UDPSinkSettings& getSettings() const { return m_settings; }
|
||||||
|
bool getForce() const { return m_force; }
|
||||||
|
|
||||||
|
static MsgConfigureUDPSink* create(const UDPSinkSettings& settings, bool force)
|
||||||
|
{
|
||||||
|
return new MsgConfigureUDPSink(settings, force);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
UDPSinkSettings m_settings;
|
||||||
|
bool m_force;
|
||||||
|
|
||||||
|
MsgConfigureUDPSink(const UDPSinkSettings& settings, bool force) :
|
||||||
|
Message(),
|
||||||
|
m_settings(settings),
|
||||||
|
m_force(force)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class MsgConfigureChannelizer : public Message {
|
||||||
|
MESSAGE_CLASS_DECLARATION
|
||||||
|
|
||||||
|
public:
|
||||||
|
int getSampleRate() const { return m_sampleRate; }
|
||||||
|
int getCenterFrequency() const { return m_centerFrequency; }
|
||||||
|
|
||||||
|
static MsgConfigureChannelizer* create(int sampleRate, int centerFrequency)
|
||||||
|
{
|
||||||
|
return new MsgConfigureChannelizer(sampleRate, centerFrequency);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_sampleRate;
|
||||||
|
int m_centerFrequency;
|
||||||
|
|
||||||
|
MsgConfigureChannelizer(int sampleRate, int centerFrequency) :
|
||||||
|
Message(),
|
||||||
|
m_sampleRate(sampleRate),
|
||||||
|
m_centerFrequency(centerFrequency)
|
||||||
|
{ }
|
||||||
|
};
|
||||||
|
|
||||||
UDPSink(MessageQueue* uiMessageQueue, UDPSinkGUI* udpSinkGUI, BasebandSampleSink* spectrum);
|
UDPSink(MessageQueue* uiMessageQueue, UDPSinkGUI* udpSinkGUI, BasebandSampleSink* spectrum);
|
||||||
virtual ~UDPSink();
|
virtual ~UDPSink();
|
||||||
|
|
||||||
@ -276,6 +323,7 @@ private:
|
|||||||
|
|
||||||
Config m_config;
|
Config m_config;
|
||||||
Config m_running;
|
Config m_running;
|
||||||
|
UDPSinkSettings m_settings;
|
||||||
|
|
||||||
NCO m_carrierNco;
|
NCO m_carrierNco;
|
||||||
Complex m_modSample;
|
Complex m_modSample;
|
||||||
@ -324,6 +372,7 @@ private:
|
|||||||
static const int m_ssbFftLen = 1024;
|
static const int m_ssbFftLen = 1024;
|
||||||
|
|
||||||
void apply(bool force);
|
void apply(bool force);
|
||||||
|
void applySettings(const UDPSinkSettings& settings, bool force = false);
|
||||||
void modulateSample();
|
void modulateSample();
|
||||||
void calculateLevel(Real sample);
|
void calculateLevel(Real sample);
|
||||||
void calculateLevel(Complex sample);
|
void calculateLevel(Complex sample);
|
||||||
|
Loading…
Reference in New Issue
Block a user