2015-12-06 13:47:55 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2015 F4EXB //
|
|
|
|
// written by Edouard Griffiths //
|
|
|
|
// //
|
|
|
|
// 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/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2017-08-13 19:39:26 -04:00
|
|
|
#include "udpsrcgui.h"
|
2015-11-18 21:27:37 -05:00
|
|
|
|
2017-08-13 19:39:26 -04:00
|
|
|
#include "device/devicesourceapi.h"
|
2015-11-18 21:27:37 -05:00
|
|
|
#include "plugin/pluginapi.h"
|
|
|
|
#include "dsp/spectrumvis.h"
|
|
|
|
#include "dsp/dspengine.h"
|
|
|
|
#include "util/simpleserializer.h"
|
|
|
|
#include "util/db.h"
|
2017-08-25 06:12:46 -04:00
|
|
|
#include "gui/basicchannelsettingsdialog.h"
|
2015-11-18 21:27:37 -05:00
|
|
|
#include "ui_udpsrcgui.h"
|
|
|
|
#include "mainwindow.h"
|
2016-10-02 07:18:07 -04:00
|
|
|
|
2017-08-14 18:20:04 -04:00
|
|
|
#include "udpsrc.h"
|
2015-11-18 21:27:37 -05:00
|
|
|
|
2016-05-16 13:37:53 -04:00
|
|
|
const QString UDPSrcGUI::m_channelID = "sdrangel.channel.udpsrc";
|
|
|
|
|
2016-10-10 19:17:55 -04:00
|
|
|
UDPSrcGUI* UDPSrcGUI::create(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI)
|
2015-11-18 21:27:37 -05:00
|
|
|
{
|
2016-05-16 04:05:09 -04:00
|
|
|
UDPSrcGUI* gui = new UDPSrcGUI(pluginAPI, deviceAPI);
|
2015-11-18 21:27:37 -05:00
|
|
|
return gui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void UDPSrcGUI::destroy()
|
|
|
|
{
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
|
|
|
|
void UDPSrcGUI::setName(const QString& name)
|
|
|
|
{
|
|
|
|
setObjectName(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
qint64 UDPSrcGUI::getCenterFrequency() const
|
|
|
|
{
|
|
|
|
return m_channelMarker.getCenterFrequency();
|
|
|
|
}
|
|
|
|
|
|
|
|
void UDPSrcGUI::setCenterFrequency(qint64 centerFrequency)
|
|
|
|
{
|
|
|
|
m_channelMarker.setCenterFrequency(centerFrequency);
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString UDPSrcGUI::getName() const
|
|
|
|
{
|
|
|
|
return objectName();
|
|
|
|
}
|
|
|
|
|
|
|
|
void UDPSrcGUI::resetToDefaults()
|
|
|
|
{
|
2017-10-05 02:38:06 -04:00
|
|
|
m_settings.resetToDefaults();
|
|
|
|
displaySettings();
|
|
|
|
applySettingsImmediate(true);
|
|
|
|
applySettings(true);
|
|
|
|
|
|
|
|
// blockApplySettings(true);
|
|
|
|
//
|
|
|
|
// ui->sampleFormat->setCurrentIndex(0);
|
|
|
|
// ui->sampleRate->setText("48000");
|
|
|
|
// ui->rfBandwidth->setText("32000");
|
|
|
|
// ui->fmDeviation->setText("2500");
|
|
|
|
// ui->spectrumGUI->resetToDefaults();
|
|
|
|
// ui->gain->setValue(10);
|
|
|
|
// ui->volume->setValue(20);
|
|
|
|
// ui->audioActive->setChecked(false);
|
|
|
|
// ui->audioStereo->setChecked(false);
|
|
|
|
// ui->agc->setChecked(false);
|
|
|
|
// m_channelMarker.setUDPAddress("127.0.0.1");
|
|
|
|
// m_channelMarker.setUDPSendPort(9999);
|
|
|
|
// m_channelMarker.setUDPReceivePort(9998);
|
|
|
|
//
|
|
|
|
// blockApplySettings(false);
|
|
|
|
// applySettingsImmediate();
|
|
|
|
// applySettings();
|
2015-11-18 21:27:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray UDPSrcGUI::serialize() const
|
|
|
|
{
|
2017-10-05 02:38:06 -04:00
|
|
|
return m_settings.serialize();
|
|
|
|
// SimpleSerializer s(1);
|
|
|
|
// s.writeS32(2, m_channelMarker.getCenterFrequency());
|
|
|
|
// s.writeS32(3, m_sampleFormat);
|
|
|
|
// s.writeReal(4, m_outputSampleRate);
|
|
|
|
// s.writeReal(5, m_rfBandwidth);
|
|
|
|
// s.writeBlob(6, m_channelMarker.serialize());
|
|
|
|
// s.writeBlob(7, ui->spectrumGUI->serialize());
|
|
|
|
// s.writeS32(8, ui->gain->value());
|
|
|
|
// s.writeBool(11, m_audioActive);
|
|
|
|
// s.writeS32(12, (qint32)m_volume);
|
|
|
|
// s.writeBool(14, m_audioStereo);
|
|
|
|
// s.writeS32(15, m_fmDeviation);
|
|
|
|
// s.writeS32(16, ui->squelch->value());
|
|
|
|
// s.writeS32(17, ui->squelchGate->value());
|
|
|
|
// s.writeBool(18, ui->agc->isChecked());
|
|
|
|
// return s.final();
|
2015-11-18 21:27:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool UDPSrcGUI::deserialize(const QByteArray& data)
|
|
|
|
{
|
2017-10-05 02:38:06 -04:00
|
|
|
if(m_settings.deserialize(data))
|
|
|
|
{
|
|
|
|
displaySettings();
|
|
|
|
applySettingsImmediate(true);
|
|
|
|
applySettings(true);
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
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_channelMarker.setCenterFrequency(s32tmp);
|
|
|
|
// d.readS32(3, &s32tmp, UDPSrcSettings::FormatS16LE);
|
|
|
|
// switch(s32tmp) {
|
|
|
|
// case UDPSrcSettings::FormatS16LE:
|
|
|
|
// ui->sampleFormat->setCurrentIndex(0);
|
|
|
|
// break;
|
|
|
|
// case UDPSrcSettings::FormatNFM:
|
|
|
|
// ui->sampleFormat->setCurrentIndex(1);
|
|
|
|
// break;
|
|
|
|
// case UDPSrcSettings::FormatNFMMono:
|
|
|
|
// ui->sampleFormat->setCurrentIndex(2);
|
|
|
|
// break;
|
|
|
|
// case UDPSrcSettings::FormatLSB:
|
|
|
|
// ui->sampleFormat->setCurrentIndex(3);
|
|
|
|
// break;
|
|
|
|
// case UDPSrcSettings::FormatUSB:
|
|
|
|
// ui->sampleFormat->setCurrentIndex(4);
|
|
|
|
// break;
|
|
|
|
// case UDPSrcSettings::FormatLSBMono:
|
|
|
|
// ui->sampleFormat->setCurrentIndex(5);
|
|
|
|
// break;
|
|
|
|
// case UDPSrcSettings::FormatUSBMono:
|
|
|
|
// ui->sampleFormat->setCurrentIndex(6);
|
|
|
|
// break;
|
|
|
|
// case UDPSrcSettings::FormatAMMono:
|
|
|
|
// ui->sampleFormat->setCurrentIndex(7);
|
|
|
|
// break;
|
|
|
|
// case UDPSrcSettings::FormatAMNoDCMono:
|
|
|
|
// ui->sampleFormat->setCurrentIndex(8);
|
|
|
|
// break;
|
|
|
|
// case UDPSrcSettings::FormatAMBPFMono:
|
|
|
|
// ui->sampleFormat->setCurrentIndex(9);
|
|
|
|
// break;
|
|
|
|
// default:
|
|
|
|
// ui->sampleFormat->setCurrentIndex(0);
|
|
|
|
// break;
|
|
|
|
// }
|
|
|
|
// d.readReal(4, &realtmp, 48000);
|
|
|
|
// ui->sampleRate->setText(QString("%1").arg(realtmp, 0));
|
|
|
|
// d.readReal(5, &realtmp, 32000);
|
|
|
|
// ui->rfBandwidth->setText(QString("%1").arg(realtmp, 0));
|
|
|
|
// d.readBlob(7, &bytetmp);
|
|
|
|
// ui->spectrumGUI->deserialize(bytetmp);
|
|
|
|
// d.readS32(8, &s32tmp, 10);
|
|
|
|
// ui->gain->setValue(s32tmp);
|
|
|
|
// ui->gainText->setText(tr("%1").arg(s32tmp/10.0, 0, 'f', 1));
|
|
|
|
// d.readBool(11, &booltmp, false);
|
|
|
|
// ui->audioActive->setChecked(booltmp);
|
|
|
|
// d.readS32(12, &s32tmp, 20);
|
|
|
|
// ui->volume->setValue(s32tmp);
|
|
|
|
// ui->volumeText->setText(QString("%1").arg(s32tmp));
|
|
|
|
// d.readBool(14, &booltmp, false);
|
|
|
|
// ui->audioStereo->setChecked(booltmp);
|
|
|
|
// d.readS32(15, &s32tmp, 2500);
|
|
|
|
// ui->fmDeviation->setText(QString("%1").arg(s32tmp));
|
|
|
|
// d.readS32(16, &s32tmp, -60);
|
|
|
|
// ui->squelch->setValue(s32tmp);
|
|
|
|
// ui->squelchText->setText(tr("%1").arg(s32tmp*1.0, 0, 'f', 0));
|
|
|
|
// d.readS32(17, &s32tmp, 5);
|
|
|
|
// ui->squelchGate->setValue(s32tmp);
|
|
|
|
// ui->squelchGateText->setText(tr("%1").arg(s32tmp*10.0, 0, 'f', 0));
|
|
|
|
// d.readBool(18, &booltmp, false);
|
|
|
|
// ui->agc->setChecked(booltmp);
|
|
|
|
//
|
|
|
|
// blockApplySettings(false);
|
|
|
|
// m_channelMarker.blockSignals(false);
|
|
|
|
//
|
|
|
|
// this->setWindowTitle(m_channelMarker.getTitle());
|
|
|
|
// displaySettings();
|
|
|
|
// applySettingsImmediate(true);
|
|
|
|
// applySettings(true);
|
|
|
|
// return true;
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// resetToDefaults();
|
|
|
|
// return false;
|
|
|
|
// }
|
2015-11-18 21:27:37 -05:00
|
|
|
}
|
|
|
|
|
2017-05-25 14:13:34 -04:00
|
|
|
bool UDPSrcGUI::handleMessage(const Message& message __attribute__((unused)))
|
2015-11-18 21:27:37 -05:00
|
|
|
{
|
2015-11-19 02:55:58 -05:00
|
|
|
qDebug() << "UDPSrcGUI::handleMessage";
|
2015-12-01 20:28:31 -05:00
|
|
|
return false;
|
2015-11-18 21:27:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void UDPSrcGUI::channelMarkerChanged()
|
|
|
|
{
|
2017-08-25 06:12:46 -04:00
|
|
|
this->setWindowTitle(m_channelMarker.getTitle());
|
2017-10-05 02:38:06 -04:00
|
|
|
m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency();
|
|
|
|
m_settings.m_udpAddress = m_channelMarker.getUDPAddress(),
|
|
|
|
m_settings.m_udpPort = m_channelMarker.getUDPSendPort(),
|
|
|
|
m_settings.m_rgbColor = m_channelMarker.getColor().rgb();
|
|
|
|
displayUDPAddress();
|
|
|
|
applySettings();
|
2015-11-18 21:27:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void UDPSrcGUI::tick()
|
|
|
|
{
|
2017-08-17 06:57:45 -04:00
|
|
|
if (m_tickCount % 4 == 0)
|
|
|
|
{
|
2017-08-19 21:47:21 -04:00
|
|
|
// m_channelPowerAvg.feed(m_udpSrc->getMagSq());
|
|
|
|
// double powDb = CalcDb::dbPower(m_channelPowerAvg.average());
|
|
|
|
double powDb = CalcDb::dbPower(m_udpSrc->getMagSq());
|
2017-08-17 06:57:45 -04:00
|
|
|
ui->channelPower->setText(QString::number(powDb, 'f', 1));
|
2017-08-17 14:23:17 -04:00
|
|
|
m_inPowerAvg.feed(m_udpSrc->getInMagSq());
|
|
|
|
double inPowDb = CalcDb::dbPower(m_inPowerAvg.average());
|
|
|
|
ui->inputPower->setText(QString::number(inPowDb, 'f', 1));
|
2017-08-17 06:57:45 -04:00
|
|
|
}
|
|
|
|
|
2017-08-17 18:10:15 -04:00
|
|
|
if (m_udpSrc->getSquelchOpen()) {
|
|
|
|
ui->squelchLabel->setStyleSheet("QLabel { background-color : green; }");
|
|
|
|
} else {
|
|
|
|
ui->squelchLabel->setStyleSheet("QLabel { background:rgb(79,79,79); }");
|
|
|
|
}
|
|
|
|
|
2017-08-17 06:57:45 -04:00
|
|
|
m_tickCount++;
|
2015-11-18 21:27:37 -05:00
|
|
|
}
|
|
|
|
|
2016-10-10 19:17:55 -04:00
|
|
|
UDPSrcGUI::UDPSrcGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidget* parent) :
|
2015-11-18 21:27:37 -05:00
|
|
|
RollupWidget(parent),
|
|
|
|
ui(new Ui::UDPSrcGUI),
|
|
|
|
m_pluginAPI(pluginAPI),
|
2016-05-16 04:05:09 -04:00
|
|
|
m_deviceAPI(deviceAPI),
|
2015-11-19 02:55:58 -05:00
|
|
|
m_udpSrc(0),
|
2015-11-18 21:27:37 -05:00
|
|
|
m_channelMarker(this),
|
2017-08-17 06:57:45 -04:00
|
|
|
m_channelPowerAvg(4, 1e-10),
|
2017-08-17 14:23:17 -04:00
|
|
|
m_inPowerAvg(4, 1e-10),
|
2017-08-17 06:57:45 -04:00
|
|
|
m_tickCount(0),
|
|
|
|
m_gain(1.0),
|
2017-05-25 14:13:34 -04:00
|
|
|
m_volume(20),
|
|
|
|
m_doApplySettings(true)
|
2015-11-18 21:27:37 -05:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
|
2017-08-25 06:12:46 -04:00
|
|
|
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &)));
|
2015-11-18 21:27:37 -05:00
|
|
|
setAttribute(Qt::WA_DeleteOnClose, true);
|
|
|
|
|
|
|
|
m_spectrumVis = new SpectrumVis(ui->glSpectrum);
|
2017-10-04 16:05:38 -04:00
|
|
|
m_udpSrc = new UDPSrc(m_deviceAPI);
|
|
|
|
m_udpSrc->setSpectrum(m_spectrumVis);
|
2015-11-18 21:27:37 -05:00
|
|
|
|
2016-04-04 10:44:50 -04:00
|
|
|
ui->fmDeviation->setEnabled(false);
|
|
|
|
|
2017-05-17 18:05:08 -04:00
|
|
|
ui->deltaFrequencyLabel->setText(QString("%1f").arg(QChar(0x94, 0x03)));
|
|
|
|
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
|
|
|
|
ui->deltaFrequency->setValueRange(false, 7, -9999999, 9999999);
|
2017-08-17 18:10:15 -04:00
|
|
|
ui->squelchLabel->setStyleSheet("QLabel { background:rgb(79,79,79); }");
|
2015-11-18 21:27:37 -05:00
|
|
|
|
|
|
|
ui->glSpectrum->setCenterFrequency(0);
|
|
|
|
ui->glSpectrum->setSampleRate(ui->sampleRate->text().toInt());
|
|
|
|
ui->glSpectrum->setDisplayWaterfall(true);
|
|
|
|
ui->glSpectrum->setDisplayMaxHold(true);
|
|
|
|
m_spectrumVis->configure(m_spectrumVis->getInputMessageQueue(), 64, 10, FFTWindow::BlackmanHarris);
|
|
|
|
|
|
|
|
ui->glSpectrum->connectTimer(m_pluginAPI->getMainWindow()->getMasterTimer());
|
|
|
|
connect(&m_pluginAPI->getMainWindow()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick()));
|
|
|
|
|
|
|
|
m_channelMarker.setBandwidth(16000);
|
|
|
|
m_channelMarker.setCenterFrequency(0);
|
2017-08-25 06:12:46 -04:00
|
|
|
m_channelMarker.setTitle("UDP Sample Source");
|
|
|
|
m_channelMarker.setUDPAddress("127.0.0.1");
|
|
|
|
m_channelMarker.setUDPSendPort(9999);
|
|
|
|
m_channelMarker.setUDPReceivePort(9998);
|
2015-11-18 21:27:37 -05:00
|
|
|
m_channelMarker.setVisible(true);
|
2017-10-05 16:11:57 -04:00
|
|
|
m_channelMarker.setColor(m_settings.m_rgbColor);
|
|
|
|
setTitleColor(m_channelMarker.getColor());
|
2016-05-16 13:37:53 -04:00
|
|
|
|
2017-10-05 02:17:49 -04:00
|
|
|
m_settings.setChannelMarker(&m_channelMarker);
|
|
|
|
m_settings.setSpectrumGUI(ui->spectrumGUI);
|
|
|
|
|
2015-11-18 21:27:37 -05:00
|
|
|
connect(&m_channelMarker, SIGNAL(changed()), this, SLOT(channelMarkerChanged()));
|
2016-05-16 13:37:53 -04:00
|
|
|
|
|
|
|
m_deviceAPI->registerChannelInstance(m_channelID, this);
|
2016-05-16 04:05:09 -04:00
|
|
|
m_deviceAPI->addChannelMarker(&m_channelMarker);
|
|
|
|
m_deviceAPI->addRollupWidget(this);
|
2015-11-18 21:27:37 -05:00
|
|
|
|
|
|
|
ui->spectrumGUI->setBuddies(m_spectrumVis->getInputMessageQueue(), m_spectrumVis, ui->glSpectrum);
|
|
|
|
|
2017-08-17 06:57:45 -04:00
|
|
|
displaySettings();
|
2017-08-18 18:12:56 -04:00
|
|
|
applySettingsImmediate(true);
|
|
|
|
applySettings(true);
|
2015-11-18 21:27:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
UDPSrcGUI::~UDPSrcGUI()
|
|
|
|
{
|
2016-05-16 13:37:53 -04:00
|
|
|
m_deviceAPI->removeChannelInstance(this);
|
2015-11-19 02:55:58 -05:00
|
|
|
delete m_udpSrc;
|
2015-11-18 21:27:37 -05:00
|
|
|
delete m_spectrumVis;
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void UDPSrcGUI::blockApplySettings(bool block)
|
|
|
|
{
|
|
|
|
m_doApplySettings = !block;
|
|
|
|
}
|
|
|
|
|
2017-08-17 06:57:45 -04:00
|
|
|
void UDPSrcGUI::displaySettings()
|
|
|
|
{
|
2017-10-05 02:38:06 -04:00
|
|
|
m_channelMarker.blockSignals(true);
|
|
|
|
m_channelMarker.setCenterFrequency(m_settings.m_inputFrequencyOffset);
|
|
|
|
m_channelMarker.setUDPAddress(m_settings.m_udpAddress);
|
|
|
|
m_channelMarker.setUDPSendPort(m_settings.m_udpPort);
|
|
|
|
m_channelMarker.setColor(m_settings.m_rgbColor);
|
|
|
|
setTitleColor(m_settings.m_rgbColor);
|
|
|
|
m_channelMarker.blockSignals(false);
|
|
|
|
|
|
|
|
ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency());
|
|
|
|
|
|
|
|
ui->sampleRate->setText(QString("%1").arg(m_settings.m_outputSampleRate, 0));
|
|
|
|
|
|
|
|
switch(m_settings.m_sampleFormat)
|
|
|
|
{
|
|
|
|
case UDPSrcSettings::FormatS16LE:
|
|
|
|
ui->sampleFormat->setCurrentIndex(0);
|
|
|
|
break;
|
|
|
|
case UDPSrcSettings::FormatNFM:
|
|
|
|
ui->sampleFormat->setCurrentIndex(1);
|
|
|
|
break;
|
|
|
|
case UDPSrcSettings::FormatNFMMono:
|
|
|
|
ui->sampleFormat->setCurrentIndex(2);
|
|
|
|
break;
|
|
|
|
case UDPSrcSettings::FormatLSB:
|
|
|
|
ui->sampleFormat->setCurrentIndex(3);
|
|
|
|
break;
|
|
|
|
case UDPSrcSettings::FormatUSB:
|
|
|
|
ui->sampleFormat->setCurrentIndex(4);
|
|
|
|
break;
|
|
|
|
case UDPSrcSettings::FormatLSBMono:
|
|
|
|
ui->sampleFormat->setCurrentIndex(5);
|
|
|
|
break;
|
|
|
|
case UDPSrcSettings::FormatUSBMono:
|
|
|
|
ui->sampleFormat->setCurrentIndex(6);
|
|
|
|
break;
|
|
|
|
case UDPSrcSettings::FormatAMMono:
|
|
|
|
ui->sampleFormat->setCurrentIndex(7);
|
|
|
|
break;
|
|
|
|
case UDPSrcSettings::FormatAMNoDCMono:
|
|
|
|
ui->sampleFormat->setCurrentIndex(8);
|
|
|
|
break;
|
|
|
|
case UDPSrcSettings::FormatAMBPFMono:
|
|
|
|
ui->sampleFormat->setCurrentIndex(9);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ui->sampleFormat->setCurrentIndex(0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-10-05 07:38:55 -04:00
|
|
|
ui->squelch->setValue(m_settings.m_squelch);
|
|
|
|
ui->squelchText->setText(tr("%1").arg(ui->squelch->value()*1.0, 0, 'f', 0));
|
|
|
|
|
|
|
|
ui->squelchGate->setValue(m_settings.m_squelchGate*100.0);
|
|
|
|
ui->squelchGateText->setText(tr("%1").arg(ui->squelchGate->value()*10.0, 0, 'f', 0));
|
|
|
|
|
|
|
|
ui->rfBandwidth->setText(QString("%1").arg(m_settings.m_rfBandwidth, 0));
|
|
|
|
ui->fmDeviation->setText(QString("%1").arg(m_settings.m_fmDeviation, 0));
|
|
|
|
|
|
|
|
ui->agc->setChecked(m_settings.m_agc);
|
|
|
|
ui->audioActive->setChecked(m_settings.m_audioActive);
|
|
|
|
ui->audioStereo->setChecked(m_settings.m_audioStereo);
|
2017-10-05 02:38:06 -04:00
|
|
|
|
|
|
|
ui->volume->setValue(m_settings.m_volume);
|
2017-08-17 06:57:45 -04:00
|
|
|
ui->volumeText->setText(QString("%1").arg(ui->volume->value()));
|
2017-10-05 02:38:06 -04:00
|
|
|
|
2017-10-05 07:38:55 -04:00
|
|
|
ui->gain->setValue(m_settings.m_gain*10.0);
|
|
|
|
ui->gainText->setText(tr("%1").arg(ui->gain->value()/10.0, 0, 'f', 1));
|
|
|
|
|
2017-10-05 02:38:06 -04:00
|
|
|
ui->squelch->setValue(m_settings.m_squelch);
|
2017-08-17 14:23:17 -04:00
|
|
|
ui->squelchText->setText(tr("%1").arg(ui->squelch->value()*1.0, 0, 'f', 0));
|
2017-10-05 02:38:06 -04:00
|
|
|
|
|
|
|
ui->squelchGate->setValue(m_settings.m_squelchGate*100.0);
|
2017-08-18 18:12:56 -04:00
|
|
|
ui->squelchGateText->setText(tr("%1").arg(ui->squelchGate->value()*10.0, 0, 'f', 0));
|
2017-10-05 02:38:06 -04:00
|
|
|
|
|
|
|
displayUDPAddress();
|
|
|
|
}
|
|
|
|
|
|
|
|
void UDPSrcGUI::displayUDPAddress()
|
|
|
|
{
|
2017-08-25 06:12:46 -04:00
|
|
|
ui->addressText->setText(tr("%1:%2/%3").arg(m_channelMarker.getUDPAddress()).arg(m_channelMarker.getUDPSendPort()).arg(m_channelMarker.getUDPReceivePort()));
|
2017-08-17 06:57:45 -04:00
|
|
|
}
|
|
|
|
|
2017-08-18 18:12:56 -04:00
|
|
|
void UDPSrcGUI::applySettingsImmediate(bool force)
|
2015-12-03 21:46:51 -05:00
|
|
|
{
|
|
|
|
if (m_doApplySettings)
|
|
|
|
{
|
2015-12-05 06:03:26 -05:00
|
|
|
m_audioActive = ui->audioActive->isChecked();
|
2015-12-05 06:23:55 -05:00
|
|
|
m_audioStereo = ui->audioStereo->isChecked();
|
2017-08-17 06:57:45 -04:00
|
|
|
m_gain = ui->gain->value() / 10.0;
|
2015-12-03 21:46:51 -05:00
|
|
|
m_volume = ui->volume->value();
|
|
|
|
|
|
|
|
m_udpSrc->configureImmediate(m_udpSrc->getInputMessageQueue(),
|
2015-12-05 06:03:26 -05:00
|
|
|
m_audioActive,
|
2015-12-05 06:23:55 -05:00
|
|
|
m_audioStereo,
|
2017-08-17 06:57:45 -04:00
|
|
|
m_gain,
|
2017-08-17 14:23:17 -04:00
|
|
|
m_volume,
|
|
|
|
ui->squelch->value() * 1.0f,
|
2017-08-18 18:12:56 -04:00
|
|
|
ui->squelchGate->value() * 0.01f,
|
|
|
|
ui->squelch->value() != -100,
|
2017-08-19 18:32:40 -04:00
|
|
|
ui->agc->isChecked(),
|
2017-08-18 18:12:56 -04:00
|
|
|
force);
|
2015-12-03 21:46:51 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-08-18 18:12:56 -04:00
|
|
|
void UDPSrcGUI::applySettings(bool force)
|
2015-11-18 21:27:37 -05:00
|
|
|
{
|
|
|
|
if (m_doApplySettings)
|
|
|
|
{
|
|
|
|
bool ok;
|
|
|
|
|
|
|
|
Real outputSampleRate = ui->sampleRate->text().toDouble(&ok);
|
|
|
|
|
|
|
|
if((!ok) || (outputSampleRate < 1000))
|
|
|
|
{
|
|
|
|
outputSampleRate = 48000;
|
|
|
|
}
|
|
|
|
|
|
|
|
Real rfBandwidth = ui->rfBandwidth->text().toDouble(&ok);
|
|
|
|
|
|
|
|
if((!ok) || (rfBandwidth > outputSampleRate))
|
|
|
|
{
|
|
|
|
rfBandwidth = outputSampleRate;
|
|
|
|
}
|
|
|
|
|
2016-04-03 21:44:06 -04:00
|
|
|
int fmDeviation = ui->fmDeviation->text().toInt(&ok);
|
|
|
|
|
|
|
|
if ((!ok) || (fmDeviation < 1))
|
|
|
|
{
|
|
|
|
fmDeviation = 2500;
|
|
|
|
}
|
|
|
|
|
2015-11-18 21:27:37 -05:00
|
|
|
setTitleColor(m_channelMarker.getColor());
|
2017-05-17 18:05:08 -04:00
|
|
|
ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency());
|
2015-11-18 21:27:37 -05:00
|
|
|
ui->sampleRate->setText(QString("%1").arg(outputSampleRate, 0));
|
|
|
|
ui->rfBandwidth->setText(QString("%1").arg(rfBandwidth, 0));
|
2016-04-03 21:44:06 -04:00
|
|
|
ui->fmDeviation->setText(QString("%1").arg(fmDeviation));
|
2015-11-18 21:27:37 -05:00
|
|
|
m_channelMarker.disconnect(this, SLOT(channelMarkerChanged()));
|
|
|
|
m_channelMarker.setBandwidth((int)rfBandwidth);
|
|
|
|
connect(&m_channelMarker, SIGNAL(changed()), this, SLOT(channelMarkerChanged()));
|
|
|
|
ui->glSpectrum->setSampleRate(outputSampleRate);
|
|
|
|
|
2017-10-04 16:41:58 -04:00
|
|
|
UDPSrc::MsgConfigureChannelizer* channelConfigMsg = UDPSrc::MsgConfigureChannelizer::create(
|
|
|
|
outputSampleRate, m_channelMarker.getCenterFrequency());
|
|
|
|
m_udpSrc->getInputMessageQueue()->push(channelConfigMsg);
|
2015-11-18 21:27:37 -05:00
|
|
|
|
2017-10-05 02:17:49 -04:00
|
|
|
UDPSrcSettings::SampleFormat sampleFormat;
|
2015-11-18 21:27:37 -05:00
|
|
|
|
|
|
|
switch(ui->sampleFormat->currentIndex())
|
|
|
|
{
|
|
|
|
case 0:
|
2017-10-05 02:17:49 -04:00
|
|
|
sampleFormat = UDPSrcSettings::FormatS16LE;
|
2016-04-04 10:44:50 -04:00
|
|
|
ui->fmDeviation->setEnabled(false);
|
2015-11-18 21:27:37 -05:00
|
|
|
break;
|
|
|
|
case 1:
|
2017-10-05 02:17:49 -04:00
|
|
|
sampleFormat = UDPSrcSettings::FormatNFM;
|
2016-04-04 10:44:50 -04:00
|
|
|
ui->fmDeviation->setEnabled(true);
|
2015-11-18 21:27:37 -05:00
|
|
|
break;
|
|
|
|
case 2:
|
2017-10-05 02:17:49 -04:00
|
|
|
sampleFormat = UDPSrcSettings::FormatNFMMono;
|
2016-04-05 11:02:24 -04:00
|
|
|
ui->fmDeviation->setEnabled(true);
|
|
|
|
break;
|
|
|
|
case 3:
|
2017-10-05 02:17:49 -04:00
|
|
|
sampleFormat = UDPSrcSettings::FormatLSB;
|
2016-04-05 11:02:24 -04:00
|
|
|
ui->fmDeviation->setEnabled(false);
|
|
|
|
break;
|
|
|
|
case 4:
|
2017-10-05 02:17:49 -04:00
|
|
|
sampleFormat = UDPSrcSettings::FormatUSB;
|
2016-04-05 11:02:24 -04:00
|
|
|
ui->fmDeviation->setEnabled(false);
|
|
|
|
break;
|
|
|
|
case 5:
|
2017-10-05 02:17:49 -04:00
|
|
|
sampleFormat = UDPSrcSettings::FormatLSBMono;
|
2016-04-05 11:02:24 -04:00
|
|
|
ui->fmDeviation->setEnabled(false);
|
|
|
|
break;
|
|
|
|
case 6:
|
2017-10-05 02:17:49 -04:00
|
|
|
sampleFormat = UDPSrcSettings::FormatUSBMono;
|
2016-04-05 11:02:24 -04:00
|
|
|
ui->fmDeviation->setEnabled(false);
|
|
|
|
break;
|
|
|
|
case 7:
|
2017-10-05 02:17:49 -04:00
|
|
|
sampleFormat = UDPSrcSettings::FormatAMMono;
|
2016-04-04 10:44:50 -04:00
|
|
|
ui->fmDeviation->setEnabled(false);
|
2015-11-18 21:27:37 -05:00
|
|
|
break;
|
2017-08-19 18:32:40 -04:00
|
|
|
case 8:
|
2017-10-05 02:17:49 -04:00
|
|
|
sampleFormat = UDPSrcSettings::FormatAMNoDCMono;
|
2017-08-19 18:32:40 -04:00
|
|
|
ui->fmDeviation->setEnabled(false);
|
2017-08-20 16:18:33 -04:00
|
|
|
break;
|
|
|
|
case 9:
|
2017-10-05 02:17:49 -04:00
|
|
|
sampleFormat = UDPSrcSettings::FormatAMBPFMono;
|
2017-08-20 16:18:33 -04:00
|
|
|
ui->fmDeviation->setEnabled(false);
|
2017-08-19 18:32:40 -04:00
|
|
|
break;
|
2015-11-18 21:27:37 -05:00
|
|
|
default:
|
2017-10-05 02:17:49 -04:00
|
|
|
sampleFormat = UDPSrcSettings::FormatS16LE;
|
2016-04-04 10:44:50 -04:00
|
|
|
ui->fmDeviation->setEnabled(false);
|
2015-11-18 21:27:37 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_sampleFormat = sampleFormat;
|
|
|
|
m_outputSampleRate = outputSampleRate;
|
|
|
|
m_rfBandwidth = rfBandwidth;
|
2016-04-03 21:44:06 -04:00
|
|
|
m_fmDeviation = fmDeviation;
|
2015-11-18 21:27:37 -05:00
|
|
|
|
2015-11-19 02:55:58 -05:00
|
|
|
m_udpSrc->configure(m_udpSrc->getInputMessageQueue(),
|
2015-11-18 21:27:37 -05:00
|
|
|
sampleFormat,
|
|
|
|
outputSampleRate,
|
|
|
|
rfBandwidth,
|
2016-04-03 21:44:06 -04:00
|
|
|
fmDeviation,
|
2017-08-25 06:12:46 -04:00
|
|
|
m_channelMarker.getUDPAddress(),
|
|
|
|
m_channelMarker.getUDPSendPort(),
|
|
|
|
m_channelMarker.getUDPReceivePort(),
|
2017-08-18 18:12:56 -04:00
|
|
|
force);
|
2015-11-18 21:27:37 -05:00
|
|
|
|
|
|
|
ui->applyBtn->setEnabled(false);
|
2017-08-18 21:45:17 -04:00
|
|
|
ui->applyBtn->setStyleSheet("QPushButton { background:rgb(79,79,79); }");
|
2015-11-18 21:27:37 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-17 18:05:08 -04:00
|
|
|
void UDPSrcGUI::on_deltaFrequency_changed(qint64 value)
|
2015-11-18 21:27:37 -05:00
|
|
|
{
|
2017-05-17 18:05:08 -04:00
|
|
|
m_channelMarker.setCenterFrequency(value);
|
2015-11-18 21:27:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void UDPSrcGUI::on_sampleFormat_currentIndexChanged(int index)
|
|
|
|
{
|
2016-04-05 11:02:24 -04:00
|
|
|
if ((index == 1) || (index == 2)) {
|
2016-04-04 10:44:50 -04:00
|
|
|
ui->fmDeviation->setEnabled(true);
|
|
|
|
} else {
|
|
|
|
ui->fmDeviation->setEnabled(false);
|
|
|
|
}
|
|
|
|
|
2015-11-18 21:27:37 -05:00
|
|
|
ui->applyBtn->setEnabled(true);
|
2017-08-18 21:45:17 -04:00
|
|
|
ui->applyBtn->setStyleSheet("QPushButton { background-color : green; }");
|
2015-11-18 21:27:37 -05:00
|
|
|
}
|
|
|
|
|
2017-05-25 14:13:34 -04:00
|
|
|
void UDPSrcGUI::on_sampleRate_textEdited(const QString& arg1 __attribute__((unused)))
|
2015-11-18 21:27:37 -05:00
|
|
|
{
|
|
|
|
ui->applyBtn->setEnabled(true);
|
2017-08-18 21:45:17 -04:00
|
|
|
ui->applyBtn->setStyleSheet("QPushButton { background-color : green; }");
|
2015-11-18 21:27:37 -05:00
|
|
|
}
|
|
|
|
|
2017-05-25 14:13:34 -04:00
|
|
|
void UDPSrcGUI::on_rfBandwidth_textEdited(const QString& arg1 __attribute__((unused)))
|
2015-11-18 21:27:37 -05:00
|
|
|
{
|
|
|
|
ui->applyBtn->setEnabled(true);
|
2017-08-18 21:45:17 -04:00
|
|
|
ui->applyBtn->setStyleSheet("QPushButton { background-color : green; }");
|
2015-11-18 21:27:37 -05:00
|
|
|
}
|
|
|
|
|
2017-05-25 14:13:34 -04:00
|
|
|
void UDPSrcGUI::on_fmDeviation_textEdited(const QString& arg1 __attribute__((unused)))
|
2016-04-03 21:44:06 -04:00
|
|
|
{
|
|
|
|
ui->applyBtn->setEnabled(true);
|
2017-08-18 21:45:17 -04:00
|
|
|
ui->applyBtn->setStyleSheet("QPushButton { background-color : green; }");
|
2016-04-03 21:44:06 -04:00
|
|
|
}
|
|
|
|
|
2017-05-25 14:13:34 -04:00
|
|
|
void UDPSrcGUI::on_udpAddress_textEdited(const QString& arg1 __attribute__((unused)))
|
2016-02-24 18:55:05 -05:00
|
|
|
{
|
|
|
|
ui->applyBtn->setEnabled(true);
|
2017-08-18 21:45:17 -04:00
|
|
|
ui->applyBtn->setStyleSheet("QPushButton { background-color : green; }");
|
2016-02-24 18:55:05 -05:00
|
|
|
}
|
|
|
|
|
2017-05-25 14:13:34 -04:00
|
|
|
void UDPSrcGUI::on_udpPort_textEdited(const QString& arg1 __attribute__((unused)))
|
2015-11-18 21:27:37 -05:00
|
|
|
{
|
|
|
|
ui->applyBtn->setEnabled(true);
|
2017-08-18 21:45:17 -04:00
|
|
|
ui->applyBtn->setStyleSheet("QPushButton { background-color : green; }");
|
2015-11-18 21:27:37 -05:00
|
|
|
}
|
|
|
|
|
2017-05-25 14:13:34 -04:00
|
|
|
void UDPSrcGUI::on_audioPort_textEdited(const QString& arg1 __attribute__((unused)))
|
2015-12-04 22:03:30 -05:00
|
|
|
{
|
|
|
|
ui->applyBtn->setEnabled(true);
|
2017-08-18 21:45:17 -04:00
|
|
|
ui->applyBtn->setStyleSheet("QPushButton { background-color : green; }");
|
2015-12-04 22:03:30 -05:00
|
|
|
}
|
|
|
|
|
2015-11-18 21:27:37 -05:00
|
|
|
void UDPSrcGUI::on_applyBtn_clicked()
|
|
|
|
{
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2017-05-25 14:13:34 -04:00
|
|
|
void UDPSrcGUI::on_audioActive_toggled(bool active __attribute__((unused)))
|
2015-12-03 21:46:51 -05:00
|
|
|
{
|
2015-12-05 06:03:26 -05:00
|
|
|
applySettingsImmediate();
|
2015-12-03 21:46:51 -05:00
|
|
|
}
|
|
|
|
|
2017-05-25 14:13:34 -04:00
|
|
|
void UDPSrcGUI::on_audioStereo_toggled(bool stereo __attribute__((unused)))
|
2015-12-05 06:23:55 -05:00
|
|
|
{
|
|
|
|
applySettingsImmediate();
|
|
|
|
}
|
|
|
|
|
2017-08-19 18:32:40 -04:00
|
|
|
void UDPSrcGUI::on_agc_toggled(bool agc __attribute__((unused)))
|
|
|
|
{
|
|
|
|
applySettingsImmediate();
|
|
|
|
}
|
|
|
|
|
2017-08-17 06:57:45 -04:00
|
|
|
void UDPSrcGUI::on_gain_valueChanged(int value)
|
2015-11-18 21:27:37 -05:00
|
|
|
{
|
2017-08-17 06:57:45 -04:00
|
|
|
ui->gainText->setText(tr("%1").arg(value/10.0, 0, 'f', 1));
|
2015-12-03 21:46:51 -05:00
|
|
|
applySettingsImmediate();
|
|
|
|
}
|
|
|
|
|
|
|
|
void UDPSrcGUI::on_volume_valueChanged(int value)
|
|
|
|
{
|
|
|
|
ui->volumeText->setText(QString("%1").arg(value));
|
|
|
|
applySettingsImmediate();
|
2015-11-18 21:27:37 -05:00
|
|
|
}
|
|
|
|
|
2017-08-17 14:23:17 -04:00
|
|
|
void UDPSrcGUI::on_squelch_valueChanged(int value)
|
|
|
|
{
|
|
|
|
if (value == -100) // means disabled
|
|
|
|
{
|
|
|
|
ui->squelchText->setText("---");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui->squelchText->setText(tr("%1").arg(value*1.0, 0, 'f', 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
applySettingsImmediate();
|
|
|
|
}
|
|
|
|
|
2017-08-18 18:12:56 -04:00
|
|
|
void UDPSrcGUI::on_squelchGate_valueChanged(int value)
|
|
|
|
{
|
|
|
|
ui->squelchGateText->setText(tr("%1").arg(value*10.0, 0, 'f', 0));
|
|
|
|
applySettingsImmediate();
|
|
|
|
}
|
|
|
|
|
2015-11-18 21:27:37 -05:00
|
|
|
void UDPSrcGUI::onWidgetRolled(QWidget* widget, bool rollDown)
|
|
|
|
{
|
2015-11-19 02:55:58 -05:00
|
|
|
if ((widget == ui->spectrumBox) && (m_udpSrc != 0))
|
2015-11-18 21:27:37 -05:00
|
|
|
{
|
2015-11-19 02:55:58 -05:00
|
|
|
m_udpSrc->setSpectrum(m_udpSrc->getInputMessageQueue(), rollDown);
|
2015-11-18 21:27:37 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-25 06:12:46 -04:00
|
|
|
void UDPSrcGUI::onMenuDialogCalled(const QPoint &p)
|
2015-11-18 21:27:37 -05:00
|
|
|
{
|
2017-08-25 06:12:46 -04:00
|
|
|
BasicChannelSettingsDialog dialog(&m_channelMarker, this);
|
|
|
|
dialog.move(p);
|
|
|
|
dialog.exec();
|
2015-11-18 21:27:37 -05:00
|
|
|
}
|
2016-04-03 12:14:04 -04:00
|
|
|
|
|
|
|
void UDPSrcGUI::leaveEvent(QEvent*)
|
|
|
|
{
|
|
|
|
blockApplySettings(true);
|
|
|
|
m_channelMarker.setHighlighted(false);
|
|
|
|
blockApplySettings(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void UDPSrcGUI::enterEvent(QEvent*)
|
|
|
|
{
|
|
|
|
blockApplySettings(true);
|
|
|
|
m_channelMarker.setHighlighted(true);
|
|
|
|
blockApplySettings(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|