UDP Sink: use settings in sink (6)

This commit is contained in:
f4exb 2017-10-17 00:27:48 +02:00
parent 199d7a054e
commit 876001cf8c
3 changed files with 0 additions and 448 deletions

View File

@ -23,7 +23,6 @@
MESSAGE_CLASS_DEFINITION(UDPSink::MsgConfigureUDPSink, Message)
MESSAGE_CLASS_DEFINITION(UDPSink::MsgConfigureChannelizer, Message)
//MESSAGE_CLASS_DEFINITION(UDPSink::MsgUDPSinkConfigure, Message)
MESSAGE_CLASS_DEFINITION(UDPSink::MsgUDPSinkSpectrum, Message)
MESSAGE_CLASS_DEFINITION(UDPSink::MsgResetReadIndex, Message)
@ -359,46 +358,6 @@ bool UDPSink::handleMessage(const Message& cmd)
return true;
}
// else if (MsgUDPSinkConfigure::match(cmd))
// {
// MsgUDPSinkConfigure& cfg = (MsgUDPSinkConfigure&) cmd;
//
// m_config.m_sampleFormat = cfg.getSampleFormat();
// m_config.m_inputSampleRate = cfg.getInputSampleRate();
// m_config.m_rfBandwidth = cfg.getRFBandwidth();
// m_config.m_fmDeviation = cfg.getFMDeviation();
// m_config.m_udpAddressStr = cfg.getUDPAddress();
// m_config.m_udpPort = cfg.getUDPPort();
// m_config.m_channelMute = cfg.getChannelMute();
// m_config.m_gainIn = cfg.getGainIn();
// m_config.m_gainOut = cfg.getGainOut();
// m_config.m_squelch = CalcDb::powerFromdB(cfg.getSquelchDB());
// m_config.m_squelchGate = cfg.getSquelchGate();
// m_config.m_squelchEnabled = cfg.getSquelchEnabled();
// m_config.m_autoRWBalance = cfg.getAutoRWBalance();
// m_config.m_stereoInput = cfg.getStereoInput();
//
// //apply(cfg.getForce());
//
// qDebug() << "UDPSink::handleMessage: MsgUDPSinkConfigure:"
// << " m_sampleFormat: " << m_config.m_sampleFormat
// << " m_inputSampleRate: " << m_config.m_inputSampleRate
// << " m_rfBandwidth: " << m_config.m_rfBandwidth
// << " m_fmDeviation: " << m_config.m_fmDeviation
// << " m_udpAddressStr: " << m_config.m_udpAddressStr
// << " m_udpPort: " << m_config.m_udpPort
// << " m_channelMute: " << m_config.m_channelMute
// << " m_gainIn: " << m_config.m_gainIn
// << " m_gainOut: " << m_config.m_gainOut
// << " squelchDB: " << cfg.getSquelchDB()
// << " m_squelchGate: " << m_config.m_squelchGate
// << " m_squelch: " << m_config.m_squelch
// << " m_squelchEnabled: " << m_config.m_squelchEnabled
// << " m_autoRWBalance: " << m_config.m_autoRWBalance
// << " m_stereoInput: " << m_config.m_stereoInput;
//
// return true;
// }
else if (UDPSinkMessages::MsgSampleRateCorrection::match(cmd))
{
UDPSinkMessages::MsgSampleRateCorrection& cfg = (UDPSinkMessages::MsgSampleRateCorrection&) cmd;
@ -482,43 +441,6 @@ bool UDPSink::handleMessage(const Message& cmd)
}
}
//void UDPSink::configure(MessageQueue* messageQueue,
// UDPSinkSettings::SampleFormat sampleFormat,
// Real inputSampleRate,
// Real rfBandwidth,
// int fmDeviation,
// Real amModFactor,
// const QString& udpAddress,
// int udpPort,
// bool channelMute,
// Real gainIn,
// Real gainOut,
// Real squelchDB,
// Real squelchGate,
// bool squelchEnabled,
// bool autoRWBalance,
// bool stereoInput,
// bool force)
//{
// Message* cmd = MsgUDPSinkConfigure::create(sampleFormat,
// inputSampleRate,
// rfBandwidth,
// fmDeviation,
// amModFactor,
// udpAddress,
// udpPort,
// channelMute,
// gainIn,
// gainOut,
// squelchDB,
// squelchGate,
// squelchEnabled,
// autoRWBalance,
// stereoInput,
// force);
// messageQueue->push(cmd);
//}
void UDPSink::setSpectrum(MessageQueue* messageQueue, bool enabled)
{
Message* cmd = MsgUDPSinkSpectrum::create(enabled);
@ -531,86 +453,6 @@ void UDPSink::resetReadIndex(MessageQueue* messageQueue)
messageQueue->push(cmd);
}
//void UDPSink::apply(bool force)
//{
// if ((m_config.m_inputFrequencyOffset != m_running.m_inputFrequencyOffset) ||
// (m_config.m_outputSampleRate != m_running.m_outputSampleRate) || force)
// {
// m_settingsMutex.lock();
// m_carrierNco.setFreq(m_config.m_inputFrequencyOffset, m_config.m_outputSampleRate);
// m_settingsMutex.unlock();
// }
//
// if((m_config.m_outputSampleRate != m_running.m_outputSampleRate) ||
// (m_config.m_rfBandwidth != m_running.m_rfBandwidth) ||
// (m_config.m_inputSampleRate != m_running.m_inputSampleRate) || force)
// {
// m_settingsMutex.lock();
// m_interpolatorDistanceRemain = 0;
// m_interpolatorConsumed = false;
// m_interpolatorDistance = (Real) m_config.m_inputSampleRate / (Real) m_config.m_outputSampleRate;
// m_interpolator.create(48, m_config.m_inputSampleRate, m_config.m_rfBandwidth / 2.2, 3.0);
// m_actualInputSampleRate = m_config.m_inputSampleRate;
// m_udpHandler.resetReadIndex();
// m_sampleRateSum = 0.0;
// m_sampleRateAvgCounter = 0;
// m_spectrumChunkSize = m_config.m_inputSampleRate * 0.05; // 50 ms chunk
// m_spectrumChunkCounter = 0;
// m_levelNbSamples = m_config.m_inputSampleRate * 0.01; // every 10 ms
// m_levelCalcCount = 0;
// m_peakLevel = 0.0f;
// m_levelSum = 0.0f;
// m_udpHandler.resizeBuffer(m_config.m_inputSampleRate);
// m_inMovingAverage.resize(m_config.m_inputSampleRate * 0.01, 1e-10); // 10 ms
// m_squelchThreshold = m_config.m_inputSampleRate * m_config.m_squelchGate;
// initSquelch(m_squelchOpen);
// m_SSBFilter->create_filter(m_config.m_lowCutoff / m_config.m_inputSampleRate, m_config.m_rfBandwidth / m_config.m_inputSampleRate);
// m_settingsMutex.unlock();
// }
//
// if ((m_config.m_squelchGate != m_running.m_squelchGate) || force)
// {
// m_squelchThreshold = m_config.m_outputSampleRate * m_config.m_squelchGate;
// initSquelch(m_squelchOpen);
// }
//
// if ((m_config.m_udpAddressStr != m_running.m_udpAddressStr) ||
// (m_config.m_udpPort != m_running.m_udpPort) || force)
// {
// m_settingsMutex.lock();
// m_udpHandler.configureUDPLink(m_config.m_udpAddressStr, m_config.m_udpPort);
// m_settingsMutex.unlock();
// }
//
// if ((m_config.m_channelMute != m_running.m_channelMute) || force)
// {
// if (!m_config.m_channelMute) {
// m_udpHandler.resetReadIndex();
// }
// }
//
// if ((m_config.m_autoRWBalance != m_running.m_autoRWBalance) || force)
// {
// m_settingsMutex.lock();
// m_udpHandler.setAutoRWBalance(m_config.m_autoRWBalance);
//
// if (!m_config.m_autoRWBalance)
// {
// m_interpolatorDistanceRemain = 0;
// m_interpolatorConsumed = false;
// m_interpolatorDistance = (Real) m_config.m_inputSampleRate / (Real) m_config.m_outputSampleRate;
// m_interpolator.create(48, m_config.m_inputSampleRate, m_config.m_rfBandwidth / 2.2, 3.0);
// m_actualInputSampleRate = m_config.m_inputSampleRate;
// m_udpHandler.resetReadIndex();
// }
//
// m_settingsMutex.unlock();
// }
//
// m_running = m_config;
//}
void UDPSink::applySettings(const UDPSinkSettings& settings, bool force)
{
if ((settings.m_inputFrequencyOffset != m_settings.m_inputFrequencyOffset) ||

View File

@ -96,23 +96,6 @@ public:
int32_t getBufferGauge() const { return m_udpHandler.getBufferGauge(); }
bool getSquelchOpen() const { return m_squelchOpen; }
// void configure(MessageQueue* messageQueue,
// UDPSinkSettings::SampleFormat sampleFormat,
// Real inputSampleRate,
// Real rfBandwidth,
// int fmDeviation,
// Real amModFactor,
// const QString& udpAddress,
// int udpPort,
// bool channelMute,
// Real gainIn,
// Real gainOut,
// Real squelchDB,
// Real squelchGate,
// bool squelchEnabled,
// bool autoRWBalance,
// bool stereoInput,
// bool force = false);
void setSpectrum(MessageQueue* messageQueue, bool enabled);
void resetReadIndex(MessageQueue* messageQueue);
@ -126,119 +109,6 @@ signals:
void levelChanged(qreal rmsLevel, qreal peakLevel, int numSamples);
private:
// class MsgUDPSinkConfigure : public Message {
// MESSAGE_CLASS_DECLARATION
//
// public:
// UDPSinkSettings::SampleFormat getSampleFormat() const { return m_sampleFormat; }
// Real getInputSampleRate() const { return m_inputSampleRate; }
// Real getRFBandwidth() const { return m_rfBandwidth; }
// int getFMDeviation() const { return m_fmDeviation; }
// Real getAMModFactor() const { return m_amModFactor; }
// const QString& getUDPAddress() const { return m_udpAddress; }
// int getUDPPort() const { return m_udpPort; }
// bool getChannelMute() const { return m_channelMute; }
// Real getGainIn() const { return m_gainIn; }
// Real getGainOut() const { return m_gainOut; }
// Real getSquelchDB() const { return m_squelchDB; }
// Real getSquelchGate() const { return m_squelchGate; }
// bool getSquelchEnabled() const { return m_squelchEnabled; }
// bool getForce() const { return m_force; }
// bool getAutoRWBalance() const { return m_autoRWBalance; }
// bool getStereoInput() const { return m_stereoInput; }
//
// static MsgUDPSinkConfigure* create(
// UDPSinkSettings::SampleFormat sampleFormat,
// Real inputSampleRate,
// Real rfBandwidth,
// int fmDeviation,
// Real amModFactor,
// const QString& udpAddress,
// int udpPort,
// bool channelMute,
// Real gainIn,
// Real gainOut,
// Real squelchDB,
// Real squelchGate,
// bool squelchEnabled,
// bool autoRWBalance,
// bool stereoInput,
// bool force)
// {
// return new MsgUDPSinkConfigure(
// sampleFormat,
// inputSampleRate,
// rfBandwidth,
// fmDeviation,
// amModFactor,
// udpAddress,
// udpPort,
// channelMute,
// gainIn,
// gainOut,
// squelchDB,
// squelchGate,
// squelchEnabled,
// autoRWBalance,
// stereoInput,
// force);
// }
//
// private:
// UDPSinkSettings::SampleFormat m_sampleFormat;
// Real m_inputSampleRate;
// Real m_rfBandwidth;
// int m_fmDeviation;
// Real m_amModFactor;
// QString m_udpAddress;
// int m_udpPort;
// bool m_channelMute;
// Real m_gainIn;
// Real m_gainOut;
// Real m_squelchDB;
// Real m_squelchGate;
// bool m_squelchEnabled;
// bool m_autoRWBalance;
// bool m_stereoInput;
// bool m_force;
//
// MsgUDPSinkConfigure(
// UDPSinkSettings::SampleFormat sampleFormat,
// Real inputSampleRate,
// Real rfBandwidth,
// int fmDeviation,
// Real amModFactor,
// const QString& udpAddress,
// int udpPort,
// bool channelMute,
// Real gainIn,
// Real gainOut,
// Real squelchDB,
// Real squelchGate,
// bool squelchEnabled,
// bool autoRWBalance,
// bool stereoInput,
// bool force) :
// Message(),
// m_sampleFormat(sampleFormat),
// m_inputSampleRate(inputSampleRate),
// m_rfBandwidth(rfBandwidth),
// m_fmDeviation(fmDeviation),
// m_amModFactor(amModFactor),
// m_udpAddress(udpAddress),
// m_udpPort(udpPort),
// m_channelMute(channelMute),
// m_gainIn(gainIn),
// m_gainOut(gainOut),
// m_squelchDB(squelchDB),
// m_squelchGate(squelchGate),
// m_squelchEnabled(squelchEnabled),
// m_autoRWBalance(autoRWBalance),
// m_stereoInput(stereoInput),
// m_force(force)
// { }
// };
class MsgUDPSinkSpectrum : public Message {
MESSAGE_CLASS_DECLARATION
@ -276,53 +146,6 @@ private:
{ }
};
// struct Config {
// int m_basebandSampleRate;
// Real m_outputSampleRate;
// int m_sampleFormat;
// Real m_inputSampleRate;
// qint64 m_inputFrequencyOffset;
// Real m_rfBandwidth;
// Real m_lowCutoff;
// int m_fmDeviation;
// Real m_amModFactor;
// bool m_channelMute;
// Real m_gainIn;
// Real m_gainOut;
// Real m_squelch; //!< squared magnitude
// Real m_squelchGate; //!< seconds
// bool m_squelchEnabled;
// bool m_autoRWBalance;
// bool m_stereoInput;
//
// QString m_udpAddressStr;
// quint16 m_udpPort;
//
// Config() :
// m_basebandSampleRate(48000),
// m_outputSampleRate(48000),
// m_sampleFormat(0),
// m_inputSampleRate(48000),
// m_inputFrequencyOffset(0),
// m_rfBandwidth(12500),
// m_lowCutoff(300),
// m_fmDeviation(1.0),
// m_amModFactor(0.95),
// m_channelMute(false),
// m_gainIn(1.0),
// m_gainOut(1.0),
// m_squelch(-50.0),
// m_squelchGate(0.05),
// m_squelchEnabled(true),
// m_autoRWBalance(true),
// m_stereoInput(false),
// m_udpAddressStr("127.0.0.1"),
// m_udpPort(9999)
// {}
// };
//
// Config m_config;
// Config m_running;
UDPSinkSettings m_settings;
Real m_squelch;
@ -372,7 +195,6 @@ private:
static const int m_sampleRateAverageItems = 17;
static const int m_ssbFftLen = 1024;
//void apply(bool force);
void applySettings(const UDPSinkSettings& settings, bool force = false);
void modulateSample();
void calculateLevel(Real sample);

View File

@ -65,41 +65,11 @@ void UDPSinkGUI::resetToDefaults()
m_settings.resetToDefaults();
displaySettings();
applySettings(true);
// blockApplySettings(true);
//
// ui->sampleFormat->setCurrentIndex(0);
// ui->sampleRate->setText("48000");
// ui->rfBandwidth->setText("32000");
// ui->fmDeviation->setText("2500");
// ui->spectrumGUI->resetToDefaults();
// ui->gainIn->setValue(10);
// ui->gainOut->setValue(10);
//
// blockApplySettings(false);
// applySettings();
}
QByteArray UDPSinkGUI::serialize() const
{
return m_settings.serialize();
// SimpleSerializer s(1);
// s.writeS32(2, m_settings.m_inputFrequencyOffset);
// s.writeS32(3, (int) m_settings.m_sampleFormat);
// s.writeReal(4, m_settings.m_inputSampleRate);
// s.writeReal(5, m_settings.m_rfBandwidth);
//
// s.writeBlob(6, m_channelMarker.serialize());
// s.writeBlob(7, ui->spectrumGUI->serialize());
//
// s.writeS32(10, roundf(m_settings.m_gainOut * 10.0));
// s.writeS32(11, m_settings.m_fmDeviation);
// s.writeBool(13, m_settings.m_stereoInput);
// s.writeS32(14, roundf(m_settings.m_squelch));
// s.writeS32(15, roundf(m_settings.m_squelchGate * 100.0));
// s.writeBool(16, m_settings.m_autoRWBalance);
// s.writeS32(17, roundf(m_settings.m_gainIn * 10.0));
// return s.final();
}
bool UDPSinkGUI::deserialize(const QByteArray& data)
@ -113,69 +83,6 @@ bool UDPSinkGUI::deserialize(const QByteArray& data)
resetToDefaults();
return false;
}
// SimpleDeserializer d(data);
//
// if (!d.isValid())
// {
// resetToDefaults();
// return false;
// }
//
// if (d.getVersion() == 1)
// {
// QByteArray bytetmp;
// QString strtmp;
// qint32 s32tmp;
// Real realtmp;
// bool booltmp;
//
// blockApplySettings(true);
// m_channelMarker.blockSignals(true);
//
// d.readBlob(6, &bytetmp);
// m_channelMarker.deserialize(bytetmp);
//
// d.readS32(2, &s32tmp, 0);
// m_settings.m_inputFrequencyOffset = s32tmp;
// d.readS32(3, &s32tmp, UDPSinkSettings::FormatS16LE);
// m_settings.m_sampleFormat = (UDPSinkSettings::SampleFormat) s32tmp;
// d.readReal(4, &realtmp, 48000);
// m_settings.m_inputSampleRate = realtmp;
// d.readReal(5, &realtmp, 32000);
// m_settings.m_rfBandwidth = realtmp;
//
// d.readBlob(7, &bytetmp);
// ui->spectrumGUI->deserialize(bytetmp);
//
// d.readS32(10, &s32tmp, 10);
// m_settings.m_gainOut = s32tmp / 10.0;
// d.readS32(11, &s32tmp, 2500);
// m_settings.m_fmDeviation = s32tmp * 1.0;
// d.readBool(13, &booltmp, false);
// m_settings.m_stereoInput = booltmp;
// d.readS32(14, &s32tmp, -60);
// m_settings.m_squelch = s32tmp * 1.0;
// m_settings.m_squelchEnabled = (s32tmp != -100);
// d.readS32(15, &s32tmp, 5);
// m_settings.m_squelchGate = s32tmp / 100.0;
// d.readBool(16, &booltmp, true);
// m_settings.m_autoRWBalance = booltmp;
// d.readS32(17, &s32tmp, 10);
// m_settings.m_gainIn = s32tmp / 10.0;
//
// blockApplySettings(false);
// m_channelMarker.blockSignals(false);
//
// displaySettings();
// applySettings(true);
// return true;
// }
// else
// {
// resetToDefaults();
// return false;
// }
}
bool UDPSinkGUI::handleMessage(const Message& message __attribute__((unused)))
@ -284,24 +191,6 @@ void UDPSinkGUI::applySettings(bool force)
UDPSink::MsgConfigureUDPSink* message = UDPSink::MsgConfigureUDPSink::create( m_settings, force);
m_udpSink->getInputMessageQueue()->push(message);
// m_udpSink->configure(m_udpSink->getInputMessageQueue(),
// m_settings.m_sampleFormat,
// m_settings.m_inputSampleRate,
// m_settings.m_rfBandwidth,
// m_settings.m_fmDeviation,
// m_settings.m_amModFactor,
// m_settings.m_udpAddress,
// m_settings.m_udpPort,
// m_settings.m_channelMute,
// m_settings.m_gainIn,
// m_settings.m_gainOut,
// m_settings.m_squelch,
// m_settings.m_squelchGate,
// m_settings.m_squelchEnabled,
// m_settings.m_autoRWBalance,
// m_settings.m_stereoInput,
// force);
ui->applyBtn->setEnabled(false);
ui->applyBtn->setStyleSheet("QPushButton { background:rgb(79,79,79); }");
}
@ -663,4 +552,3 @@ void UDPSinkGUI::setSampleFormat(int index)
}
}