1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-17 13:51:47 -05:00

Preparation for variable span SSB

This commit is contained in:
f4exb 2015-06-11 05:47:59 +02:00
parent 3d2b82b934
commit bec01078d9
3 changed files with 124 additions and 31 deletions

View File

@ -41,6 +41,7 @@ void SSBDemodGUI::resetToDefaults()
ui->BW->setValue(30);
ui->volume->setValue(40);
ui->deltaFrequency->setValue(0);
ui->spanLog2->setValue(3);
applySettings();
}
@ -53,6 +54,7 @@ QByteArray SSBDemodGUI::serialize() const
s.writeS32(3, ui->volume->value());
s.writeBlob(4, ui->spectrumGUI->serialize());
s.writeU32(5, m_channelMarker->getColor().rgb());
s.writeS32(6, ui->spanLog2->value());
return s.final();
}
@ -81,6 +83,9 @@ bool SSBDemodGUI::deserialize(const QByteArray& data)
ui->spectrumGUI->deserialize(bytetmp);
if(d.readU32(5, &u32tmp))
m_channelMarker->setColor(u32tmp);
d.readS32(6, &tmp, 20);
ui->spanLog2->setValue(tmp);
setNewRate(tmp);
applySettings();
return true;
} else {
@ -122,7 +127,7 @@ void SSBDemodGUI::on_deltaFrequency_changed(quint64 value)
void SSBDemodGUI::on_BW_valueChanged(int value)
{
QString s = QString::number(value/10.0, 'f', 1);
ui->BWText->setText(s);
ui->BWText->setText(tr("%1k").arg(s));
m_channelMarker->setBandwidth(value * 100 * 2);
if (value < 0) {
@ -164,7 +169,7 @@ void SSBDemodGUI::on_lowCut_valueChanged(int value)
int lowCutoff = getEffectiveLowCutoff(value * 100);
m_channelMarker->setLowCutoff(lowCutoff);
QString s = QString::number(lowCutoff/1000.0, 'f', 1);
ui->lowCutText->setText(s);
ui->lowCutText->setText(tr("%1k").arg(s));
ui->lowCut->setValue(lowCutoff/100);
applySettings();
}
@ -175,6 +180,14 @@ void SSBDemodGUI::on_volume_valueChanged(int value)
applySettings();
}
void SSBDemodGUI::on_spanLog2_valueChanged(int value)
{
if (setNewRate(value)) {
applySettings();
}
}
void SSBDemodGUI::onWidgetRolled(QWidget* widget, bool rollDown)
{
/*
@ -196,7 +209,8 @@ SSBDemodGUI::SSBDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
RollupWidget(parent),
ui(new Ui::SSBDemodGUI),
m_pluginAPI(pluginAPI),
m_basicSettingsShown(false)
m_basicSettingsShown(false),
m_rate(6000)
{
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose, true);
@ -211,14 +225,14 @@ SSBDemodGUI::SSBDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
m_pluginAPI->addAudioSource(m_audioFifo);
m_pluginAPI->addSampleSink(m_threadedSampleSink);
ui->glSpectrum->setCenterFrequency(3000);
ui->glSpectrum->setSampleRate(6000);
ui->glSpectrum->setCenterFrequency(m_rate/2);
ui->glSpectrum->setSampleRate(m_rate);
ui->glSpectrum->setDisplayWaterfall(true);
ui->glSpectrum->setDisplayMaxHold(true);
m_channelMarker = new ChannelMarker(this);
m_channelMarker->setColor(Qt::green);
m_channelMarker->setBandwidth(6000);
m_channelMarker->setBandwidth(m_rate);
m_channelMarker->setSidebands(ChannelMarker::usb);
m_channelMarker->setCenterFrequency(0);
m_channelMarker->setVisible(true);
@ -244,6 +258,37 @@ SSBDemodGUI::~SSBDemodGUI()
delete ui;
}
bool SSBDemodGUI::setNewRate(int spanLog2)
{
if ((spanLog2 < 0) || (spanLog2 > 5)) {
return false;
}
m_rate = 48000 / (1<<spanLog2);
if (ui->BW->value() < -m_rate/100) {
ui->BW->setValue(-m_rate/100);
} else if (ui->BW->value() > m_rate/100) {
ui->BW->setValue(m_rate/100);
}
if (ui->lowCut->value() < -m_rate/100) {
ui->lowCut->setValue(-m_rate/100);
} else if (ui->lowCut->value() > m_rate/100) {
ui->lowCut->setValue(m_rate/100);
}
ui->BW->setMinimum(-m_rate/100);
ui->lowCut->setMinimum(-m_rate/100);
ui->BW->setMaximum(m_rate/100);
ui->lowCut->setMaximum(m_rate/100);
QString s = QString::number(m_rate/1000.0, 'f', 1);
ui->spanText->setText(tr("%1k").arg(s));
return true;
}
void SSBDemodGUI::applySettings()
{
setTitleColor(m_channelMarker->getColor());

View File

@ -40,6 +40,7 @@ private slots:
void on_BW_valueChanged(int value);
void on_lowCut_valueChanged(int value);
void on_volume_valueChanged(int value);
void on_spanLog2_valueChanged(int value);
void onWidgetRolled(QWidget* widget, bool rollDown);
void onMenuDoubleClicked();
@ -48,6 +49,7 @@ private:
PluginAPI* m_pluginAPI;
ChannelMarker* m_channelMarker;
bool m_basicSettingsShown;
int m_rate;
AudioFifo* m_audioFifo;
ThreadedSampleSink* m_threadedSampleSink;
@ -59,6 +61,7 @@ private:
~SSBDemodGUI();
int getEffectiveLowCutoff(int lowCutoff);
bool setNewRate(int spanLog2);
void applySettings();
void leaveEvent(QEvent*);

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>302</width>
<height>410</height>
<height>510</height>
</rect>
</property>
<property name="windowTitle">
@ -41,7 +41,7 @@
<property name="spacing">
<number>3</number>
</property>
<item row="1" column="1">
<item row="2" column="1">
<widget class="QSlider" name="BW">
<property name="minimum">
<number>-60</number>
@ -60,7 +60,7 @@
</property>
</widget>
</item>
<item row="3" column="2">
<item row="4" column="2">
<widget class="QLabel" name="volumeText">
<property name="minimumSize">
<size>
@ -76,7 +76,7 @@
</property>
</widget>
</item>
<item row="1" column="2">
<item row="2" column="2">
<widget class="QLabel" name="BWText">
<property name="minimumSize">
<size>
@ -85,14 +85,14 @@
</size>
</property>
<property name="text">
<string>3.0</string>
<string>3.0k</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="1">
<item row="4" column="1">
<widget class="QSlider" name="volume">
<property name="maximum">
<number>100</number>
@ -136,24 +136,38 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="BWLabel">
<item row="0" column="2">
<widget class="QLabel" name="deltaUnits">
<property name="text">
<string>Bandwidth</string>
<string>Hz</string>
</property>
</widget>
</item>
<item row="3" column="0">
<item row="4" column="0">
<widget class="QLabel" name="volumeLabel">
<property name="text">
<string>Volume</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="deltaUnits">
<item row="2" column="0">
<widget class="QLabel" name="BWLabel">
<property name="text">
<string>Hz</string>
<string>Bandwidth</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="spanLabel">
<property name="text">
<string>Span</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="lowCutLabel">
<property name="text">
<string>Low cutoff</string>
</property>
</widget>
</item>
@ -167,14 +181,7 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lowCutLabel">
<property name="text">
<string>Low cutoff</string>
</property>
</widget>
</item>
<item row="2" column="1">
<item row="3" column="1">
<widget class="QSlider" name="lowCut">
<property name="minimum">
<number>-60</number>
@ -193,7 +200,7 @@
</property>
</widget>
</item>
<item row="2" column="2">
<item row="3" column="2">
<widget class="QLabel" name="lowCutText">
<property name="minimumSize">
<size>
@ -202,13 +209,51 @@
</size>
</property>
<property name="text">
<string>0.3</string>
<string>0.3k</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="spanText">
<property name="text">
<string>6.0k</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSlider" name="spanLog2">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>5</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>3</number>
</property>
<property name="sliderPosition">
<number>3</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="invertedAppearance">
<bool>true</bool>
</property>
<property name="invertedControls">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="spectrumContainer" native="true">
@ -217,7 +262,7 @@
<x>40</x>
<y>140</y>
<width>218</width>
<height>184</height>
<height>284</height>
</rect>
</property>
<property name="windowTitle">
@ -244,7 +289,7 @@
<property name="minimumSize">
<size>
<width>200</width>
<height>150</height>
<height>250</height>
</size>
</property>
</widget>