ATV modulator: use settings (1)

pull/85/head
f4exb 2017-10-22 00:33:18 +02:00
rodzic dcb43d554c
commit 04c8729e44
6 zmienionych plików z 254 dodań i 229 usunięć

Wyświetl plik

@ -72,8 +72,8 @@ ATVMod::ATVMod() :
m_config.m_outputSampleRate = 1000000;
m_config.m_inputFrequencyOffset = 0;
m_config.m_rfBandwidth = 1000000;
m_config.m_atvModInput = ATVModInputHBars;
m_config.m_atvStd = ATVStdPAL625;
m_config.m_atvModInput = ATVModSettings::ATVModInputHBars;
m_config.m_atvStd = ATVModSettings::ATVStdPAL625;
m_config.m_nbLines = 625;
m_config.m_fps = 25;
@ -102,12 +102,12 @@ ATVMod::~ATVMod()
void ATVMod::configure(MessageQueue* messageQueue,
Real rfBandwidth,
Real rfOppBandwidth,
ATVStd atvStd,
ATVModSettings::ATVStd atvStd,
int nbLines,
int fps,
ATVModInput atvModInput,
ATVModSettings::ATVModInput atvModInput,
Real uniformLevel,
ATVModulation atvModulation,
ATVModSettings::ATVModulation atvModulation,
bool videoPlayLoop,
bool videoPlay,
bool cameraPlay,
@ -208,24 +208,24 @@ void ATVMod::modulateSample()
switch (m_running.m_atvModulation)
{
case ATVModulationFM: // FM half bandwidth deviation
case ATVModSettings::ATVModulationFM: // FM half bandwidth deviation
m_modPhasor += (t - 0.5f) * m_running.m_fmExcursion * 2.0f * 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) * m_running.m_rfScalingFactor); // -1 dB
m_modSample.imag(sin(m_modPhasor) * m_running.m_rfScalingFactor);
break;
case ATVModulationLSB:
case ATVModulationUSB:
case ATVModSettings::ATVModulationLSB:
case ATVModSettings::ATVModulationUSB:
m_modSample = modulateSSB(t);
m_modSample *= m_running.m_rfScalingFactor;
break;
case ATVModulationVestigialLSB:
case ATVModulationVestigialUSB:
case ATVModSettings::ATVModulationVestigialLSB:
case ATVModSettings::ATVModulationVestigialUSB:
m_modSample = modulateVestigialSSB(t);
m_modSample *= m_running.m_rfScalingFactor;
break;
case ATVModulationAM: // AM 90%
case ATVModSettings::ATVModulationAM: // AM 90%
default:
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);
@ -238,7 +238,7 @@ Complex& ATVMod::modulateSSB(Real& sample)
Complex ci(sample, 0.0f);
fftfilt::cmplx *filtered;
n_out = m_SSBFilter->runSSB(ci, &filtered, m_running.m_atvModulation == ATVModulationUSB);
n_out = m_SSBFilter->runSSB(ci, &filtered, m_running.m_atvModulation == ATVModSettings::ATVModulationUSB);
if (n_out > 0)
{
@ -257,7 +257,7 @@ Complex& ATVMod::modulateVestigialSSB(Real& sample)
Complex ci(sample, 0.0f);
fftfilt::cmplx *filtered;
n_out = m_DSBFilter->runAsym(ci, &filtered, m_running.m_atvModulation == ATVModulationVestigialUSB);
n_out = m_DSBFilter->runAsym(ci, &filtered, m_running.m_atvModulation == ATVModSettings::ATVModulationVestigialUSB);
if (n_out > 0)
{
@ -272,7 +272,7 @@ Complex& ATVMod::modulateVestigialSSB(Real& sample)
void ATVMod::pullVideo(Real& sample)
{
if ((m_running.m_atvStd == ATVStdHSkip) && (m_lineCount == m_nbLines2)) // last line in skip mode
if ((m_running.m_atvStd == ATVModSettings::ATVStdHSkip) && (m_lineCount == m_nbLines2)) // last line in skip mode
{
pullImageLine(sample, true); // pull image line without sync
}
@ -327,7 +327,7 @@ void ATVMod::pullVideo(Real& sample)
m_lineCount = 0;
m_evenImage = !m_evenImage;
if ((m_running.m_atvModInput == ATVModInputVideo) && m_videoOK && (m_running.m_videoPlay) && !m_videoEOF)
if ((m_running.m_atvModInput == ATVModSettings::ATVModInputVideo) && m_videoOK && (m_running.m_videoPlay) && !m_videoEOF)
{
int grabOK = 0;
int fpsIncrement = (int) m_videoFPSCount - m_videoPrevFPSCount;
@ -376,7 +376,7 @@ void ATVMod::pullVideo(Real& sample)
m_videoFPSCount = m_videoFPSq;
}
}
else if ((m_running.m_atvModInput == ATVModInputCamera) && (m_running.m_cameraPlay))
else if ((m_running.m_atvModInput == ATVModSettings::ATVModInputCamera) && (m_running.m_cameraPlay))
{
ATVCamera& camera = m_cameras[m_cameraIndex]; // currently selected canera
@ -806,18 +806,18 @@ void ATVMod::getBaseValues(int outputSampleRate, int linesPerSecond, int& sample
sampleRateUnits = nbPointsPerRateUnit * linesPerSecond;
}
float ATVMod::getRFBandwidthDivisor(ATVModulation modulation)
float ATVMod::getRFBandwidthDivisor(ATVModSettings::ATVModulation modulation)
{
switch(modulation)
{
case ATVModulationLSB:
case ATVModulationUSB:
case ATVModulationVestigialLSB:
case ATVModulationVestigialUSB:
case ATVModSettings::ATVModulationLSB:
case ATVModSettings::ATVModulationUSB:
case ATVModSettings::ATVModulationVestigialLSB:
case ATVModSettings::ATVModulationVestigialUSB:
return 1.05f;
break;
case ATVModulationAM:
case ATVModulationFM:
case ATVModSettings::ATVModulationAM:
case ATVModSettings::ATVModulationFM:
default:
return 2.2f;
}
@ -851,7 +851,7 @@ void ATVMod::applyStandard()
switch(m_config.m_atvStd)
{
case ATVStdHSkip:
case ATVModSettings::ATVStdHSkip:
m_nbImageLines = m_nbLines; // lines less the total number of sync lines
m_nbImageLines2 = m_nbImageLines; // force non interleaved for vbars
m_interleaved = false;
@ -866,7 +866,7 @@ void ATVMod::applyStandard()
m_blankLineLvel = 0.7f;
m_nbLines2 = m_nbLines - 1;
break;
case ATVStdShort:
case ATVModSettings::ATVStdShort:
m_nbImageLines = m_nbLines - 2; // lines less the total number of sync lines
m_nbImageLines2 = m_nbImageLines; // force non interleaved for vbars
m_interleaved = false;
@ -881,7 +881,7 @@ void ATVMod::applyStandard()
m_blankLineLvel = 0.7f;
m_nbLines2 = m_nbLines; // force non interleaved => treated as even for all lines
break;
case ATVStdShortInterleaved:
case ATVModSettings::ATVStdShortInterleaved:
m_nbImageLines = m_nbLines - 2; // lines less the total number of sync lines
m_nbImageLines2 = m_nbImageLines / 2;
m_interleaved = true;
@ -895,7 +895,7 @@ void ATVMod::applyStandard()
m_nbBlankLines = 1;
m_blankLineLvel = 0.7f;
break;
case ATVStd405: // Follows loosely the 405 lines standard
case ATVModSettings::ATVStd405: // Follows loosely the 405 lines standard
m_nbImageLines = m_nbLines - 15; // lines less the total number of sync lines
m_nbImageLines2 = m_nbImageLines / 2;
m_interleaved = true;
@ -909,7 +909,7 @@ void ATVMod::applyStandard()
m_nbBlankLines = 7; // yields 376 lines (195 - 7) * 2
m_blankLineLvel = m_blackLevel;
break;
case ATVStdPAL525: // Follows PAL-M standard
case ATVModSettings::ATVStdPAL525: // Follows PAL-M standard
m_nbImageLines = m_nbLines - 15;
m_nbImageLines2 = m_nbImageLines / 2;
m_interleaved = true;
@ -923,7 +923,7 @@ void ATVMod::applyStandard()
m_nbBlankLines = 15; // yields 480 lines (255 - 15) * 2
m_blankLineLvel = m_blackLevel;
break;
case ATVStdPAL625: // Follows PAL-B/G/H standard
case ATVModSettings::ATVStdPAL625: // Follows PAL-B/G/H standard
default:
m_nbImageLines = m_nbLines - 15;
m_nbImageLines2 = m_nbImageLines / 2;

Wyświetl plik

@ -34,43 +34,12 @@
#include "dsp/fftfilt.h"
#include "util/message.h"
#include "atvmodsettings.h"
class ATVMod : public BasebandSampleSource {
Q_OBJECT
public:
typedef enum
{
ATVStdPAL625,
ATVStdPAL525,
ATVStd405,
ATVStdShortInterleaved,
ATVStdShort,
ATVStdHSkip,
} ATVStd;
typedef enum
{
ATVModInputUniform,
ATVModInputHBars,
ATVModInputVBars,
ATVModInputChessboard,
ATVModInputHGradient,
ATVModInputVGradient,
ATVModInputImage,
ATVModInputVideo,
ATVModInputCamera
} ATVModInput;
typedef enum
{
ATVModulationAM,
ATVModulationFM,
ATVModulationUSB,
ATVModulationLSB,
ATVModulationVestigialUSB,
ATVModulationVestigialLSB
} ATVModulation;
class MsgConfigureImageFileName : public Message
{
MESSAGE_CLASS_DECLARATION
@ -381,12 +350,12 @@ public:
void configure(MessageQueue* messageQueue,
Real rfBandwidth,
Real rfOppBandwidth,
ATVStd atvStd,
ATVModSettings::ATVStd atvStd,
int nbLines,
int fps,
ATVModInput atvModInput,
ATVModSettings::ATVModInput atvModInput,
Real uniformLevel,
ATVModulation atvModulation,
ATVModSettings::ATVModulation atvModulation,
bool videoPlayLoop,
bool videoPlay,
bool cameraPLay,
@ -407,7 +376,7 @@ public:
void getCameraNumbers(std::vector<int>& numbers);
static void getBaseValues(int outputSampleRate, int linesPerSecond, int& sampleRateUnits, uint32_t& nbPointsPerRateUnit);
static float getRFBandwidthDivisor(ATVModulation modulation);
static float getRFBandwidthDivisor(ATVModSettings::ATVModulation modulation);
signals:
/**
@ -426,12 +395,12 @@ private:
public:
Real getRFBandwidth() const { return m_rfBandwidth; }
Real getRFOppBandwidth() const { return m_rfOppBandwidth; }
ATVStd getATVStd() const { return m_atvStd; }
ATVModInput getATVModInput() const { return m_atvModInput; }
ATVModSettings::ATVStd getATVStd() const { return m_atvStd; }
ATVModSettings::ATVModInput getATVModInput() const { return m_atvModInput; }
int getNbLines() const { return m_nbLines; }
int getFPS() const { return m_fps; }
Real getUniformLevel() const { return m_uniformLevel; }
ATVModulation getModulation() const { return m_atvModulation; }
ATVModSettings::ATVModulation getModulation() const { return m_atvModulation; }
bool getVideoPlayLoop() const { return m_videoPlayLoop; }
bool getVideoPlay() const { return m_videoPlay; }
bool getCameraPlay() const { return m_cameraPlay; }
@ -444,12 +413,12 @@ private:
static MsgConfigureATVMod* create(
Real rfBandwidth,
Real rfOppBandwidth,
ATVStd atvStd,
ATVModSettings::ATVStd atvStd,
int nbLines,
int fps,
ATVModInput atvModInput,
ATVModSettings::ATVModInput atvModInput,
Real uniformLevel,
ATVModulation atvModulation,
ATVModSettings::ATVModulation atvModulation,
bool videoPlayLoop,
bool videoPlay,
bool cameraPlay,
@ -481,12 +450,12 @@ private:
private:
Real m_rfBandwidth;
Real m_rfOppBandwidth;
ATVStd m_atvStd;
ATVModSettings::ATVStd m_atvStd;
int m_nbLines;
int m_fps;
ATVModInput m_atvModInput;
ATVModSettings::ATVModInput m_atvModInput;
Real m_uniformLevel;
ATVModulation m_atvModulation;
ATVModSettings::ATVModulation m_atvModulation;
bool m_videoPlayLoop;
bool m_videoPlay;
bool m_cameraPlay;
@ -499,12 +468,12 @@ private:
MsgConfigureATVMod(
Real rfBandwidth,
Real rfOppBandwidth,
ATVStd atvStd,
ATVModSettings::ATVStd atvStd,
int nbLines,
int fps,
ATVModInput atvModInput,
ATVModSettings::ATVModInput atvModInput,
Real uniformLevel,
ATVModulation atvModulation,
ATVModSettings::ATVModulation atvModulation,
bool videoPlayLoop,
bool videoPlay,
bool cameraPlay,
@ -573,12 +542,12 @@ private:
qint64 m_inputFrequencyOffset; //!< offset from baseband center frequency
Real m_rfBandwidth; //!< Bandwidth of modulated signal or direct sideband for SSB / vestigial SSB
Real m_rfOppBandwidth; //!< Bandwidth of opposite sideband for vestigial SSB
ATVStd m_atvStd; //!< Standard
ATVModSettings::ATVStd m_atvStd; //!< Standard
int m_nbLines; //!< Number of lines per full frame
int m_fps; //!< Number of frames per second
ATVModInput m_atvModInput; //!< Input source type
ATVModSettings::ATVModInput m_atvModInput; //!< Input source type
Real m_uniformLevel; //!< Percentage between black and white for uniform screen display
ATVModulation m_atvModulation; //!< RF modulation type
ATVModSettings::ATVModulation m_atvModulation; //!< RF modulation type
bool m_videoPlayLoop; //!< Play video in a loop
bool m_videoPlay; //!< True to play video and false to pause
bool m_cameraPlay; //!< True to play camera video and false to pause
@ -593,12 +562,12 @@ private:
m_inputFrequencyOffset(0),
m_rfBandwidth(0),
m_rfOppBandwidth(0),
m_atvStd(ATVStdPAL625),
m_atvStd(ATVModSettings::ATVStdPAL625),
m_nbLines(625),
m_fps(25),
m_atvModInput(ATVModInputHBars),
m_atvModInput(ATVModSettings::ATVModInputHBars),
m_uniformLevel(0.5f),
m_atvModulation(ATVModulationAM),
m_atvModulation(ATVModSettings::ATVModulationAM),
m_videoPlayLoop(false),
m_videoPlay(false),
m_cameraPlay(false),
@ -741,22 +710,22 @@ private:
switch(m_running.m_atvModInput)
{
case ATVModInputHBars:
case ATVModSettings::ATVModInputHBars:
sample = (pointIndex / m_pointsPerHBar) * m_hBarIncrement + m_blackLevel;
break;
case ATVModInputVBars:
case ATVModSettings::ATVModInputVBars:
sample = (iLine / m_linesPerVBar) * m_vBarIncrement + m_blackLevel;
break;
case ATVModInputChessboard:
case ATVModSettings::ATVModInputChessboard:
sample = (((iLine / m_linesPerVBar)*5 + (pointIndex / m_pointsPerHBar)) % 2) * m_spanLevel * m_running.m_uniformLevel + m_blackLevel;
break;
case ATVModInputHGradient:
case ATVModSettings::ATVModInputHGradient:
sample = (pointIndex / (float) m_pointsPerImgLine) * m_spanLevel + m_blackLevel;
break;
case ATVModInputVGradient:
case ATVModSettings::ATVModInputVGradient:
sample = ((iLine -5) / (float) m_nbImageLines2) * m_spanLevel + m_blackLevel;
break;
case ATVModInputImage:
case ATVModSettings::ATVModInputImage:
if (!m_imageOK || (iLineImage < -oddity) || m_image.empty())
{
sample = m_spanLevel * m_running.m_uniformLevel + m_blackLevel;
@ -774,7 +743,7 @@ private:
sample = (pixv / 256.0f) * m_spanLevel + m_blackLevel;
}
break;
case ATVModInputVideo:
case ATVModSettings::ATVModInputVideo:
if (!m_videoOK || (iLineImage < -oddity) || m_videoFrame.empty())
{
sample = m_spanLevel * m_running.m_uniformLevel + m_blackLevel;
@ -792,7 +761,7 @@ private:
sample = (pixv / 256.0f) * m_spanLevel + m_blackLevel;
}
break;
case ATVModInputCamera:
case ATVModSettings::ATVModInputCamera:
if ((iLineImage < -oddity) || (m_cameraIndex < 0))
{
sample = m_spanLevel * m_running.m_uniformLevel + m_blackLevel;
@ -819,7 +788,7 @@ private:
}
}
break;
case ATVModInputUniform:
case ATVModSettings::ATVModInputUniform:
default:
sample = m_spanLevel * m_running.m_uniformLevel + m_blackLevel;
}

Wyświetl plik

@ -25,15 +25,15 @@
#include "device/devicesinkapi.h"
#include "dsp/upchannelizer.h"
#include "dsp/threadedbasebandsamplesource.h"
#include "ui_atvmodgui.h"
#include "plugin/pluginapi.h"
#include "util/simpleserializer.h"
#include "util/db.h"
#include "gui/basicchannelsettingswidget.h"
#include "dsp/dspengine.h"
#include "util/db.h"
#include "mainwindow.h"
#include "ui_atvmodgui.h"
#include "atvmodgui.h"
const QString ATVModGUI::m_channelID = "sdrangel.channeltx.modatv";
@ -70,111 +70,29 @@ void ATVModGUI::setCenterFrequency(qint64 centerFrequency)
void ATVModGUI::resetToDefaults()
{
blockApplySettings(true);
ui->rfBW->setValue(10);
ui->uniformLevel->setValue(35);
ui->standard->setCurrentIndex(0);
ui->nbLines->setCurrentIndex(0);
ui->fps->setCurrentIndex(1);
ui->inputSelect->setCurrentIndex(0);
ui->deltaFrequency->setValue(0);
ui->modulation->setCurrentIndex(0);
blockApplySettings(false);
applySettings();
m_settings.resetToDefaults();
}
QByteArray ATVModGUI::serialize() const
{
SimpleSerializer s(1);
s.writeS32(1, m_channelMarker.getCenterFrequency());
s.writeS32(2, ui->rfBW->value());
s.writeS32(3, ui->uniformLevel->value());
s.writeS32(4, ui->standard->currentIndex());
s.writeS32(5, ui->inputSelect->currentIndex());
s.writeU32(6, m_channelMarker.getColor().rgb());
s.writeS32(7, ui->rfOppBW->value());
s.writeS32(8, ui->modulation->currentIndex());
s.writeBool(9, ui->invertVideo->isChecked());
s.writeS32(10, ui->nbLines->currentIndex());
s.writeS32(11, ui->fps->currentIndex());
s.writeS32(12, ui->rfScaling->value());
s.writeS32(13, ui->fmExcursion->value());
s.writeString(14, ui->overlayText->text());
return s.final();
return m_settings.serialize();
}
bool ATVModGUI::deserialize(const QByteArray& data)
{
SimpleDeserializer d(data);
if(!d.isValid())
if(m_settings.deserialize(data))
{
resetToDefaults();
return false;
}
if(d.getVersion() == 1)
{
QByteArray bytetmp;
quint32 u32tmp;
qint32 tmp;
bool booltmp;
QString tmpString;
blockApplySettings(true);
m_channelMarker.blockSignals(true);
d.readS32(1, &tmp, 0);
m_channelMarker.setCenterFrequency(tmp);
d.readS32(2, &tmp, 4);
ui->rfBW->setValue(tmp);
d.readS32(3, &tmp, 100);
ui->uniformLevel->setValue(tmp);
d.readS32(4, &tmp, 0);
ui->standard->setCurrentIndex(tmp);
d.readS32(5, &tmp, 0);
ui->inputSelect->setCurrentIndex(tmp);
if(d.readU32(6, &u32tmp))
{
m_channelMarker.setColor(u32tmp);
}
d.readS32(7, &tmp, 10);
ui->rfOppBW->setValue(tmp);
d.readS32(8, &tmp, 0);
ui->modulation->setCurrentIndex(tmp);
d.readBool(9, &booltmp, false);
ui->invertVideo->setChecked(booltmp);
d.readS32(10, &tmp, 0);
ui->nbLines->setCurrentIndex(tmp);
d.readS32(11, &tmp, 0);
ui->fps->setCurrentIndex(tmp);
d.readS32(12, &tmp, 80);
ui->rfScaling->setValue(tmp);
d.readS32(13, &tmp, 250);
ui->fmExcursion->setValue(tmp);
d.readString(14, &tmpString, "");
ui->overlayText->setText(tmpString);
blockApplySettings(false);
m_channelMarker.blockSignals(false);
ATVMod::MsgConfigureOverlayText* message = ATVMod::MsgConfigureOverlayText::create(ui->overlayText->text());
m_atvMod->getInputMessageQueue()->push(message);
applySettings();
return true;
}
displaySettings();
applySettings(); // will have true
return true;
}
else
{
resetToDefaults();
return false;
}
m_settings.resetToDefaults();
displaySettings();
applySettings(); // will have true
return false;
}
}
bool ATVModGUI::handleMessage(const Message& message)
@ -255,10 +173,10 @@ void ATVModGUI::setRFFiltersSlidersRange(int sampleRate)
m_rfSliderDivisor /= 10;
}
if ((ui->modulation->currentIndex() == (int) ATVMod::ATVModulationLSB) ||
(ui->modulation->currentIndex() == (int) ATVMod::ATVModulationUSB) ||
(ui->modulation->currentIndex() == (int) ATVMod::ATVModulationVestigialLSB) ||
(ui->modulation->currentIndex() == (int) ATVMod::ATVModulationVestigialUSB))
if ((ui->modulation->currentIndex() == (int) ATVModSettings::ATVModulationLSB) ||
(ui->modulation->currentIndex() == (int) ATVModSettings::ATVModulationUSB) ||
(ui->modulation->currentIndex() == (int) ATVModSettings::ATVModulationVestigialLSB) ||
(ui->modulation->currentIndex() == (int) ATVModSettings::ATVModulationVestigialUSB))
{
ui->rfBW->setMaximum((sampleRate) / (2*m_rfSliderDivisor));
ui->rfOppBW->setMaximum((sampleRate) / (2*m_rfSliderDivisor));
@ -320,6 +238,39 @@ int ATVModGUI::getNbLines()
}
}
int ATVModGUI::getNbLinesIndex(int nbLines)
{
if (nbLines < 32) {
return 1;
} else if (nbLines < 60) {
return 12;
} else if (nbLines < 90) {
return 11;
} else if (nbLines < 120) {
return 10;
} else if (nbLines < 180) {
return 9;
} else if (nbLines < 240) {
return 8;
} else if (nbLines < 343) {
return 7;
} else if (nbLines < 360) {
return 6;
} else if (nbLines < 405) {
return 5;
} else if (nbLines < 480) {
return 4;
} else if (nbLines < 525) {
return 3;
} else if (nbLines < 625) {
return 2;
} else if (nbLines < 640) {
return 1;
} else {
return 0;
}
}
int ATVModGUI::getFPS()
{
switch(ui->fps->currentIndex())
@ -356,7 +307,33 @@ int ATVModGUI::getFPS()
return 25;
break;
}
}
int ATVModGUI::getFPSIndex(int fps)
{
if (fps < 1) {
return 1;
} else if (fps < 2) {
return 9;
} else if (fps < 5) {
return 8;
} else if (fps < 8) {
return 7;
} else if (fps < 10) {
return 6;
} else if (fps < 12) {
return 5;
} else if (fps < 16) {
return 4;
} else if (fps < 20) {
return 3;
} else if (fps < 25) {
return 2;
} else if (fps < 30) {
return 1;
} else {
return 0;
}
}
void ATVModGUI::handleSourceMessages()
@ -377,8 +354,9 @@ void ATVModGUI::on_deltaFrequency_changed(qint64 value)
m_channelMarker.setCenterFrequency(value);
}
void ATVModGUI::on_modulation_currentIndexChanged(int index __attribute__((unused)))
void ATVModGUI::on_modulation_currentIndexChanged(int index)
{
m_settings.m_atvModulation = (ATVModSettings::ATVModulation) index;
setRFFiltersSlidersRange(m_atvMod->getEffectiveSampleRate());
setChannelMarkerBandwidth();
applySettings();
@ -387,18 +365,21 @@ void ATVModGUI::on_modulation_currentIndexChanged(int index __attribute__((unuse
void ATVModGUI::on_rfScaling_valueChanged(int value)
{
ui->rfScalingText->setText(tr("%1").arg(value));
m_settings.m_rfScalingFactor = value * 327.68f;
applySettings();
}
void ATVModGUI::on_fmExcursion_valueChanged(int value)
{
ui->fmExcursionText->setText(tr("%1").arg(value / 10.0, 0, 'f', 1));
m_settings.m_fmExcursion = value / 1000.0; // pro mill
applySettings();
}
void ATVModGUI::on_rfBW_valueChanged(int value)
{
ui->rfBWText->setText(QString("%1k").arg((value*m_rfSliderDivisor) / 1000.0, 0, 'f', 0));
m_settings.m_rfBandwidth = value * m_rfSliderDivisor * 1.0f;
setChannelMarkerBandwidth();
applySettings();
}
@ -406,29 +387,30 @@ void ATVModGUI::on_rfBW_valueChanged(int value)
void ATVModGUI::on_rfOppBW_valueChanged(int value)
{
ui->rfOppBWText->setText(QString("%1k").arg((value*m_rfSliderDivisor) / 1000.0, 0, 'f', 0));
m_settings.m_rfOppBandwidth = value * m_rfSliderDivisor * 1.0f;
setChannelMarkerBandwidth();
applySettings();
}
void ATVModGUI::setChannelMarkerBandwidth()
{
if (ui->modulation->currentIndex() == (int) ATVMod::ATVModulationLSB)
if (ui->modulation->currentIndex() == (int) ATVModSettings::ATVModulationLSB)
{
m_channelMarker.setBandwidth(-ui->rfBW->value()*m_rfSliderDivisor*2);
m_channelMarker.setSidebands(ChannelMarker::lsb);
}
else if (ui->modulation->currentIndex() == (int) ATVMod::ATVModulationVestigialLSB)
else if (ui->modulation->currentIndex() == (int) ATVModSettings::ATVModulationVestigialLSB)
{
m_channelMarker.setBandwidth(ui->rfBW->value()*m_rfSliderDivisor);
m_channelMarker.setOppositeBandwidth(ui->rfOppBW->value()*m_rfSliderDivisor);
m_channelMarker.setSidebands(ChannelMarker::vlsb);
}
else if (ui->modulation->currentIndex() == (int) ATVMod::ATVModulationUSB)
else if (ui->modulation->currentIndex() == (int) ATVModSettings::ATVModulationUSB)
{
m_channelMarker.setBandwidth(ui->rfBW->value()*m_rfSliderDivisor*2);
m_channelMarker.setSidebands(ChannelMarker::usb);
}
else if (ui->modulation->currentIndex() == (int) ATVMod::ATVModulationVestigialUSB)
else if (ui->modulation->currentIndex() == (int) ATVModSettings::ATVModulationVestigialUSB)
{
m_channelMarker.setBandwidth(ui->rfBW->value()*m_rfSliderDivisor);
m_channelMarker.setOppositeBandwidth(ui->rfOppBW->value()*m_rfSliderDivisor);
@ -443,43 +425,51 @@ void ATVModGUI::setChannelMarkerBandwidth()
void ATVModGUI::on_nbLines_currentIndexChanged(int index __attribute__((unused)))
{
m_settings.m_nbLines = getNbLines();
applySettings();
}
void ATVModGUI::on_fps_currentIndexChanged(int index __attribute__((unused)))
{
m_settings.m_fps = getFPS();
applySettings();
}
void ATVModGUI::on_standard_currentIndexChanged(int index __attribute__((unused)))
void ATVModGUI::on_standard_currentIndexChanged(int index)
{
m_settings.m_atvStd = (ATVModSettings::ATVStd) index;
applySettings();
}
void ATVModGUI::on_uniformLevel_valueChanged(int value)
{
ui->uniformLevelText->setText(QString("%1").arg(value));
m_settings.m_uniformLevel = value / 100.0f;
applySettings();
}
void ATVModGUI::on_invertVideo_clicked()
void ATVModGUI::on_invertVideo_clicked(bool checked)
{
m_settings.m_invertedVideo = checked;
applySettings();
}
void ATVModGUI::on_inputSelect_currentIndexChanged(int index __attribute__((unused)))
void ATVModGUI::on_inputSelect_currentIndexChanged(int index)
{
m_settings.m_atvModInput = (ATVModSettings::ATVModInput) index;
applySettings();
}
void ATVModGUI::on_channelMute_toggled(bool checked __attribute__((unused)))
void ATVModGUI::on_channelMute_toggled(bool checked)
{
m_settings.m_channelMute = checked;
applySettings();
}
void ATVModGUI::on_forceDecimator_toggled(bool checked __attribute__((unused)))
void ATVModGUI::on_forceDecimator_toggled(bool checked)
{
m_settings.m_forceDecimator = checked;
applySettings();
}
@ -509,13 +499,15 @@ void ATVModGUI::on_videoFileDialog_clicked(bool checked __attribute__((unused)))
}
}
void ATVModGUI::on_playLoop_toggled(bool checked __attribute__((unused)))
void ATVModGUI::on_playLoop_toggled(bool checked)
{
m_settings.m_videoPlayLoop = checked;
applySettings();
}
void ATVModGUI::on_playVideo_toggled(bool checked)
{
m_settings.m_videoPlay = checked;
ui->navTimeSlider->setEnabled(!checked);
m_enableNavTime = !checked;
applySettings();
@ -530,8 +522,9 @@ void ATVModGUI::on_navTimeSlider_valueChanged(int value)
}
}
void ATVModGUI::on_playCamera_toggled(bool checked __attribute__((unused)))
void ATVModGUI::on_playCamera_toggled(bool checked)
{
m_settings.m_cameraPlay = checked;
applySettings();
}
@ -568,6 +561,7 @@ void ATVModGUI::on_overlayTextShow_toggled(bool checked)
void ATVModGUI::on_overlayText_textEdited(const QString& arg1 __attribute__((unused)))
{
m_settings.m_overlayText = arg1;
ATVMod::MsgConfigureOverlayText* message = ATVMod::MsgConfigureOverlayText::create(ui->overlayText->text());
m_atvMod->getInputMessageQueue()->push(message);
}
@ -683,34 +677,87 @@ void ATVModGUI::applySettings()
{
if (m_doApplySettings)
{
setTitleColor(m_channelMarker.getColor());
m_channelizer->configure(m_channelizer->getInputMessageQueue(),
m_channelizer->getOutputSampleRate(),
m_channelMarker.getCenterFrequency());
ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency());
m_atvMod->configure(m_atvMod->getInputMessageQueue(),
ui->rfBW->value() * m_rfSliderDivisor * 1.0f,
ui->rfOppBW->value() * m_rfSliderDivisor * 1.0f,
(ATVMod::ATVStd) ui->standard->currentIndex(),
getNbLines(),
getFPS(),
(ATVMod::ATVModInput) ui->inputSelect->currentIndex(),
ui->uniformLevel->value() / 100.0f,
(ATVMod::ATVModulation) ui->modulation->currentIndex(),
ui->playLoop->isChecked(),
ui->playVideo->isChecked(),
ui->playCamera->isChecked(),
ui->channelMute->isChecked(),
ui->invertVideo->isChecked(),
ui->rfScaling->value() * 327.68f,
ui->fmExcursion->value() / 1000.0f, // percentage of full bandwidth. Value in pro milli
ui->forceDecimator->isChecked());
m_atvMod->configure(m_atvMod->getInputMessageQueue(),
m_settings.m_rfBandwidth,
m_settings.m_rfOppBandwidth,
m_settings.m_atvStd,
m_settings.m_nbLines,
m_settings.m_fps,
m_settings.m_atvModInput,
m_settings.m_uniformLevel,
m_settings.m_atvModulation,
m_settings.m_videoPlayLoop,
m_settings.m_videoPlay,
m_settings.m_cameraPlay,
m_settings.m_channelMute,
m_settings.m_invertedVideo,
m_settings.m_rfScalingFactor,
m_settings.m_fmExcursion, // percentage of full bandwidth. Value in pro milli
m_settings.m_forceDecimator);
}
}
void ATVModGUI::displaySettings()
{
m_channelMarker.blockSignals(true);
m_channelMarker.setCenterFrequency(m_settings.m_inputFrequencyOffset);
m_channelMarker.setColor(m_settings.m_rgbColor);
m_channelMarker.blockSignals(false);
setTitleColor(m_settings.m_rgbColor);
setWindowTitle(m_channelMarker.getTitle());
blockApplySettings(true);
ui->modulation->setCurrentIndex((int) m_settings.m_atvModulation);
setRFFiltersSlidersRange(m_atvMod->getEffectiveSampleRate());
ui->rfBW->setValue(roundf(m_settings.m_rfBandwidth / m_rfSliderDivisor));
ui->rfBWText->setText(QString("%1k").arg((ui->rfBW->value()*m_rfSliderDivisor) / 1000.0, 0, 'f', 0));
ui->rfOppBW->setValue(roundf(m_settings.m_rfOppBandwidth / m_rfSliderDivisor));
ui->rfOppBWText->setText(QString("%1k").arg((ui->rfOppBW->value()*m_rfSliderDivisor) / 1000.0, 0, 'f', 0));
setChannelMarkerBandwidth();
ui->deltaFrequency->setValue(m_settings.m_inputFrequencyOffset);
ui->forceDecimator->setChecked(m_settings.m_forceDecimator);
ui->channelMute->setChecked(m_settings.m_channelMute);
ui->fmExcursion->setValue(roundf(m_settings.m_fmExcursion * 1000.0));
ui->fmExcursionText->setText(tr("%1").arg(ui->fmExcursion->value() / 10.0, 0, 'f', 1));
ui->rfScaling->setValue(roundf(m_settings.m_rfScalingFactor / 327.68f));
ui->rfScalingText->setText(tr("%1").arg(ui->rfScaling->value()));
int validNbLinesIndex = getNbLinesIndex(m_settings.m_nbLines);
ui->nbLines->setCurrentIndex(validNbLinesIndex);
m_settings.m_nbLines = getNbLines(); // normalize
int validFPSIndex = getFPSIndex(m_settings.m_fps);
ui->fps->setCurrentIndex(validFPSIndex);
m_settings.m_fps = getFPS(); // normalize
ui->standard->setCurrentIndex((int) m_settings.m_atvStd);
ui->inputSelect->setCurrentIndex((int) m_settings.m_atvModInput);
ui->invertVideo->setChecked(m_settings.m_invertedVideo);
ui->uniformLevel->setValue(roundf(m_settings.m_uniformLevel * 100.0));
ui->uniformLevelText->setText(QString("%1").arg(ui->uniformLevel->value()));
ui->overlayText->setText(m_settings.m_overlayText);
ATVMod::MsgConfigureOverlayText* message = ATVMod::MsgConfigureOverlayText::create(ui->overlayText->text());
m_atvMod->getInputMessageQueue()->push(message);
blockApplySettings(false);
}
void ATVModGUI::leaveEvent(QEvent*)
{
blockApplySettings(true);
@ -731,7 +778,7 @@ void ATVModGUI::tick()
m_channelPowerDbAvg.feed(powDb);
ui->channelPower->setText(tr("%1 dB").arg(m_channelPowerDbAvg.average(), 0, 'f', 1));
if (((++m_tickCount & 0xf) == 0) && (ui->inputSelect->currentIndex() == (int) ATVMod::ATVModInputVideo))
if (((++m_tickCount & 0xf) == 0) && (ui->inputSelect->currentIndex() == (int) ATVModSettings::ATVModInputVideo))
{
ATVMod::MsgConfigureVideoFileSourceStreamTiming* message = ATVMod::MsgConfigureVideoFileSourceStreamTiming::create();
m_atvMod->getInputMessageQueue()->push(message);

Wyświetl plik

@ -24,6 +24,7 @@
#include "util/messagequeue.h"
#include "atvmod.h"
#include "atvmodsettings.h"
class PluginAPI;
class DeviceSinkAPI;
@ -73,7 +74,7 @@ private slots:
void on_nbLines_currentIndexChanged(int index);
void on_fps_currentIndexChanged(int index);
void on_standard_currentIndexChanged(int index);
void on_invertVideo_clicked();
void on_invertVideo_clicked(bool checked);
void on_uniformLevel_valueChanged(int value);
void on_inputSelect_currentIndexChanged(int index);
void on_imageFileDialog_clicked(bool checked);
@ -103,6 +104,7 @@ private:
PluginAPI* m_pluginAPI;
DeviceSinkAPI* m_deviceAPI;
ChannelMarker m_channelMarker;
ATVModSettings m_settings;
bool m_basicSettingsShown;
bool m_doApplySettings;
@ -127,12 +129,15 @@ private:
void blockApplySettings(bool block);
void applySettings();
void displaySettings();
void updateWithStreamData();
void updateWithStreamTime();
void setRFFiltersSlidersRange(int sampleRate);
void setChannelMarkerBandwidth();
int getNbLines();
int getFPS();
int getNbLinesIndex(int nbLines);
int getFPSIndex(int fps);
void leaveEvent(QEvent*);
void enterEvent(QEvent*);

Wyświetl plik

@ -445,6 +445,9 @@
<height>24</height>
</size>
</property>
<property name="toolTip">
<string>RF volume</string>
</property>
<property name="maximum">
<number>100</number>
</property>

Wyświetl plik

@ -48,6 +48,7 @@ void ATVModSettings::resetToDefaults()
m_fmExcursion = 0.5f; // half bandwidth
m_forceDecimator = false;
m_overlayText = "ATV";
m_rgbColor = Qt::white;
}
QByteArray ATVModSettings::serialize() const