From 8ec923c74636a9afdde8add2477ba6c08297d7f7 Mon Sep 17 00:00:00 2001 From: f4exb Date: Fri, 22 Feb 2019 15:30:51 +0100 Subject: [PATCH] FreeDV modulator: implemented set FreeDV mode setting --- plugins/channeltx/modfreedv/freedvmod.cpp | 99 ++-- plugins/channeltx/modfreedv/freedvmod.h | 5 + plugins/channeltx/modfreedv/freedvmodgui.cpp | 99 +--- plugins/channeltx/modfreedv/freedvmodgui.h | 6 +- plugins/channeltx/modfreedv/freedvmodgui.ui | 485 ++++-------------- .../channeltx/modfreedv/freedvmodsettings.cpp | 55 +- .../channeltx/modfreedv/freedvmodsettings.h | 14 +- sdrbase/resources/webapi/doc/html2/index.html | 5 +- .../webapi/doc/swagger/include/FreeDVMod.yaml | 2 + .../api/swagger/include/FreeDVMod.yaml | 2 + swagger/sdrangel/code/html2/index.html | 5 +- .../code/qt5/client/SWGFreeDVModSettings.cpp | 21 + .../code/qt5/client/SWGFreeDVModSettings.h | 6 + 13 files changed, 251 insertions(+), 553 deletions(-) diff --git a/plugins/channeltx/modfreedv/freedvmod.cpp b/plugins/channeltx/modfreedv/freedvmod.cpp index c9275a578..d62bbca69 100644 --- a/plugins/channeltx/modfreedv/freedvmod.cpp +++ b/plugins/channeltx/modfreedv/freedvmod.cpp @@ -57,6 +57,8 @@ FreeDVMod::FreeDVMod(DeviceSinkAPI *deviceAPI) : m_basebandSampleRate(48000), m_outputSampleRate(48000), m_inputFrequencyOffset(0), + m_lowCutoff(0.0), + m_hiCutoff(6000.0), m_SSBFilter(0), m_SSBFilterBuffer(0), m_SSBFilterBufferIndex(0), @@ -75,7 +77,7 @@ FreeDVMod::FreeDVMod(DeviceSinkAPI *deviceAPI) : DSPEngine::instance()->getAudioDeviceManager()->addAudioSource(&m_audioFifo, getInputMessageQueue()); m_audioSampleRate = DSPEngine::instance()->getAudioDeviceManager()->getInputSampleRate(); - m_SSBFilter = new fftfilt(m_settings.m_lowCutoff / m_audioSampleRate, m_settings.m_bandwidth / m_audioSampleRate, m_ssbFftLen); + m_SSBFilter = new fftfilt(m_lowCutoff / m_audioSampleRate, m_hiCutoff / m_audioSampleRate, m_ssbFftLen); m_SSBFilterBuffer = new Complex[m_ssbFftLen>>1]; // filter returns data exactly half of its size std::fill(m_SSBFilterBuffer, m_SSBFilterBuffer+(m_ssbFftLen>>1), Complex{0,0}); @@ -526,25 +528,9 @@ void FreeDVMod::applyAudioSampleRate(int sampleRate) m_interpolatorDistanceRemain = 0; m_interpolatorConsumed = false; m_interpolatorDistance = (Real) sampleRate / (Real) m_outputSampleRate; - m_interpolator.create(48, sampleRate, m_settings.m_bandwidth, 3.0); + m_interpolator.create(48, sampleRate, m_hiCutoff, 3.0); - float band = m_settings.m_bandwidth; - float lowCutoff = m_settings.m_lowCutoff; - - if (band < 100.0f) // at least 100 Hz - { - band = 100.0f; - lowCutoff = 0; - } - - if (band - lowCutoff < 100.0f) { - lowCutoff = band - 100.0f; - } - - m_SSBFilter->create_filter(lowCutoff / sampleRate, band / sampleRate); - - m_settings.m_bandwidth = band; - m_settings.m_lowCutoff = lowCutoff; + m_SSBFilter->create_filter(m_lowCutoff / sampleRate, m_hiCutoff / sampleRate); m_toneNco.setFreq(m_settings.m_toneFrequency, sampleRate); m_cwKeyer.setSampleRate(sampleRate); @@ -581,7 +567,7 @@ void FreeDVMod::applyChannelSettings(int basebandSampleRate, int outputSampleRat m_interpolatorDistanceRemain = 0; m_interpolatorConsumed = false; m_interpolatorDistance = (Real) m_audioSampleRate / (Real) outputSampleRate; - m_interpolator.create(48, m_audioSampleRate, m_settings.m_bandwidth, 3.0); + m_interpolator.create(48, m_audioSampleRate, m_hiCutoff, 3.0); m_settingsMutex.unlock(); } @@ -590,21 +576,27 @@ void FreeDVMod::applyChannelSettings(int basebandSampleRate, int outputSampleRat m_inputFrequencyOffset = inputFrequencyOffset; } +void FreeDVMod::applyFreeDVMode(FreeDVModSettings::FreeDVMode mode) +{ + m_hiCutoff = FreeDVModSettings::getHiCutoff(mode); + m_lowCutoff = FreeDVModSettings::getLowCutoff(mode); + + m_settingsMutex.lock(); + m_interpolatorDistanceRemain = 0; + m_interpolatorConsumed = false; + m_interpolatorDistance = (Real) m_audioSampleRate / (Real) m_outputSampleRate; + m_interpolator.create(48, m_audioSampleRate, m_hiCutoff, 3.0); + m_SSBFilter->create_filter(m_lowCutoff / m_audioSampleRate, m_hiCutoff / m_audioSampleRate); + m_settingsMutex.unlock(); +} + void FreeDVMod::applySettings(const FreeDVModSettings& settings, bool force) { - float band = settings.m_bandwidth; - float lowCutoff = settings.m_lowCutoff; QList reverseAPIKeys; if ((settings.m_inputFrequencyOffset != m_settings.m_inputFrequencyOffset) || force) { reverseAPIKeys.append("inputFrequencyOffset"); } - if ((settings.m_bandwidth != m_settings.m_bandwidth) || force) { - reverseAPIKeys.append("bandwidth"); - } - if ((settings.m_lowCutoff != m_settings.m_lowCutoff) || force) { - reverseAPIKeys.append("lowCutoff"); - } if ((settings.m_toneFrequency != m_settings.m_toneFrequency) || force) { reverseAPIKeys.append("toneFrequency"); } @@ -626,6 +618,9 @@ void FreeDVMod::applySettings(const FreeDVModSettings& settings, bool force) if ((settings.m_title != m_settings.m_title) || force) { reverseAPIKeys.append("title"); } + if ((settings.m_freeDVMode != m_settings.m_freeDVMode) || force) { + reverseAPIKeys.append("freeDVMode"); + } if ((settings.m_modAFInput != m_settings.m_modAFInput) || force) { reverseAPIKeys.append("modAFInput"); } @@ -633,28 +628,6 @@ void FreeDVMod::applySettings(const FreeDVModSettings& settings, bool force) reverseAPIKeys.append("audioDeviceName"); } - if ((settings.m_bandwidth != m_settings.m_bandwidth) || - (settings.m_lowCutoff != m_settings.m_lowCutoff) || force) - { - if (band < 100.0f) // at least 100 Hz - { - band = 100.0f; - lowCutoff = 0; - } - - if (band - lowCutoff < 100.0f) { - lowCutoff = band - 100.0f; - } - - m_settingsMutex.lock(); - m_interpolatorDistanceRemain = 0; - m_interpolatorConsumed = false; - m_interpolatorDistance = (Real) m_audioSampleRate / (Real) m_outputSampleRate; - m_interpolator.create(48, m_audioSampleRate, band, 3.0); - m_SSBFilter->create_filter(lowCutoff / m_audioSampleRate, band / m_audioSampleRate); - m_settingsMutex.unlock(); - } - if ((settings.m_toneFrequency != m_settings.m_toneFrequency) || force) { m_settingsMutex.lock(); @@ -674,6 +647,10 @@ void FreeDVMod::applySettings(const FreeDVModSettings& settings, bool force) } } + if ((m_settings.m_freeDVMode != settings.m_freeDVMode) || force) { + applyFreeDVMode(settings.m_freeDVMode); + } + if (settings.m_useReverseAPI) { bool fullUpdate = ((m_settings.m_useReverseAPI != settings.m_useReverseAPI) && settings.m_useReverseAPI) || @@ -685,8 +662,6 @@ void FreeDVMod::applySettings(const FreeDVModSettings& settings, bool force) } m_settings = settings; - m_settings.m_bandwidth = band; - m_settings.m_lowCutoff = lowCutoff; } QByteArray FreeDVMod::serialize() const @@ -737,12 +712,6 @@ int FreeDVMod::webapiSettingsPutPatch( settings.m_inputFrequencyOffset = response.getFreeDvModSettings()->getInputFrequencyOffset(); frequencyOffsetChanged = true; } - if (channelSettingsKeys.contains("bandwidth")) { - settings.m_bandwidth = response.getFreeDvModSettings()->getBandwidth(); - } - if (channelSettingsKeys.contains("lowCutoff")) { - settings.m_lowCutoff = response.getFreeDvModSettings()->getLowCutoff(); - } if (channelSettingsKeys.contains("toneFrequency")) { settings.m_toneFrequency = response.getFreeDvModSettings()->getToneFrequency(); } @@ -764,6 +733,9 @@ int FreeDVMod::webapiSettingsPutPatch( if (channelSettingsKeys.contains("title")) { settings.m_title = *response.getFreeDvModSettings()->getTitle(); } + if (channelSettingsKeys.contains("freeDVMode")) { + settings.m_freeDVMode = (FreeDVModSettings::FreeDVMode) response.getFreeDvModSettings()->getFreeDvMode(); + } if (channelSettingsKeys.contains("modAFInput")) { settings.m_modAFInput = (FreeDVModSettings::FreeDVModInputAF) response.getFreeDvModSettings()->getModAfInput(); } @@ -855,8 +827,6 @@ int FreeDVMod::webapiReportGet( void FreeDVMod::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const FreeDVModSettings& settings) { response.getFreeDvModSettings()->setInputFrequencyOffset(settings.m_inputFrequencyOffset); - response.getFreeDvModSettings()->setBandwidth(settings.m_bandwidth); - response.getFreeDvModSettings()->setLowCutoff(settings.m_lowCutoff); response.getFreeDvModSettings()->setToneFrequency(settings.m_toneFrequency); response.getFreeDvModSettings()->setVolumeFactor(settings.m_volumeFactor); response.getFreeDvModSettings()->setSpanLog2(settings.m_spanLog2); @@ -929,12 +899,6 @@ void FreeDVMod::webapiReverseSendSettings(QList& channelSettingsKeys, c if (channelSettingsKeys.contains("inputFrequencyOffset") || force) { swgFreeDVModSettings->setInputFrequencyOffset(settings.m_inputFrequencyOffset); } - if (channelSettingsKeys.contains("bandwidth") || force) { - swgFreeDVModSettings->setBandwidth(settings.m_bandwidth); - } - if (channelSettingsKeys.contains("lowCutoff") || force) { - swgFreeDVModSettings->setLowCutoff(settings.m_lowCutoff); - } if (channelSettingsKeys.contains("toneFrequency") || force) { swgFreeDVModSettings->setToneFrequency(settings.m_toneFrequency); } @@ -956,6 +920,9 @@ void FreeDVMod::webapiReverseSendSettings(QList& channelSettingsKeys, c if (channelSettingsKeys.contains("title") || force) { swgFreeDVModSettings->setTitle(new QString(settings.m_title)); } + if (channelSettingsKeys.contains("freeDVMode") || force) { + swgFreeDVModSettings->setFreeDvMode((int) settings.m_freeDVMode); + } if (channelSettingsKeys.contains("modAFInput") || force) { swgFreeDVModSettings->setModAfInput((int) settings.m_modAFInput); } diff --git a/plugins/channeltx/modfreedv/freedvmod.h b/plugins/channeltx/modfreedv/freedvmod.h index 3880a44c4..6b267fd6b 100644 --- a/plugins/channeltx/modfreedv/freedvmod.h +++ b/plugins/channeltx/modfreedv/freedvmod.h @@ -236,6 +236,8 @@ public: uint32_t getAudioSampleRate() const { return m_audioSampleRate; } double getMagSq() const { return m_magsq; } + Real getLowCutoff() const { return m_lowCutoff; } + Real getHiCutoff() const { return m_hiCutoff; } CWKeyer *getCWKeyer() { return &m_cwKeyer; } @@ -265,6 +267,8 @@ private: int m_basebandSampleRate; int m_outputSampleRate; int m_inputFrequencyOffset; + Real m_lowCutoff; + Real m_hiCutoff; FreeDVModSettings m_settings; quint32 m_audioSampleRate; @@ -315,6 +319,7 @@ private: void applyAudioSampleRate(int sampleRate); void applyChannelSettings(int basebandSampleRate, int outputSampleRate, int inputFrequencyOffset, bool force = false); void applySettings(const FreeDVModSettings& settings, bool force = false); + void applyFreeDVMode(FreeDVModSettings::FreeDVMode mode); void pullAF(Complex& sample); void calculateLevel(Complex& sample); void modulateSample(); diff --git a/plugins/channeltx/modfreedv/freedvmodgui.cpp b/plugins/channeltx/modfreedv/freedvmodgui.cpp index 78678e9b4..4e3b7ab54 100644 --- a/plugins/channeltx/modfreedv/freedvmodgui.cpp +++ b/plugins/channeltx/modfreedv/freedvmodgui.cpp @@ -182,18 +182,6 @@ void FreeDVModGUI::on_spanLog2_valueChanged(int value) applyBandwidths(5 - value); } -void FreeDVModGUI::on_BW_valueChanged(int value) -{ - (void) value; - applyBandwidths(5 - ui->spanLog2->value()); -} - -void FreeDVModGUI::on_lowCut_valueChanged(int value) -{ - (void) value; - applyBandwidths(5 - ui->spanLog2->value()); -} - void FreeDVModGUI::on_toneFrequency_valueChanged(int value) { ui->toneFrequencyText->setText(QString("%1k").arg(value / 100.0, 0, 'f', 2)); @@ -214,6 +202,14 @@ void FreeDVModGUI::on_audioMute_toggled(bool checked) applySettings(); } +void FreeDVModGUI::on_freeDVMode_currentIndexChanged(int index) +{ + m_settings.m_freeDVMode = (FreeDVModSettings::FreeDVMode) index; + m_channelMarker.setBandwidth(FreeDVModSettings::getHiCutoff(m_settings.m_freeDVMode) * 2); + m_channelMarker.setLowCutoff(FreeDVModSettings::getLowCutoff(m_settings.m_freeDVMode)); + applySettings(); +} + void FreeDVModGUI::on_playLoop_toggled(bool checked) { m_settings.m_playLoop = checked; @@ -368,17 +364,8 @@ FreeDVModGUI::FreeDVModGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseb ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold)); ui->deltaFrequency->setValueRange(false, 7, -9999999, 9999999); - m_channelMarker.blockSignals(true); - m_channelMarker.setColor(QColor(0, 255, 204)); - m_channelMarker.setBandwidth(m_spectrumRate); - m_channelMarker.setSidebands(ChannelMarker::usb); - m_channelMarker.setCenterFrequency(0); - m_channelMarker.setTitle("FreeDV Modulator"); - m_channelMarker.blockSignals(false); m_channelMarker.setVisible(true); - setTitleColor(m_channelMarker.getColor()); - m_deviceUISet->registerTxChannelInstance(FreeDVMod::m_channelIdURI, this); m_deviceUISet->addChannelMarker(&m_channelMarker); m_deviceUISet->addRollupWidget(this); @@ -395,11 +382,6 @@ FreeDVModGUI::FreeDVModGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseb connect(getInputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages())); connect(m_freeDVMod, SIGNAL(levelChanged(qreal, qreal, int)), ui->volumeMeter, SLOT(levelChanged(qreal, qreal, int))); - m_iconDSBUSB.addPixmap(QPixmap("://dsb.png"), QIcon::Normal, QIcon::On); - m_iconDSBUSB.addPixmap(QPixmap("://usb.png"), QIcon::Normal, QIcon::Off); - m_iconDSBLSB.addPixmap(QPixmap("://dsb.png"), QIcon::Normal, QIcon::On); - m_iconDSBLSB.addPixmap(QPixmap("://lsb.png"), QIcon::Normal, QIcon::Off); - displaySettings(); applyBandwidths(5 - ui->spanLog2->value(), true); // does applySettings(true) } @@ -435,8 +417,6 @@ void FreeDVModGUI::applySettings(bool force) void FreeDVModGUI::applyBandwidths(int spanLog2, bool force) { m_spectrumRate = m_freeDVMod->getAudioSampleRate() / (1<BW->value(); - int lw = ui->lowCut->value(); int bwMax = m_freeDVMod->getAudioSampleRate() / (100*(1<BW->setTickInterval(tickInterval); - ui->lowCut->setTickInterval(tickInterval); - - bw = bw < -bwMax ? -bwMax : bw > bwMax ? bwMax : bw; - - if (bw < 0) { - lw = lw < bw+1 ? bw+1 : lw < 0 ? lw : 0; - } else if (bw > 0) { - lw = lw > bw-1 ? bw-1 : lw < 0 ? 0 : lw; - } else { - lw = 0; - } - QString spanStr = QString::number(bwMax/10.0, 'f', 1); - QString bwStr = QString::number(bw/10.0, 'f', 1); - QString lwStr = QString::number(lw/10.0, 'f', 1); - ui->BWText->setText(tr("%1k").arg(bwStr)); ui->spanText->setText(tr("%1k").arg(spanStr)); - ui->scaleMinus->setText("-"); - ui->scaleCenter->setText("0"); - ui->scalePlus->setText("+"); - ui->lsbLabel->setText("LSB"); - ui->usbLabel->setText("USB"); ui->glSpectrum->setCenterFrequency(m_spectrumRate/2); ui->glSpectrum->setSampleRate(m_spectrumRate); ui->glSpectrum->setSsbSpectrum(true); - ui->glSpectrum->setLsbDisplay(bw < 0); - ui->lowCutText->setText(tr("%1k").arg(lwStr)); - - ui->BW->blockSignals(true); - ui->lowCut->blockSignals(true); - - ui->BW->setMaximum(bwMax); - ui->BW->setValue(bw); - ui->lowCut->setValue(lw); - - ui->lowCut->blockSignals(false); - ui->BW->blockSignals(false); + ui->glSpectrum->setLsbDisplay(false); m_settings.m_spanLog2 = spanLog2; - m_settings.m_bandwidth = bw * 100; - m_settings.m_lowCutoff = lw * 100; applySettings(force); - - bool applySettingsWereBlocked = blockApplySettings(true); - m_channelMarker.setBandwidth(bw * 200); - blockApplySettings(applySettingsWereBlocked); } void FreeDVModGUI::displaySettings() @@ -505,15 +445,9 @@ void FreeDVModGUI::displaySettings() m_channelMarker.blockSignals(true); m_channelMarker.setCenterFrequency(m_settings.m_inputFrequencyOffset); m_channelMarker.setTitle(m_settings.m_title); - m_channelMarker.setBandwidth(m_settings.m_bandwidth * 2); - m_channelMarker.setLowCutoff(m_settings.m_lowCutoff); - - if (m_settings.m_bandwidth < 0) { - m_channelMarker.setSidebands(ChannelMarker::lsb); - } else { - m_channelMarker.setSidebands(ChannelMarker::usb); - } - + m_channelMarker.setBandwidth(FreeDVModSettings::getHiCutoff(m_settings.m_freeDVMode) * 2); + m_channelMarker.setLowCutoff(FreeDVModSettings::getLowCutoff(m_settings.m_freeDVMode)); + m_channelMarker.setSidebands(ChannelMarker::usb); m_channelMarker.blockSignals(false); m_channelMarker.setColor(m_settings.m_rgbColor); @@ -527,22 +461,15 @@ void FreeDVModGUI::displaySettings() // Prevent uncontrolled triggering of applyBandwidths ui->spanLog2->blockSignals(true); - ui->BW->blockSignals(true); ui->spanLog2->setValue(5 - m_settings.m_spanLog2); - ui->BW->setValue(roundf(m_settings.m_bandwidth/100.0)); - QString s = QString::number(m_settings.m_bandwidth/1000.0, 'f', 1); - - ui->BWText->setText(tr("%1k").arg(s)); + QString s = QString::number(m_freeDVMod->getHiCutoff()/1000.0, 'f', 1); ui->spanLog2->blockSignals(false); - ui->BW->blockSignals(false); // The only one of the four signals triggering applyBandwidths will trigger it once only with all other values // set correctly and therefore validate the settings and apply them to dependent widgets - ui->lowCut->setValue(m_settings.m_lowCutoff / 100.0); - ui->lowCutText->setText(tr("%1k").arg(m_settings.m_lowCutoff / 1000.0)); ui->deltaFrequency->setValue(m_settings.m_inputFrequencyOffset); diff --git a/plugins/channeltx/modfreedv/freedvmodgui.h b/plugins/channeltx/modfreedv/freedvmodgui.h index 53485ee8c..2cac1f6c5 100644 --- a/plugins/channeltx/modfreedv/freedvmodgui.h +++ b/plugins/channeltx/modfreedv/freedvmodgui.h @@ -79,9 +79,6 @@ private: bool m_enableNavTime; MessageQueue m_inputMessageQueue; - QIcon m_iconDSBUSB; - QIcon m_iconDSBLSB; - explicit FreeDVModGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSource *channelTx, QWidget* parent = 0); virtual ~FreeDVModGUI(); @@ -100,10 +97,9 @@ private slots: void handleSourceMessages(); void on_deltaFrequency_changed(qint64 value); void on_spanLog2_valueChanged(int value); - void on_BW_valueChanged(int value); - void on_lowCut_valueChanged(int value); void on_volume_valueChanged(int value); void on_audioMute_toggled(bool checked); + void on_freeDVMode_currentIndexChanged(int index); void on_tone_toggled(bool checked); void on_toneFrequency_valueChanged(int value); void on_mic_toggled(bool checked); diff --git a/plugins/channeltx/modfreedv/freedvmodgui.ui b/plugins/channeltx/modfreedv/freedvmodgui.ui index 31cbfbc75..d81098ac3 100644 --- a/plugins/channeltx/modfreedv/freedvmodgui.ui +++ b/plugins/channeltx/modfreedv/freedvmodgui.ui @@ -165,383 +165,6 @@ - - - - - - - 50 - 0 - - - - - 50 - 16777215 - - - - Span - - - - - - - Spectrum display frequency span - - - 0 - - - 4 - - - 1 - - - 2 - - - 2 - - - Qt::Horizontal - - - false - - - false - - - - - - - - 50 - 0 - - - - - 50 - 16777215 - - - - 6.0k - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - - 50 - 0 - - - - - 50 - 16777215 - - - - Low cut - - - - - - - - 16777215 - 16 - - - - Highpass filter cutoff frequency (SSB) - - - -60 - - - 60 - - - 1 - - - 3 - - - Qt::Horizontal - - - QSlider::NoTicks - - - 5 - - - - - - - - 50 - 0 - - - - - 50 - 16777215 - - - - 0.3k - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - - 50 - 0 - - - - - 50 - 16777215 - - - - Hi cut - - - - - - - - 16777215 - 16 - - - - Lowpass filter cutoff frequency - - - -60 - - - 60 - - - 1 - - - 30 - - - Qt::Horizontal - - - QSlider::TicksBelow - - - 5 - - - - - - - - 50 - 0 - - - - - 50 - 16777215 - - - - 3.0k - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - 0 - - - - - - 50 - 0 - - - - - 50 - 10 - - - - - 8 - - - - f - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 10 - 10 - - - - - 8 - - - - - - - - - - - - - 8 - - - - LSB - - - Qt::AlignCenter - - - - - - - - 12 - 10 - - - - - 8 - - - - 0 - - - Qt::AlignCenter - - - - - - - - 8 - - - - USB - - - Qt::AlignCenter - - - - - - - - 10 - 10 - - - - - 8 - - - - + - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 50 - 0 - - - - - 50 - 10 - - - - - - - - - @@ -752,6 +375,33 @@ + + + + FreeDV mode + + + + 2400A + + + + + 1600 + + + + + 800XA + + + + + 700D + + + + @@ -927,6 +577,82 @@ + + + + + + + 50 + 0 + + + + + 50 + 16777215 + + + + Span + + + + + + + Spectrum display frequency span + + + 0 + + + 4 + + + 1 + + + 2 + + + 2 + + + Qt::Horizontal + + + false + + + false + + + + + + + + 50 + 0 + + + + + 50 + 16777215 + + + + 6.0k + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + @@ -1021,11 +747,6 @@
gui/valuedialz.h
1 - - TickedSlider - QSlider -
gui/tickedslider.h
-
diff --git a/plugins/channeltx/modfreedv/freedvmodsettings.cpp b/plugins/channeltx/modfreedv/freedvmodsettings.cpp index b4f59c9e9..9048c2e86 100644 --- a/plugins/channeltx/modfreedv/freedvmodsettings.cpp +++ b/plugins/channeltx/modfreedv/freedvmodsettings.cpp @@ -32,8 +32,6 @@ FreeDVModSettings::FreeDVModSettings() : void FreeDVModSettings::resetToDefaults() { m_inputFrequencyOffset = 0; - m_bandwidth = 3000.0; - m_lowCutoff = 300.0; m_toneFrequency = 1000.0; m_volumeFactor = 1.0; m_spanLog2 = 3; @@ -43,6 +41,7 @@ void FreeDVModSettings::resetToDefaults() m_title = "FreeDV Modulator"; m_modAFInput = FreeDVModInputAF::FreeDVModInputNone; m_audioDeviceName = AudioDeviceManager::m_defaultDeviceName; + m_freeDVMode = FreeDVMode::FreeDVMode2400A; m_useReverseAPI = false; m_reverseAPIAddress = "127.0.0.1"; m_reverseAPIPort = 8888; @@ -55,7 +54,6 @@ QByteArray FreeDVModSettings::serialize() const SimpleSerializer s(1); s.writeS32(1, m_inputFrequencyOffset); - s.writeS32(2, roundf(m_bandwidth / 100.0)); s.writeS32(3, roundf(m_toneFrequency / 10.0)); if (m_spectrumGUI) { @@ -68,8 +66,8 @@ QByteArray FreeDVModSettings::serialize() const s.writeBlob(6, m_cwKeyerGUI->serialize()); } - s.writeS32(7, roundf(m_lowCutoff / 100.0)); s.writeS32(8, m_spanLog2); + s.writeS32(10, (int) m_freeDVMode); if (m_channelMarker) { s.writeBlob(18, m_channelMarker->serialize()); @@ -106,9 +104,6 @@ bool FreeDVModSettings::deserialize(const QByteArray& data) d.readS32(1, &tmp, 0); m_inputFrequencyOffset = tmp; - d.readS32(2, &tmp, 30); - m_bandwidth = tmp * 100.0; - d.readS32(3, &tmp, 100); m_toneFrequency = tmp * 10.0; @@ -125,11 +120,15 @@ bool FreeDVModSettings::deserialize(const QByteArray& data) m_cwKeyerGUI->deserialize(bytetmp); } - d.readS32(7, &tmp, 3); - m_lowCutoff = tmp * 100.0; - d.readS32(8, &m_spanLog2, 3); + d.readS32(10, &tmp, 0); + if ((tmp < 0) || (tmp > (int) FreeDVMode::FreeDVMode700D)) { + m_freeDVMode = FreeDVMode::FreeDVMode2400A; + } else { + m_freeDVMode = (FreeDVMode) tmp; + } + if (m_channelMarker) { d.readBlob(18, &bytetmp); m_channelMarker->deserialize(bytetmp); @@ -168,3 +167,39 @@ bool FreeDVModSettings::deserialize(const QByteArray& data) return false; } } + +int FreeDVModSettings::getHiCutoff(FreeDVMode freeDVMode) +{ + switch(freeDVMode) + { + case FreeDVModSettings::FreeDVMode800XA: // C4FM NB + return 2400; + break; + case FreeDVModSettings::FreeDVMode700D: // OFDM + case FreeDVModSettings::FreeDVMode1600: // OFDM + return 2200.0; + break; + case FreeDVModSettings::FreeDVMode2400A: // C4FM WB + default: + return 6000.0; + break; + } +} + +int FreeDVModSettings::getLowCutoff(FreeDVMode freeDVMode) +{ + switch(freeDVMode) + { + case FreeDVModSettings::FreeDVMode800XA: // C4FM NB + return 400.0; + break; + case FreeDVModSettings::FreeDVMode700D: // OFDM + case FreeDVModSettings::FreeDVMode1600: // OFDM + return 800.0; + break; + case FreeDVModSettings::FreeDVMode2400A: // C4FM WB + default: + return 0.0; + break; + } +} diff --git a/plugins/channeltx/modfreedv/freedvmodsettings.h b/plugins/channeltx/modfreedv/freedvmodsettings.h index 38296297b..567d04421 100644 --- a/plugins/channeltx/modfreedv/freedvmodsettings.h +++ b/plugins/channeltx/modfreedv/freedvmodsettings.h @@ -34,9 +34,15 @@ struct FreeDVModSettings FreeDVModInputCWTone } FreeDVModInputAF; + typedef enum + { + FreeDVMode2400A, + FreeDVMode1600, + FreeDVMode800XA, + FreeDVMode700D + } FreeDVMode; + qint64 m_inputFrequencyOffset; - Real m_bandwidth; - Real m_lowCutoff; float m_toneFrequency; float m_volumeFactor; int m_spanLog2; @@ -47,6 +53,7 @@ struct FreeDVModSettings QString m_title; FreeDVModInputAF m_modAFInput; QString m_audioDeviceName; + FreeDVMode m_freeDVMode; bool m_useReverseAPI; QString m_reverseAPIAddress; @@ -65,6 +72,9 @@ struct FreeDVModSettings void setCWKeyerGUI(Serializable *cwKeyerGUI) { m_cwKeyerGUI = cwKeyerGUI; } QByteArray serialize() const; bool deserialize(const QByteArray& data); + + static int getHiCutoff(FreeDVMode freeDVMode); + static int getLowCutoff(FreeDVMode freeDVMode); }; diff --git a/sdrbase/resources/webapi/doc/html2/index.html b/sdrbase/resources/webapi/doc/html2/index.html index eff9d735b..a131c3c3a 100644 --- a/sdrbase/resources/webapi/doc/html2/index.html +++ b/sdrbase/resources/webapi/doc/html2/index.html @@ -2602,6 +2602,9 @@ margin-bottom: 20px; "audioDeviceName" : { "type" : "string" }, + "freeDVMode" : { + "type" : "integer" + }, "modAFInput" : { "type" : "integer" }, @@ -24468,7 +24471,7 @@ except ApiException as e:
- Generated 2019-02-22T10:50:46.075+01:00 + Generated 2019-02-22T15:22:55.188+01:00
diff --git a/sdrbase/resources/webapi/doc/swagger/include/FreeDVMod.yaml b/sdrbase/resources/webapi/doc/swagger/include/FreeDVMod.yaml index 426bc43a8..dfdadd622 100644 --- a/sdrbase/resources/webapi/doc/swagger/include/FreeDVMod.yaml +++ b/sdrbase/resources/webapi/doc/swagger/include/FreeDVMod.yaml @@ -28,6 +28,8 @@ FreeDVModSettings: type: string audioDeviceName: type: string + freeDVMode: + type: integer modAFInput: type: integer useReverseAPI: diff --git a/swagger/sdrangel/api/swagger/include/FreeDVMod.yaml b/swagger/sdrangel/api/swagger/include/FreeDVMod.yaml index 23b7cef9e..88d24a6db 100644 --- a/swagger/sdrangel/api/swagger/include/FreeDVMod.yaml +++ b/swagger/sdrangel/api/swagger/include/FreeDVMod.yaml @@ -28,6 +28,8 @@ FreeDVModSettings: type: string audioDeviceName: type: string + freeDVMode: + type: integer modAFInput: type: integer useReverseAPI: diff --git a/swagger/sdrangel/code/html2/index.html b/swagger/sdrangel/code/html2/index.html index eff9d735b..a131c3c3a 100644 --- a/swagger/sdrangel/code/html2/index.html +++ b/swagger/sdrangel/code/html2/index.html @@ -2602,6 +2602,9 @@ margin-bottom: 20px; "audioDeviceName" : { "type" : "string" }, + "freeDVMode" : { + "type" : "integer" + }, "modAFInput" : { "type" : "integer" }, @@ -24468,7 +24471,7 @@ except ApiException as e:
- Generated 2019-02-22T10:50:46.075+01:00 + Generated 2019-02-22T15:22:55.188+01:00
diff --git a/swagger/sdrangel/code/qt5/client/SWGFreeDVModSettings.cpp b/swagger/sdrangel/code/qt5/client/SWGFreeDVModSettings.cpp index 0c72998c4..729b02c6d 100644 --- a/swagger/sdrangel/code/qt5/client/SWGFreeDVModSettings.cpp +++ b/swagger/sdrangel/code/qt5/client/SWGFreeDVModSettings.cpp @@ -50,6 +50,8 @@ SWGFreeDVModSettings::SWGFreeDVModSettings() { m_title_isSet = false; audio_device_name = nullptr; m_audio_device_name_isSet = false; + free_dv_mode = 0; + m_free_dv_mode_isSet = false; mod_af_input = 0; m_mod_af_input_isSet = false; use_reverse_api = 0; @@ -94,6 +96,8 @@ SWGFreeDVModSettings::init() { m_title_isSet = false; audio_device_name = new QString(""); m_audio_device_name_isSet = false; + free_dv_mode = 0; + m_free_dv_mode_isSet = false; mod_af_input = 0; m_mod_af_input_isSet = false; use_reverse_api = 0; @@ -129,6 +133,7 @@ SWGFreeDVModSettings::cleanup() { } + if(reverse_api_address != nullptr) { delete reverse_api_address; } @@ -173,6 +178,8 @@ SWGFreeDVModSettings::fromJsonObject(QJsonObject &pJson) { ::SWGSDRangel::setValue(&audio_device_name, pJson["audioDeviceName"], "QString", "QString"); + ::SWGSDRangel::setValue(&free_dv_mode, pJson["freeDVMode"], "qint32", ""); + ::SWGSDRangel::setValue(&mod_af_input, pJson["modAFInput"], "qint32", ""); ::SWGSDRangel::setValue(&use_reverse_api, pJson["useReverseAPI"], "qint32", ""); @@ -236,6 +243,9 @@ SWGFreeDVModSettings::asJsonObject() { if(audio_device_name != nullptr && *audio_device_name != QString("")){ toJsonValue(QString("audioDeviceName"), audio_device_name, obj, QString("QString")); } + if(m_free_dv_mode_isSet){ + obj->insert("freeDVMode", QJsonValue(free_dv_mode)); + } if(m_mod_af_input_isSet){ obj->insert("modAFInput", QJsonValue(mod_af_input)); } @@ -371,6 +381,16 @@ SWGFreeDVModSettings::setAudioDeviceName(QString* audio_device_name) { this->m_audio_device_name_isSet = true; } +qint32 +SWGFreeDVModSettings::getFreeDvMode() { + return free_dv_mode; +} +void +SWGFreeDVModSettings::setFreeDvMode(qint32 free_dv_mode) { + this->free_dv_mode = free_dv_mode; + this->m_free_dv_mode_isSet = true; +} + qint32 SWGFreeDVModSettings::getModAfInput() { return mod_af_input; @@ -457,6 +477,7 @@ SWGFreeDVModSettings::isSet(){ if(m_rgb_color_isSet){ isObjectUpdated = true; break;} if(title != nullptr && *title != QString("")){ isObjectUpdated = true; break;} if(audio_device_name != nullptr && *audio_device_name != QString("")){ isObjectUpdated = true; break;} + if(m_free_dv_mode_isSet){ isObjectUpdated = true; break;} if(m_mod_af_input_isSet){ isObjectUpdated = true; break;} if(m_use_reverse_api_isSet){ isObjectUpdated = true; break;} if(reverse_api_address != nullptr && *reverse_api_address != QString("")){ isObjectUpdated = true; break;} diff --git a/swagger/sdrangel/code/qt5/client/SWGFreeDVModSettings.h b/swagger/sdrangel/code/qt5/client/SWGFreeDVModSettings.h index e8d2407fd..01f793d97 100644 --- a/swagger/sdrangel/code/qt5/client/SWGFreeDVModSettings.h +++ b/swagger/sdrangel/code/qt5/client/SWGFreeDVModSettings.h @@ -76,6 +76,9 @@ public: QString* getAudioDeviceName(); void setAudioDeviceName(QString* audio_device_name); + qint32 getFreeDvMode(); + void setFreeDvMode(qint32 free_dv_mode); + qint32 getModAfInput(); void setModAfInput(qint32 mod_af_input); @@ -134,6 +137,9 @@ private: QString* audio_device_name; bool m_audio_device_name_isSet; + qint32 free_dv_mode; + bool m_free_dv_mode_isSet; + qint32 mod_af_input; bool m_mod_af_input_isSet;