mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-02-03 09:44:01 -05:00
ATV demod: scaling multiply and shift parameters. Reworked top time setting. Added some missing serialize/deserialize settings
This commit is contained in:
parent
563c509c7c
commit
53dc81b0df
@ -136,6 +136,10 @@ void ATVDemodGUI::displaySettings()
|
||||
ui->bfoText->setText(QString("%1").arg(m_settings.m_bfoFrequency * 1.0, 0, 'f', 0));
|
||||
ui->fmDeviation->setValue((int) (m_settings.m_fmDeviation * 1000.0f));
|
||||
ui->fmDeviationText->setText(QString("%1").arg(m_settings.m_fmDeviation * 100.0, 0, 'f', 1));
|
||||
ui->amScaleFactor->setValue(m_settings.m_amScalingFactor);
|
||||
ui->amScaleFactorText->setText(QString("%1").arg(m_settings.m_amScalingFactor));
|
||||
ui->amScaleOffset->setValue(m_settings.m_amOffsetFactor);
|
||||
ui->amScaleOffsetText->setText(QString("%1").arg(m_settings.m_amOffsetFactor));
|
||||
blockApplySettings(false);
|
||||
|
||||
applyTVSampleRate();
|
||||
@ -436,7 +440,7 @@ void ATVDemodGUI::on_lineTime_valueChanged(int value)
|
||||
|
||||
void ATVDemodGUI::on_topTime_valueChanged(int value)
|
||||
{
|
||||
ui->topTime->setToolTip(QString("Horizontal sync pulse length adjustment (%1)").arg(value));
|
||||
ui->topTime->setToolTip(QString("Horizontal sync pulse length adjustment (%1 %)").arg(value));
|
||||
m_settings.m_topTimeFactor = value;
|
||||
topTimeUpdate();
|
||||
applySettings();
|
||||
@ -552,6 +556,22 @@ void ATVDemodGUI::on_fmDeviation_valueChanged(int value)
|
||||
applySettings();
|
||||
}
|
||||
|
||||
void ATVDemodGUI::on_amScaleFactor_valueChanged(int value)
|
||||
{
|
||||
ui->amScaleFactor->setValue(m_settings.m_amScalingFactor);
|
||||
ui->amScaleFactorText->setText(QString("%1").arg(m_settings.m_amScalingFactor));
|
||||
m_settings.m_amScalingFactor = value;
|
||||
applySettings();
|
||||
}
|
||||
|
||||
void ATVDemodGUI::on_amScaleOffset_valueChanged(int value)
|
||||
{
|
||||
ui->amScaleOffset->setValue(m_settings.m_amOffsetFactor);
|
||||
ui->amScaleOffsetText->setText(QString("%1").arg(m_settings.m_amOffsetFactor));
|
||||
m_settings.m_amOffsetFactor = value;
|
||||
applySettings();
|
||||
}
|
||||
|
||||
void ATVDemodGUI::on_screenTabWidget_currentChanged(int index)
|
||||
{
|
||||
m_atvDemod->setVideoTabIndex(index);
|
||||
@ -585,15 +605,7 @@ void ATVDemodGUI::lineTimeUpdate()
|
||||
void ATVDemodGUI::topTimeUpdate()
|
||||
{
|
||||
float nominalTopTime = ATVDemodSettings::getNominalLineTime(m_settings.m_nbLines, m_settings.m_fps) * (4.7f / 64.0f);
|
||||
int topTimeScaleFactor = (int) std::log10(nominalTopTime);
|
||||
|
||||
if (m_tvSampleRate == 0) {
|
||||
m_fltTopTimeMultiplier = std::pow(10.0, topTimeScaleFactor-3);
|
||||
} else {
|
||||
m_fltTopTimeMultiplier = 1.0f / m_tvSampleRate;
|
||||
}
|
||||
|
||||
float topTime = nominalTopTime + m_fltTopTimeMultiplier * ui->topTime->value();
|
||||
float topTime = nominalTopTime * (ui->topTime->value() / 100.0f);
|
||||
|
||||
if (topTime < 0.0)
|
||||
ui->topTimeText->setText("invalid");
|
||||
|
@ -77,7 +77,6 @@ private:
|
||||
ScopeVis* m_scopeVis;
|
||||
|
||||
float m_fltLineTimeMultiplier;
|
||||
float m_fltTopTimeMultiplier;
|
||||
int m_rfSliderDivisor;
|
||||
int m_basebandSampleRate;
|
||||
int m_tvSampleRate;
|
||||
@ -124,6 +123,8 @@ private slots:
|
||||
void on_deltaFrequency_changed(qint64 value);
|
||||
void on_bfo_valueChanged(int value);
|
||||
void on_fmDeviation_valueChanged(int value);
|
||||
void on_amScaleFactor_valueChanged(int value);
|
||||
void on_amScaleOffset_valueChanged(int value);
|
||||
void on_screenTabWidget_currentChanged(int index);
|
||||
};
|
||||
|
||||
|
@ -367,6 +367,108 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="amScaleFactorLabel">
|
||||
<property name="text">
|
||||
<string>AM</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDial" name="amScaleFactor">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Adjust AM scaling as % of nominal scale</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>50</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>200</number>
|
||||
</property>
|
||||
<property name="pageStep">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>100</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="amScaleFactorText">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>26</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>% of nominal scale</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>100</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDial" name="amScaleOffset">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>AM offset as % of adjusted scale</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>-50</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>50</number>
|
||||
</property>
|
||||
<property name="pageStep">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="amScaleOffsetText">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>26</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>% of full scale</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>-50</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_4">
|
||||
<property name="orientation">
|
||||
@ -906,10 +1008,10 @@
|
||||
<string>Horizontal sync pulse length adjustment</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>-30</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>30</number>
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>1</number>
|
||||
@ -918,7 +1020,7 @@
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>0</number>
|
||||
<number>25</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
|
@ -35,6 +35,8 @@ void ATVDemodSettings::resetToDefaults()
|
||||
m_bfoFrequency = 0.0f;
|
||||
m_atvModulation = ATV_FM1;
|
||||
m_fmDeviation = 0.5f;
|
||||
m_amScalingFactor = 100;
|
||||
m_amOffsetFactor = 0;
|
||||
m_fftFiltering = false;
|
||||
m_fftOppBandwidth = 0;
|
||||
m_fftBandwidth = 6000;
|
||||
@ -48,7 +50,7 @@ void ATVDemodSettings::resetToDefaults()
|
||||
m_levelSynchroTop = 0.1f;
|
||||
m_levelBlack = 0.3f;
|
||||
m_lineTimeFactor = 0;
|
||||
m_topTimeFactor = 0;
|
||||
m_topTimeFactor = 25;
|
||||
m_rgbColor = QColor(255, 255, 255).rgb();
|
||||
m_title = "ATV Demodulator";
|
||||
m_udpAddress = "127.0.0.1";
|
||||
@ -85,6 +87,10 @@ QByteArray ATVDemodSettings::serialize() const
|
||||
|
||||
s.writeString(20, m_title);
|
||||
s.writeS32(21, m_streamIndex);
|
||||
s.writeS32(22, m_amScalingFactor);
|
||||
s.writeS32(23, m_amOffsetFactor);
|
||||
s.writeBool(24, m_fftFiltering);
|
||||
s.writeBool(25, m_forceDecimator);
|
||||
|
||||
return s.final();
|
||||
}
|
||||
@ -111,7 +117,7 @@ bool ATVDemodSettings::deserialize(const QByteArray& arrData)
|
||||
d.readS32(4, &tmp, 310);
|
||||
m_levelBlack = tmp / 1000.0f;
|
||||
d.readS32(5, &m_lineTimeFactor, 0);
|
||||
d.readS32(6, &m_topTimeFactor, 0);
|
||||
d.readS32(6, &m_topTimeFactor, 25);
|
||||
d.readS32(7, &tmp, 0);
|
||||
m_atvModulation = static_cast<ATVModulation>(tmp);
|
||||
d.readS32(8, &tmp, 25);
|
||||
@ -132,6 +138,10 @@ bool ATVDemodSettings::deserialize(const QByteArray& arrData)
|
||||
d.readS32(18, &tmp, 1);
|
||||
m_atvStd = static_cast<ATVStd>(tmp);
|
||||
d.readS32(21, &m_streamIndex, 0);
|
||||
d.readS32(22, &m_amScalingFactor, 100);
|
||||
d.readS32(23, &m_amOffsetFactor, 0);
|
||||
d.readBool(24, &m_fftFiltering, false);
|
||||
d.readBool(25, &m_forceDecimator, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -310,25 +320,9 @@ float ATVDemodSettings::getLineTime(unsigned int sampleRate)
|
||||
return nominalLineTime + m_fltLineTimeMultiplier * m_lineTimeFactor;
|
||||
}
|
||||
|
||||
/**
|
||||
* calculates m_fltTopTimeMultiplier
|
||||
*/
|
||||
void ATVDemodSettings::topTimeUpdate(unsigned int sampleRate)
|
||||
{
|
||||
float nominalTopTime = getNominalLineTime(m_nbLines, m_fps) * (4.7f / 64.0f);
|
||||
int topTimeScaleFactor = (int) std::log10(nominalTopTime);
|
||||
|
||||
if (sampleRate == 0) {
|
||||
m_fltTopTimeMultiplier = std::pow(10.0, topTimeScaleFactor-3);
|
||||
} else {
|
||||
m_fltTopTimeMultiplier = 1.0f / sampleRate;
|
||||
}
|
||||
}
|
||||
|
||||
float ATVDemodSettings::getTopTime(unsigned int sampleRate)
|
||||
{
|
||||
topTimeUpdate(sampleRate);
|
||||
return getNominalLineTime(m_nbLines, m_fps) * (4.7f / 64.0f) + m_fltTopTimeMultiplier * m_topTimeFactor;
|
||||
return getNominalLineTime(m_nbLines, m_fps) * (4.7f / 64.0f) * (m_topTimeFactor / 100.0f);
|
||||
}
|
||||
|
||||
int ATVDemodSettings::getRFSliderDivisor(unsigned int sampleRate)
|
||||
|
@ -51,6 +51,8 @@ struct ATVDemodSettings
|
||||
int m_bfoFrequency; //!< BFO frequency (Hz)
|
||||
ATVModulation m_atvModulation; //!< RF modulation type
|
||||
float m_fmDeviation; //!< Expected FM deviation
|
||||
int m_amScalingFactor; //!< Factor in % to apply to detected signal scale
|
||||
int m_amOffsetFactor; //!< Factor in % to apply to adjusted signal scale
|
||||
bool m_fftFiltering; //!< Toggle FFT filter
|
||||
unsigned int m_fftOppBandwidth; //!< FFT filter lower frequency cutoff (Hz)
|
||||
unsigned int m_fftBandwidth; //!< FFT filter high frequency cutoff (Hz)
|
||||
@ -66,7 +68,7 @@ struct ATVDemodSettings
|
||||
float m_levelSynchroTop; //!< Horizontal synchronization top level (0.0 to 1.0 scale)
|
||||
float m_levelBlack; //!< Black level (0.0 to 1.0 scale)
|
||||
int m_lineTimeFactor; //!< added: +/- 100 something
|
||||
int m_topTimeFactor; //!< added: +/- 30 something
|
||||
int m_topTimeFactor; //!< percentage of nominal horizontal top (pulse) time
|
||||
|
||||
// common channel settings
|
||||
quint32 m_rgbColor;
|
||||
@ -96,10 +98,8 @@ struct ATVDemodSettings
|
||||
|
||||
private:
|
||||
void lineTimeUpdate(unsigned int sampleRate);
|
||||
void topTimeUpdate(unsigned int sampleRate);
|
||||
|
||||
float m_fltLineTimeMultiplier;
|
||||
float m_fltTopTimeMultiplier;
|
||||
int m_rfSliderDivisor;
|
||||
};
|
||||
|
||||
|
@ -298,6 +298,10 @@ void ATVDemodSink::demod(Complex& c)
|
||||
m_ampDelta = 1.0f;
|
||||
}
|
||||
|
||||
// readjustment
|
||||
m_ampDelta /= m_settings.m_amScalingFactor / 100.0f;
|
||||
m_ampMin += m_ampDelta * (m_settings.m_amOffsetFactor / 100.0f);
|
||||
|
||||
// qDebug("ATVDemod::demod: m_ampMin: %f m_ampMax: %f m_ampDelta: %f", m_ampMin, m_ampMax, m_ampDelta);
|
||||
|
||||
//Reset extrema
|
||||
@ -409,7 +413,7 @@ void ATVDemodSink::applyStandard(int sampleRate, const ATVDemodSettings& setting
|
||||
m_numberSamplesPerLineSignals = (int) ((12.0f/64.0f) * lineDuration * sampleRate); // 12.0 = 2.6 + 4.7 + 4.7 : front porch + horizontal sync pulse + back porch
|
||||
m_numberSamplesPerHSync = (int) ((9.6f/64.0f) * lineDuration * sampleRate); // 9.4 = 4.7 + 4.7 : horizontal sync pulse + back porch
|
||||
m_numberSamplesPerHTopNom = (int) ((4.7f/64.0f) * lineDuration * sampleRate); // 4.7 : horizontal sync pulse (ultra black) nominal value
|
||||
m_numberSamplesPerHTop = m_numberSamplesPerHTopNom + settings.m_topTimeFactor; // adjust the value used in the system
|
||||
m_numberSamplesPerHTop = m_numberSamplesPerHTopNom * (settings.m_topTimeFactor / 100.0f); // adjust the value used in the system
|
||||
}
|
||||
|
||||
bool ATVDemodSink::getBFOLocked()
|
||||
@ -585,7 +589,7 @@ void ATVDemodSink::applySettings(const ATVDemodSettings& settings, bool force)
|
||||
}
|
||||
|
||||
if ((settings.m_topTimeFactor != m_settings.m_topTimeFactor) || force) {
|
||||
m_numberSamplesPerHTop = m_numberSamplesPerHTopNom + settings.m_topTimeFactor;
|
||||
m_numberSamplesPerHTop = m_numberSamplesPerHTopNom * (settings.m_topTimeFactor / 100.0f);
|
||||
}
|
||||
|
||||
if ((settings.m_fmDeviation != m_settings.m_fmDeviation) || force) {
|
||||
|
Loading…
Reference in New Issue
Block a user