Skip to content

Commit

Permalink
SSB demod: fixed GUI and returned to previous threading model. Fixes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
f4exb committed Oct 12, 2024
1 parent 141d0c1 commit 4a9b1c3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 33 deletions.
41 changes: 10 additions & 31 deletions plugins/channeltx/modssb/ssbmod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ SSBMod::SSBMod(DeviceAPI *deviceAPI) :
m_spectrumVis(SDR_TX_SCALEF)
{
setObjectName(m_channelId);

m_thread = new QThread(this);
m_basebandSource = new SSBModBaseband();
m_basebandSource->setSpectrumSink(&m_spectrumVis);
m_basebandSource->setInputFileStream(&m_ifstream);
m_basebandSource->setChannel(this);
m_basebandSource->moveToThread(m_thread);

applySettings(m_settings, true);

m_deviceAPI->addChannelSource(this);
Expand All @@ -85,8 +93,8 @@ SSBMod::~SSBMod()
delete m_networkManager;
m_deviceAPI->removeChannelSourceAPI(this);
m_deviceAPI->removeChannelSource(this);

SSBMod::stop();
delete m_basebandSource;
delete m_thread;
}

void SSBMod::setDeviceAPI(DeviceAPI *deviceAPI)
Expand All @@ -108,37 +116,8 @@ void SSBMod::start()
}

qDebug("SSBMod::start");
m_thread = new QThread(this);
m_basebandSource = new SSBModBaseband();
m_basebandSource->setSpectrumSink(&m_spectrumVis);
m_basebandSource->setInputFileStream(&m_ifstream);
m_basebandSource->setChannel(this);
m_basebandSource->reset();
m_basebandSource->setCWKeyer(&m_cwKeyer);
m_basebandSource->moveToThread(m_thread);

QObject::connect(
m_thread,
&QThread::finished,
m_basebandSource,
&QObject::deleteLater
);
QObject::connect(
m_thread,
&QThread::finished,
m_thread,
&QThread::deleteLater
);

m_thread->start();

SSBModBaseband::MsgConfigureSSBModBaseband *msg = SSBModBaseband::MsgConfigureSSBModBaseband::create(m_settings, true);
m_basebandSource->getInputMessageQueue()->push(msg);

if (m_levelMeter) {
connect(m_basebandSource, SIGNAL(levelChanged(qreal, qreal, int)), m_levelMeter, SLOT(levelChanged(qreal, qreal, int)));
}

m_running = true;
}

Expand Down
21 changes: 19 additions & 2 deletions plugins/channeltx/modssb/ssbmodgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,13 +547,29 @@ void SSBModGUI::applySettings(bool force)
}
}

uint32_t SSBModGUI::getValidAudioSampleRate() const
{
// When not running, m_ssbDemod->getAudioSampleRate() will return 0, but we
// want a valid value to initialise the GUI, to allow a user to preselect settings
int sr = m_ssbMod->getAudioSampleRate();
if (sr == 0)
{
if (m_audioSampleRate > 0) {
sr = m_audioSampleRate;
} else {
sr = 48000;
}
}
return sr;
}

void SSBModGUI::applyBandwidths(int spanLog2, bool force)
{
bool dsb = ui->dsb->isChecked();
m_spectrumRate = m_ssbMod->getAudioSampleRate() / (1<<spanLog2);
m_spectrumRate = getValidAudioSampleRate() / (1<<spanLog2);
int bw = ui->BW->value();
int lw = ui->lowCut->value();
int bwMax = m_ssbMod->getAudioSampleRate() / (100*(1<<spanLog2));
int bwMax = getValidAudioSampleRate() / (100*(1<<spanLog2));
int tickInterval = m_spectrumRate / 1200;
tickInterval = tickInterval == 0 ? 1 : tickInterval;

Expand Down Expand Up @@ -897,6 +913,7 @@ void SSBModGUI::makeUIConnections()
QObject::connect(ui->showFileDialog, &QPushButton::clicked, this, &SSBModGUI::on_showFileDialog_clicked);
QObject::connect(ui->feedbackEnable, &QToolButton::toggled, this, &SSBModGUI::on_feedbackEnable_toggled);
QObject::connect(ui->feedbackVolume, &QDial::valueChanged, this, &SSBModGUI::on_feedbackVolume_valueChanged);
QObject::connect(ui->spanLog2, &QSlider::valueChanged, this, &SSBModGUI::on_spanLog2_valueChanged);
}

void SSBModGUI::updateAbsoluteCenterFrequency()
Expand Down
1 change: 1 addition & 0 deletions plugins/channeltx/modssb/ssbmodgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ public slots:
bool handleMessage(const Message& message);
void makeUIConnections();
void updateAbsoluteCenterFrequency();
uint32_t getValidAudioSampleRate() const;

void leaveEvent(QEvent*);
void enterEvent(EnterEventType*);
Expand Down

0 comments on commit 4a9b1c3

Please sign in to comment.