1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 09:48:45 -05:00

AM demod: use settings object to apply settings

This commit is contained in:
f4exb 2017-09-26 23:53:35 +02:00
parent 69a94c6004
commit 1bb612bf62
4 changed files with 66 additions and 50 deletions

View File

@ -43,13 +43,6 @@ AMDemod::AMDemod() :
{
setObjectName("AMDemod");
// m_config.m_inputSampleRate = 96000;
// m_config.m_inputFrequencyOffset = 0;
// m_config.m_rfBandwidth = 5000;
// m_config.m_squelch = -40.0;
// m_config.m_volume = 2.0;
// m_config.m_audioSampleRate = DSPEngine::instance()->getAudioSampleRate();
m_audioBuffer.resize(1<<14);
m_audioBufferFill = 0;

View File

@ -138,37 +138,7 @@ private:
RSRunning
};
// struct Config {
// int m_inputSampleRate;
// qint64 m_inputFrequencyOffset;
// Real m_rfBandwidth;
// Real m_squelch;
// Real m_volume;
// quint32 m_audioSampleRate;
// bool m_audioMute;
// bool m_bandpassEnable;
// bool m_copyAudioToUDP;
// QString m_udpAddress;
// quint16 m_udpPort;
//
// Config() :
// m_inputSampleRate(-1),
// m_inputFrequencyOffset(0),
// m_rfBandwidth(-1),
// m_squelch(0),
// m_volume(0),
// m_audioSampleRate(0),
// m_audioMute(false),
// m_bandpassEnable(false),
// m_copyAudioToUDP(false),
// m_udpAddress("127.0.0.1"),
// m_udpPort(9999)
// { }
// };
AMDemodSettings m_settings;
// Config m_config;
// Config m_running;
NCO m_nco;
Interpolator m_interpolator;

View File

@ -155,6 +155,9 @@ bool AMDemodGUI::handleMessage(const Message& message __attribute__((unused)))
void AMDemodGUI::channelMarkerChanged()
{
this->setWindowTitle(m_channelMarker.getTitle());
m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency();
m_settings.m_udpAddress = m_channelMarker.getUDPAddress(),
m_settings.m_udpPort = m_channelMarker.getUDPSendPort(),
displayUDPAddress();
applySettings();
}
@ -162,10 +165,13 @@ void AMDemodGUI::channelMarkerChanged()
void AMDemodGUI::on_deltaFrequency_changed(qint64 value)
{
m_channelMarker.setCenterFrequency(value);
m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency();
applySettings();
}
void AMDemodGUI::on_bandpassEnable_toggled(bool checked __attribute__((unused)))
void AMDemodGUI::on_bandpassEnable_toggled(bool checked)
{
m_settings.m_bandpassEnable = checked;
applySettings();
}
@ -173,28 +179,33 @@ void AMDemodGUI::on_rfBW_valueChanged(int value)
{
ui->rfBWText->setText(QString("%1 kHz").arg(value / 10.0, 0, 'f', 1));
m_channelMarker.setBandwidth(value * 100);
m_settings.m_rfBandwidth = value * 100;
applySettings();
}
void AMDemodGUI::on_volume_valueChanged(int value)
{
ui->volumeText->setText(QString("%1").arg(value / 10.0, 0, 'f', 1));
m_settings.m_volume = value / 10.0;
applySettings();
}
void AMDemodGUI::on_squelch_valueChanged(int value)
{
ui->squelchText->setText(QString("%1 dB").arg(value));
m_settings.m_squelch = value;
applySettings();
}
void AMDemodGUI::on_audioMute_toggled(bool checked __attribute__((unused)))
void AMDemodGUI::on_audioMute_toggled(bool checked)
{
m_settings.m_audioMute = checked;
applySettings();
}
void AMDemodGUI::on_copyAudioToUDP_toggled(bool checked __attribute__((unused)))
void AMDemodGUI::on_copyAudioToUDP_toggled(bool checked)
{
m_settings.m_copyAudioToUDP = checked;
applySettings();
}
@ -257,6 +268,7 @@ AMDemodGUI::AMDemodGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidget
m_deviceAPI->addChannelMarker(&m_channelMarker);
m_deviceAPI->addRollupWidget(this);
displaySettings();
applySettings(true);
}
@ -288,19 +300,57 @@ void AMDemodGUI::applySettings(bool force)
ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency());
m_amDemod->configure(m_amDemod->getInputMessageQueue(),
ui->rfBW->value() * 100.0,
ui->volume->value() / 10.0,
ui->squelch->value(),
ui->audioMute->isChecked(),
ui->bandpassEnable->isChecked(),
ui->copyAudioToUDP->isChecked(),
m_channelMarker.getUDPAddress(),
m_channelMarker.getUDPSendPort(),
force);
// m_amDemod->configure(m_amDemod->getInputMessageQueue(),
// ui->rfBW->value() * 100.0,
// ui->volume->value() / 10.0,
// ui->squelch->value(),
// ui->audioMute->isChecked(),
// ui->bandpassEnable->isChecked(),
// ui->copyAudioToUDP->isChecked(),
// m_channelMarker.getUDPAddress(),
// m_channelMarker.getUDPSendPort(),
// force);
m_amDemod->configure(m_amDemod->getInputMessageQueue(),
m_settings.m_rfBandwidth,
m_settings.m_volume,
m_settings.m_squelch,
m_settings.m_audioMute,
m_settings.m_bandpassEnable,
m_settings.m_copyAudioToUDP,
m_settings.m_udpAddress,
m_settings.m_udpPort,
force);
}
}
void AMDemodGUI::displaySettings()
{
blockApplySettings(true);
int displayValue = m_settings.m_rfBandwidth/100.0;
ui->rfBW->setValue(displayValue);
ui->rfBWText->setText(QString("%1 kHz").arg(displayValue / 10.0, 0, 'f', 1));
m_channelMarker.setBandwidth(m_settings.m_rfBandwidth);
ui->volume->setValue(m_settings.m_volume * 10.0);
ui->volumeText->setText(QString("%1").arg(m_settings.m_volume, 0, 'f', 1));
ui->squelch->setValue(m_settings.m_squelch);
ui->squelchText->setText(QString("%1 dB").arg(m_settings.m_squelch));
ui->audioMute->setChecked(m_settings.m_audioMute);
ui->bandpassEnable->setChecked(m_settings.m_bandpassEnable);
ui->copyAudioToUDP->setChecked(m_settings.m_copyAudioToUDP);
m_channelMarker.setCenterFrequency(m_settings.m_inputFrequencyOffset);
m_channelMarker.setUDPAddress(m_settings.m_udpAddress);
m_channelMarker.setUDPSendPort(m_settings.m_udpPort);
blockApplySettings(false);
}
void AMDemodGUI::displayUDPAddress()
{
ui->copyAudioToUDP->setToolTip(QString("Copy audio output to UDP %1:%2").arg(m_channelMarker.getUDPAddress()).arg(m_channelMarker.getUDPSendPort()));

View File

@ -6,6 +6,7 @@
#include "dsp/channelmarker.h"
#include "dsp/movingaverage.h"
#include "util/messagequeue.h"
#include "amdemodsettings.h"
class PluginAPI;
class DeviceSourceAPI;
@ -56,6 +57,7 @@ private:
PluginAPI* m_pluginAPI;
DeviceSourceAPI* m_deviceAPI;
ChannelMarker m_channelMarker;
AMDemodSettings m_settings;
bool m_doApplySettings;
ThreadedBasebandSampleSink* m_threadedChannelizer;
@ -70,6 +72,7 @@ private:
void blockApplySettings(bool block);
void applySettings(bool force = false);
void displaySettings();
void displayUDPAddress();
void leaveEvent(QEvent*);