mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-16 05:11:49 -05:00
WFM modulator: use settings in modulator (3)
This commit is contained in:
parent
1d1e885709
commit
cc7b69ebe3
@ -53,14 +53,6 @@ WFMMod::WFMMod() :
|
||||
{
|
||||
setObjectName("WFMod");
|
||||
|
||||
m_config.m_outputSampleRate = 384000;
|
||||
m_config.m_inputFrequencyOffset = 0;
|
||||
m_config.m_rfBandwidth = 125000;
|
||||
m_config.m_afBandwidth = 8000;
|
||||
m_config.m_fmDeviation = 50000.0f;
|
||||
m_config.m_toneFrequency = 1000.0f;
|
||||
m_config.m_audioSampleRate = DSPEngine::instance()->getAudioSampleRate();
|
||||
|
||||
m_rfFilter = new fftfilt(-62500.0 / 384000.0, 62500.0 / 384000.0, m_rfFilterFFTLength);
|
||||
m_rfFilterBuffer = new Complex[m_rfFilterFFTLength];
|
||||
memset(m_rfFilterBuffer, 0, sizeof(Complex)*(m_rfFilterFFTLength));
|
||||
@ -76,13 +68,13 @@ WFMMod::WFMMod() :
|
||||
m_volumeAGC.resize(4096, 0.003, 0);
|
||||
m_magsq = 0.0;
|
||||
|
||||
m_toneNco.setFreq(1000.0, m_config.m_audioSampleRate);
|
||||
m_toneNcoRF.setFreq(1000.0, m_config.m_outputSampleRate);
|
||||
m_toneNco.setFreq(1000.0, m_settings.m_audioSampleRate);
|
||||
m_toneNcoRF.setFreq(1000.0, m_settings.m_outputSampleRate);
|
||||
DSPEngine::instance()->addAudioSource(&m_audioFifo);
|
||||
|
||||
// CW keyer
|
||||
m_cwKeyer.setSampleRate(m_config.m_outputSampleRate);
|
||||
m_cwSmoother.setNbFadeSamples(m_config.m_outputSampleRate / 250); // 4 ms
|
||||
m_cwKeyer.setSampleRate(m_settings.m_outputSampleRate);
|
||||
m_cwSmoother.setNbFadeSamples(m_settings.m_outputSampleRate / 250); // 4 ms
|
||||
m_cwKeyer.setWPM(13);
|
||||
m_cwKeyer.setMode(CWKeyer::CWNone);
|
||||
m_cwKeyer.reset();
|
||||
@ -171,7 +163,7 @@ void WFMMod::pull(Sample& sample)
|
||||
|
||||
void WFMMod::pullAudio(int nbSamples)
|
||||
{
|
||||
unsigned int nbSamplesAudio = nbSamples * ((Real) m_config.m_audioSampleRate / (Real) m_config.m_basebandSampleRate);
|
||||
unsigned int nbSamplesAudio = nbSamples * ((Real) m_settings.m_audioSampleRate / (Real) m_settings.m_basebandSampleRate);
|
||||
|
||||
if (nbSamplesAudio > m_audioBuffer.size())
|
||||
{
|
||||
@ -282,8 +274,8 @@ void WFMMod::calculateLevel(const Real& sample)
|
||||
|
||||
void WFMMod::start()
|
||||
{
|
||||
qDebug() << "WFMMod::start: m_outputSampleRate: " << m_config.m_outputSampleRate
|
||||
<< " m_inputFrequencyOffset: " << m_config.m_inputFrequencyOffset;
|
||||
qDebug() << "WFMMod::start: m_outputSampleRate: " << m_settings.m_outputSampleRate
|
||||
<< " m_inputFrequencyOffset: " << m_settings.m_inputFrequencyOffset;
|
||||
|
||||
m_audioFifo.clear();
|
||||
}
|
||||
@ -337,31 +329,6 @@ bool WFMMod::handleMessage(const Message& cmd)
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (MsgConfigureWFMModPrivate::match(cmd))
|
||||
{
|
||||
MsgConfigureWFMModPrivate& cfg = (MsgConfigureWFMModPrivate&) cmd;
|
||||
|
||||
m_config.m_rfBandwidth = cfg.getRFBandwidth();
|
||||
m_config.m_afBandwidth = cfg.getAFBandwidth();
|
||||
m_config.m_fmDeviation = cfg.getFMDeviation();
|
||||
m_config.m_toneFrequency = cfg.getToneFrequency();
|
||||
m_config.m_volumeFactor = cfg.getVolumeFactor();
|
||||
m_config.m_channelMute = cfg.getChannelMute();
|
||||
m_config.m_playLoop = cfg.getPlayLoop();
|
||||
|
||||
apply();
|
||||
|
||||
qDebug() << "WFMMod::handleMessage: MsgConfigureWFMModPrivate:"
|
||||
<< " m_rfBandwidth: " << m_config.m_rfBandwidth
|
||||
<< " m_afBandwidth: " << m_config.m_afBandwidth
|
||||
<< " m_fmDeviation: " << m_config.m_fmDeviation
|
||||
<< " m_toneFrequency: " << m_config.m_toneFrequency
|
||||
<< " m_volumeFactor: " << m_config.m_volumeFactor
|
||||
<< " m_channelMute: " << m_config.m_channelMute
|
||||
<< " m_playLoop: " << m_config.m_playLoop;
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (MsgConfigureFileSourceName::match(cmd))
|
||||
{
|
||||
MsgConfigureFileSourceName& conf = (MsgConfigureFileSourceName&) cmd;
|
||||
@ -406,73 +373,6 @@ bool WFMMod::handleMessage(const Message& cmd)
|
||||
}
|
||||
}
|
||||
|
||||
void WFMMod::apply()
|
||||
{
|
||||
|
||||
if ((m_config.m_inputFrequencyOffset != m_running.m_inputFrequencyOffset) ||
|
||||
(m_config.m_outputSampleRate != m_running.m_outputSampleRate))
|
||||
{
|
||||
m_settingsMutex.lock();
|
||||
m_carrierNco.setFreq(m_config.m_inputFrequencyOffset, m_config.m_outputSampleRate);
|
||||
m_settingsMutex.unlock();
|
||||
}
|
||||
|
||||
if((m_config.m_outputSampleRate != m_running.m_outputSampleRate) ||
|
||||
(m_config.m_audioSampleRate != m_running.m_audioSampleRate) ||
|
||||
(m_config.m_afBandwidth != m_running.m_afBandwidth))
|
||||
{
|
||||
m_settingsMutex.lock();
|
||||
m_interpolatorDistanceRemain = 0;
|
||||
m_interpolatorConsumed = false;
|
||||
m_interpolatorDistance = (Real) m_config.m_audioSampleRate / (Real) m_config.m_outputSampleRate;
|
||||
m_interpolator.create(48, m_config.m_audioSampleRate, m_config.m_rfBandwidth / 2.2, 3.0);
|
||||
m_settingsMutex.unlock();
|
||||
}
|
||||
|
||||
if ((m_config.m_rfBandwidth != m_running.m_rfBandwidth) ||
|
||||
(m_config.m_outputSampleRate != m_running.m_outputSampleRate))
|
||||
{
|
||||
m_settingsMutex.lock();
|
||||
Real lowCut = -(m_config.m_rfBandwidth / 2.0) / m_config.m_outputSampleRate;
|
||||
Real hiCut = (m_config.m_rfBandwidth / 2.0) / m_config.m_outputSampleRate;
|
||||
m_rfFilter->create_filter(lowCut, hiCut);
|
||||
m_settingsMutex.unlock();
|
||||
}
|
||||
|
||||
if ((m_config.m_toneFrequency != m_running.m_toneFrequency) ||
|
||||
(m_config.m_audioSampleRate != m_running.m_audioSampleRate))
|
||||
{
|
||||
m_settingsMutex.lock();
|
||||
m_toneNco.setFreq(m_config.m_toneFrequency, m_config.m_audioSampleRate);
|
||||
m_settingsMutex.unlock();
|
||||
}
|
||||
|
||||
if ((m_config.m_toneFrequency != m_running.m_toneFrequency) ||
|
||||
(m_config.m_outputSampleRate != m_running.m_outputSampleRate))
|
||||
{
|
||||
m_settingsMutex.lock();
|
||||
m_toneNcoRF.setFreq(m_config.m_toneFrequency, m_config.m_outputSampleRate);
|
||||
m_settingsMutex.unlock();
|
||||
}
|
||||
|
||||
if (m_config.m_outputSampleRate != m_running.m_outputSampleRate)
|
||||
{
|
||||
m_cwKeyer.setSampleRate(m_config.m_outputSampleRate);
|
||||
m_cwSmoother.setNbFadeSamples(m_config.m_outputSampleRate / 250); // 4 ms
|
||||
m_cwKeyer.reset();
|
||||
}
|
||||
|
||||
m_running.m_outputSampleRate = m_config.m_outputSampleRate;
|
||||
m_running.m_inputFrequencyOffset = m_config.m_inputFrequencyOffset;
|
||||
m_running.m_rfBandwidth = m_config.m_rfBandwidth;
|
||||
m_running.m_afBandwidth = m_config.m_afBandwidth;
|
||||
m_running.m_fmDeviation = m_config.m_fmDeviation;
|
||||
m_running.m_volumeFactor = m_config.m_volumeFactor;
|
||||
m_running.m_audioSampleRate = m_config.m_audioSampleRate;
|
||||
m_running.m_channelMute = m_config.m_channelMute;
|
||||
m_running.m_playLoop = m_config.m_playLoop;
|
||||
}
|
||||
|
||||
void WFMMod::openFileStream()
|
||||
{
|
||||
if (m_ifstream.is_open()) {
|
||||
|
@ -296,38 +296,6 @@ private:
|
||||
RSRunning
|
||||
};
|
||||
|
||||
struct Config {
|
||||
int m_basebandSampleRate;
|
||||
int m_outputSampleRate;
|
||||
qint64 m_inputFrequencyOffset;
|
||||
Real m_rfBandwidth;
|
||||
Real m_afBandwidth;
|
||||
float m_fmDeviation;
|
||||
float m_toneFrequency;
|
||||
float m_volumeFactor;
|
||||
quint32 m_audioSampleRate;
|
||||
bool m_channelMute;
|
||||
bool m_playLoop;
|
||||
|
||||
Config() :
|
||||
m_basebandSampleRate(0),
|
||||
m_outputSampleRate(-1),
|
||||
m_inputFrequencyOffset(0),
|
||||
m_rfBandwidth(-1),
|
||||
m_afBandwidth(-1),
|
||||
m_fmDeviation(5000.0f),
|
||||
m_toneFrequency(1000.0f),
|
||||
m_volumeFactor(1.0f),
|
||||
m_audioSampleRate(0),
|
||||
m_channelMute(false),
|
||||
m_playLoop(false)
|
||||
{ }
|
||||
};
|
||||
|
||||
//=================================================================
|
||||
|
||||
Config m_config;
|
||||
Config m_running;
|
||||
WFMModSettings m_settings;
|
||||
|
||||
NCO m_carrierNco;
|
||||
@ -370,7 +338,6 @@ private:
|
||||
CWSmoother m_cwSmoother;
|
||||
static const int m_levelNbSamples;
|
||||
|
||||
void apply();
|
||||
void applySettings(const WFMModSettings& settings, bool force = false);
|
||||
void pullAF(Complex& sample);
|
||||
void calculateLevel(const Real& sample);
|
||||
|
@ -35,11 +35,6 @@
|
||||
|
||||
const QString WFMModGUI::m_channelID = "sdrangel.channeltx.modwfm";
|
||||
|
||||
const int WFMModGUI::m_rfBW[] = {
|
||||
12500, 25000, 40000, 60000, 75000, 80000, 100000, 125000, 140000, 160000, 180000, 200000, 220000, 250000
|
||||
};
|
||||
const int WFMModGUI::m_nbRfBW = 14;
|
||||
|
||||
WFMModGUI* WFMModGUI::create(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI)
|
||||
{
|
||||
WFMModGUI* gui = new WFMModGUI(pluginAPI, deviceAPI);
|
||||
@ -75,33 +70,11 @@ void WFMModGUI::resetToDefaults()
|
||||
m_settings.resetToDefaults();
|
||||
displaySettings();
|
||||
applySettings(true);
|
||||
|
||||
// blockApplySettings(true);
|
||||
//
|
||||
// ui->rfBW->setCurrentIndex(7);
|
||||
// ui->afBW->setValue(8);
|
||||
// ui->fmDev->setValue(50);
|
||||
// ui->toneFrequency->setValue(100);
|
||||
// ui->volume->setValue(10);
|
||||
// ui->deltaFrequency->setValue(0);
|
||||
//
|
||||
// blockApplySettings(false);
|
||||
// applySettings();
|
||||
}
|
||||
|
||||
QByteArray WFMModGUI::serialize() const
|
||||
{
|
||||
return m_settings.serialize();
|
||||
// SimpleSerializer s(1);
|
||||
// s.writeS32(1, m_channelMarker.getCenterFrequency());
|
||||
// s.writeS32(2, ui->rfBW->currentIndex());
|
||||
// s.writeS32(3, ui->afBW->value());
|
||||
// s.writeS32(4, ui->fmDev->value());
|
||||
// s.writeU32(5, m_channelMarker.getColor().rgb());
|
||||
// s.writeS32(6, ui->toneFrequency->value());
|
||||
// s.writeS32(7, ui->volume->value());
|
||||
// s.writeBlob(8, ui->cwKeyerGUI->serialize());
|
||||
// return s.final();
|
||||
}
|
||||
|
||||
bool WFMModGUI::deserialize(const QByteArray& data)
|
||||
@ -114,56 +87,6 @@ bool WFMModGUI::deserialize(const QByteArray& data)
|
||||
resetToDefaults();
|
||||
return false;
|
||||
}
|
||||
|
||||
// SimpleDeserializer d(data);
|
||||
//
|
||||
// if(!d.isValid())
|
||||
// {
|
||||
// resetToDefaults();
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// if(d.getVersion() == 1)
|
||||
// {
|
||||
// QByteArray bytetmp;
|
||||
// quint32 u32tmp;
|
||||
// qint32 tmp;
|
||||
//
|
||||
// blockApplySettings(true);
|
||||
// m_channelMarker.blockSignals(true);
|
||||
//
|
||||
// d.readS32(1, &tmp, 0);
|
||||
// m_channelMarker.setCenterFrequency(tmp);
|
||||
// d.readS32(2, &tmp, 7);
|
||||
// ui->rfBW->setCurrentIndex(tmp);
|
||||
// d.readS32(3, &tmp, 3);
|
||||
// ui->afBW->setValue(tmp);
|
||||
// d.readS32(4, &tmp, 50);
|
||||
// ui->fmDev->setValue(tmp);
|
||||
//
|
||||
// if(d.readU32(5, &u32tmp))
|
||||
// {
|
||||
// m_channelMarker.setColor(u32tmp);
|
||||
// }
|
||||
//
|
||||
// d.readS32(6, &tmp, 100);
|
||||
// ui->toneFrequency->setValue(tmp);
|
||||
// d.readS32(7, &tmp, 10);
|
||||
// ui->volume->setValue(tmp);
|
||||
// d.readBlob(8, &bytetmp);
|
||||
// ui->cwKeyerGUI->deserialize(bytetmp);
|
||||
//
|
||||
// blockApplySettings(false);
|
||||
// m_channelMarker.blockSignals(false);
|
||||
//
|
||||
// applySettings();
|
||||
// return true;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// resetToDefaults();
|
||||
// return false;
|
||||
// }
|
||||
}
|
||||
|
||||
bool WFMModGUI::handleMessage(const Message& message)
|
||||
@ -370,13 +293,14 @@ WFMModGUI::WFMModGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget* pa
|
||||
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
|
||||
blockApplySettings(true);
|
||||
|
||||
ui->rfBW->clear();
|
||||
for (int i = 0; i < m_nbRfBW; i++) {
|
||||
ui->rfBW->addItem(QString("%1").arg(m_rfBW[i] / 1000.0, 0, 'f', 2));
|
||||
for (int i = 0; i < WFMModSettings::m_nbRfBW; i++) {
|
||||
ui->rfBW->addItem(QString("%1").arg(WFMModSettings::getRFBW(i) / 1000.0, 0, 'f', 2));
|
||||
}
|
||||
ui->rfBW->setCurrentIndex(7);
|
||||
blockApplySettings(false);
|
||||
|
||||
blockApplySettings(false);
|
||||
|
||||
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
|
||||
connect(this, SIGNAL(menuDoubleClickEvent()), this, SLOT(onMenuDoubleClicked()));
|
||||
@ -395,10 +319,13 @@ WFMModGUI::WFMModGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget* pa
|
||||
ui->deltaFrequency->setValueRange(false, 7, -9999999, 9999999);
|
||||
|
||||
//m_channelMarker = new ChannelMarker(this);
|
||||
m_channelMarker.setColor(Qt::blue);
|
||||
m_channelMarker.setBandwidth(m_rfBW[ui->rfBW->currentIndex()]);
|
||||
m_channelMarker.setCenterFrequency(0);
|
||||
m_channelMarker.setVisible(true);
|
||||
// m_channelMarker.setColor(Qt::blue);
|
||||
// m_channelMarker.setBandwidth(m_rfBW[ui->rfBW->currentIndex()]);
|
||||
// m_channelMarker.setCenterFrequency(0);
|
||||
// m_channelMarker.setVisible(true);
|
||||
|
||||
m_channelMarker.setTitle("WFM Modulator");
|
||||
m_channelMarker.setVisible(true);
|
||||
|
||||
connect(&m_channelMarker, SIGNAL(changed()), this, SLOT(viewChanged()));
|
||||
|
||||
@ -446,31 +373,13 @@ void WFMModGUI::applySettings(bool force)
|
||||
setTitleColor(m_channelMarker.getColor());
|
||||
|
||||
m_channelizer->configure(m_channelizer->getInputMessageQueue(),
|
||||
requiredBW(m_rfBW[ui->rfBW->currentIndex()]),
|
||||
m_channelMarker.getCenterFrequency());
|
||||
requiredBW(WFMModSettings::getRFBW(ui->rfBW->currentIndex())),
|
||||
m_channelMarker.getCenterFrequency());
|
||||
|
||||
ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency());
|
||||
|
||||
WFMMod::MsgConfigureWFMMod *msgConf = WFMMod::MsgConfigureWFMMod::create(m_settings, force);
|
||||
m_wfmMod->getInputMessageQueue()->push(msgConf);
|
||||
|
||||
// m_wfmMod->configure(m_wfmMod->getInputMessageQueue(),
|
||||
// m_settings.m_rfBandwidth,
|
||||
// m_settings.m_afBandwidth,
|
||||
// m_settings.m_fmDeviation,
|
||||
// m_settings.m_toneFrequency,
|
||||
// m_settings.m_volumeFactor,
|
||||
// m_settings.m_channelMute,
|
||||
// m_settings.m_playLoop);
|
||||
|
||||
// m_wfmMod->configure(m_wfmMod->getInputMessageQueue(),
|
||||
// m_rfBW[ui->rfBW->currentIndex()],
|
||||
// ui->afBW->value() * 1000.0,
|
||||
// ui->fmDev->value() * 1000.0f, // value is in '100 Hz
|
||||
// ui->toneFrequency->value() * 10.0f,
|
||||
// ui->volume->value() / 10.0f,
|
||||
// ui->channelMute->isChecked(),
|
||||
// ui->playLoop->isChecked());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,9 +106,6 @@ private:
|
||||
WFMMod::WFMModInputAF m_modAFInput;
|
||||
MessageQueue m_inputMessageQueue;
|
||||
|
||||
static const int m_rfBW[];
|
||||
static const int m_nbRfBW;
|
||||
|
||||
explicit WFMModGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget* parent = NULL);
|
||||
virtual ~WFMModGUI();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user