From 7e70b7f6c663b0c59c82c3e68915a3ef1cc50a37 Mon Sep 17 00:00:00 2001 From: f4exb Date: Tue, 21 Mar 2017 21:59:44 +0100 Subject: [PATCH] ATV Modulator: added possibility to adjust baseband modulated signal amplitude to prevent filter saturation --- plugins/channeltx/modatv/atvmod.cpp | 21 ++++++----- plugins/channeltx/modatv/atvmod.h | 21 +++++++---- plugins/channeltx/modatv/atvmodgui.cpp | 12 ++++++- plugins/channeltx/modatv/atvmodgui.h | 1 + plugins/channeltx/modatv/atvmodgui.ui | 49 ++++++++++++++++++++++++++ 5 files changed, 89 insertions(+), 15 deletions(-) diff --git a/plugins/channeltx/modatv/atvmod.cpp b/plugins/channeltx/modatv/atvmod.cpp index 6aba0a00f..501c9d592 100644 --- a/plugins/channeltx/modatv/atvmod.cpp +++ b/plugins/channeltx/modatv/atvmod.cpp @@ -112,7 +112,8 @@ void ATVMod::configure(MessageQueue* messageQueue, bool videoPlay, bool cameraPlay, bool channelMute, - bool invertedVideo) + bool invertedVideo, + float rfScaling) { Message* cmd = MsgConfigureATVMod::create( rfBandwidth, @@ -127,7 +128,8 @@ void ATVMod::configure(MessageQueue* messageQueue, videoPlay, cameraPlay, channelMute, - invertedVideo); + invertedVideo, + rfScaling); messageQueue->push(cmd); } @@ -206,22 +208,22 @@ void ATVMod::modulateSample() m_modPhasor += (t - 0.5f) * M_PI; if (m_modPhasor > 2.0f * M_PI) m_modPhasor -= 2.0f * M_PI; // limit growth if (m_modPhasor < 2.0f * M_PI) m_modPhasor += 2.0f * M_PI; // limit growth - m_modSample.real(cos(m_modPhasor) * 29204.0f); // -1 dB - m_modSample.imag(sin(m_modPhasor) * 29204.0f); + m_modSample.real(cos(m_modPhasor) * m_running.m_rfScalingFactor); // -1 dB + m_modSample.imag(sin(m_modPhasor) * m_running.m_rfScalingFactor); break; case ATVModulationLSB: case ATVModulationUSB: m_modSample = modulateSSB(t); - m_modSample *= 29204.0f; + m_modSample *= m_running.m_rfScalingFactor; break; case ATVModulationVestigialLSB: case ATVModulationVestigialUSB: m_modSample = modulateVestigialSSB(t); - m_modSample *= 29204.0f; + m_modSample *= m_running.m_rfScalingFactor; break; case ATVModulationAM: // AM 90% default: - m_modSample.real((t*1.8f + 0.1f) * 16384.0f); // modulate and scale zero frequency carrier + m_modSample.real((t*1.8f + 0.1f) * (m_running.m_rfScalingFactor/2.0f)); // modulate and scale zero frequency carrier m_modSample.imag(0.0f); } } @@ -535,6 +537,7 @@ bool ATVMod::handleMessage(const Message& cmd) m_config.m_cameraPlay = cfg.getCameraPlay(); m_config.m_channelMute = cfg.getChannelMute(); m_config.m_invertedVideo = cfg.getInvertedVideo(); + m_config.m_rfScalingFactor = cfg.getRFScaling(); apply(); @@ -551,7 +554,8 @@ bool ATVMod::handleMessage(const Message& cmd) << " m_videoPlay: " << m_config.m_videoPlay << " m_cameraPlay: " << m_config.m_cameraPlay << " m_channelMute: " << m_config.m_channelMute - << " m_invertedVideo: " << m_config.m_invertedVideo; + << " m_invertedVideo: " << m_config.m_invertedVideo + << " m_rfScalingFactor: " << m_config.m_rfScalingFactor; return true; } @@ -725,6 +729,7 @@ void ATVMod::apply(bool force) m_running.m_cameraPlay = m_config.m_cameraPlay; m_running.m_channelMute = m_config.m_channelMute; m_running.m_invertedVideo = m_config.m_invertedVideo; + m_running.m_rfScalingFactor = m_config.m_rfScalingFactor; } void ATVMod::getBaseValues(int linesPerSecond, int& sampleRateUnits, int& nbPointsPerRateUnit) diff --git a/plugins/channeltx/modatv/atvmod.h b/plugins/channeltx/modatv/atvmod.h index f66d02c29..84d95192f 100644 --- a/plugins/channeltx/modatv/atvmod.h +++ b/plugins/channeltx/modatv/atvmod.h @@ -342,7 +342,8 @@ public: bool videoPlay, bool cameraPLay, bool channelMute, - bool invertedVideo); + bool invertedVideo, + float rfScaling); virtual void pull(Sample& sample); virtual void pullAudio(int nbSamples); // this is used for video signal actually @@ -385,6 +386,7 @@ private: bool getCameraPlay() const { return m_cameraPlay; } bool getChannelMute() const { return m_channelMute; } bool getInvertedVideo() const { return m_invertedVideo; } + float getRFScaling() const { return m_rfScaling; } static MsgConfigureATVMod* create( Real rfBandwidth, @@ -399,7 +401,8 @@ private: bool videoPlay, bool cameraPlay, bool channelMute, - bool invertedVideo) + bool invertedVideo, + float rfScaling) { return new MsgConfigureATVMod( rfBandwidth, @@ -414,7 +417,8 @@ private: videoPlay, cameraPlay, channelMute, - invertedVideo); + invertedVideo, + rfScaling); } private: @@ -431,6 +435,7 @@ private: bool m_cameraPlay; bool m_channelMute; bool m_invertedVideo; + float m_rfScaling; MsgConfigureATVMod( Real rfBandwidth, @@ -445,7 +450,8 @@ private: bool videoPlay, bool cameraPlay, bool channelMute, - bool invertedVideo) : + bool invertedVideo, + float rfScaling) : Message(), m_rfBandwidth(rfBandwidth), m_rfOppBandwidth(rfOppBandwidth), @@ -459,7 +465,8 @@ private: m_videoPlay(videoPlay), m_cameraPlay(cameraPlay), m_channelMute(channelMute), - m_invertedVideo(invertedVideo) + m_invertedVideo(invertedVideo), + m_rfScaling(rfScaling) { } }; @@ -508,6 +515,7 @@ private: bool m_cameraPlay; //!< True to play camera video and false to pause bool m_channelMute; //!< Mute channel baseband output bool m_invertedVideo; //!< True if video signal is inverted before modulation + float m_rfScalingFactor; //!< Scaling factor from +/-1 to +/-2^15 Config() : m_outputSampleRate(-1), @@ -524,7 +532,8 @@ private: m_videoPlay(false), m_cameraPlay(false), m_channelMute(false), - m_invertedVideo(false) + m_invertedVideo(false), + m_rfScalingFactor(29204.0f) // -1dB { } }; diff --git a/plugins/channeltx/modatv/atvmodgui.cpp b/plugins/channeltx/modatv/atvmodgui.cpp index 499025731..56064aa12 100644 --- a/plugins/channeltx/modatv/atvmodgui.cpp +++ b/plugins/channeltx/modatv/atvmodgui.cpp @@ -100,6 +100,7 @@ QByteArray ATVModGUI::serialize() const s.writeBool(9, ui->invertVideo->isChecked()); s.writeS32(10, ui->nbLines->currentIndex()); s.writeS32(11, ui->fps->currentIndex()); + s.writeS32(12, ui->rfScaling->value()); return s.final(); } @@ -150,6 +151,8 @@ bool ATVModGUI::deserialize(const QByteArray& data) ui->nbLines->setCurrentIndex(tmp); d.readS32(11, &tmp, 0); ui->fps->setCurrentIndex(tmp); + d.readS32(12, &tmp, 80); + ui->rfScaling->setValue(tmp); blockApplySettings(false); m_channelMarker.blockSignals(false); @@ -333,6 +336,12 @@ void ATVModGUI::on_modulation_currentIndexChanged(int index) applySettings(); } +void ATVModGUI::on_rfScaling_valueChanged(int value) +{ + ui->rfScalingText->setText(tr("%1").arg(value)); + applySettings(); +} + void ATVModGUI::on_rfBW_valueChanged(int value) { ui->rfBWText->setText(QString("%1k").arg((value*m_rfSliderDivisor) / 1000.0, 0, 'f', 0)); @@ -613,7 +622,8 @@ void ATVModGUI::applySettings() ui->playVideo->isChecked(), ui->playCamera->isChecked(), ui->channelMute->isChecked(), - ui->invertVideo->isChecked()); + ui->invertVideo->isChecked(), + ui->rfScaling->value() * 327.68f); } } diff --git a/plugins/channeltx/modatv/atvmodgui.h b/plugins/channeltx/modatv/atvmodgui.h index 0ef5b00f6..0ea1cece1 100644 --- a/plugins/channeltx/modatv/atvmodgui.h +++ b/plugins/channeltx/modatv/atvmodgui.h @@ -64,6 +64,7 @@ private slots: void on_deltaMinus_toggled(bool minus); void on_channelMute_toggled(bool checked); void on_modulation_currentIndexChanged(int index); + void on_rfScaling_valueChanged(int value); void on_rfBW_valueChanged(int value); void on_rfOppBW_valueChanged(int value); void on_nbLines_currentIndexChanged(int index); diff --git a/plugins/channeltx/modatv/atvmodgui.ui b/plugins/channeltx/modatv/atvmodgui.ui index cec91aa52..2afaff079 100644 --- a/plugins/channeltx/modatv/atvmodgui.ui +++ b/plugins/channeltx/modatv/atvmodgui.ui @@ -347,6 +347,55 @@ + + + + RF + + + + + + + + 24 + 24 + + + + 100 + + + 1 + + + 80 + + + + + + + + 20 + 0 + + + + 80 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::Vertical + + +