mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-12-23 18:15:45 -05:00
DSD demod: allow to set baud rate (2400 or 4800 not 9600 for now)
This commit is contained in:
parent
5ca0c95dc5
commit
25b06d06d3
@ -29,8 +29,33 @@ DSDDecoder::DSDDecoder()
|
||||
m_decoder.setUvQuality(3); // This is gr-dsd default
|
||||
m_decoder.setModulationOptimizations(DSDcc::DSDDecoder::DSDModulationOptimAuto); // Initialize with auto detection of modulation optimization:
|
||||
m_decoder.enableCosineFiltering(false);
|
||||
m_decoder.setDataRate(DSDcc::DSDDecoder::DSDRate4800);
|
||||
}
|
||||
|
||||
DSDDecoder::~DSDDecoder()
|
||||
{
|
||||
}
|
||||
|
||||
void DSDDecoder::setBaudRate(int baudRate)
|
||||
{
|
||||
if (baudRate == 2400)
|
||||
{
|
||||
m_decoder.setDataRate(DSDcc::DSDDecoder::DSDRate2400);
|
||||
}
|
||||
else if (baudRate == 4800)
|
||||
{
|
||||
m_decoder.setDataRate(DSDcc::DSDDecoder::DSDRate4800);
|
||||
}
|
||||
else if (baudRate == 9600)
|
||||
{
|
||||
m_decoder.setDataRate(DSDcc::DSDDecoder::DSDRate9600);
|
||||
}
|
||||
else // default 4800 bauds
|
||||
{
|
||||
m_decoder.setDataRate(DSDcc::DSDDecoder::DSDRate4800);
|
||||
}
|
||||
|
||||
// when setting baud rate activate detection of all possible modes for this rate
|
||||
// because on the other hand when a mode is selected then the baud rate is automatically changed
|
||||
m_decoder.setDecodeMode(DSDcc::DSDDecoder::DSDDecodeAuto, true);
|
||||
}
|
||||
|
@ -50,6 +50,7 @@ public:
|
||||
const DSDcc::DSDDstar& getDStarDecoder() const { return m_decoder.getDStarDecoder(); }
|
||||
|
||||
void setAudioGain(float gain) { m_decoder.setAudioGain(gain); }
|
||||
void setBaudRate(int baudRate);
|
||||
|
||||
private:
|
||||
DSDcc::DSDDecoder m_decoder;
|
||||
|
@ -51,6 +51,7 @@ DSDDemod::DSDDemod(SampleSink* sampleSink) :
|
||||
m_config.m_squelchGate = 5; // 10s of ms at 48000 Hz sample rate. Corresponds to 2400 for AGC attack
|
||||
m_config.m_squelch = -30.0;
|
||||
m_config.m_volume = 1.0;
|
||||
m_config.m_baudRate = 4800;
|
||||
m_config.m_audioMute = false;
|
||||
m_config.m_audioSampleRate = DSPEngine::instance()->getAudioSampleRate();
|
||||
|
||||
@ -78,6 +79,7 @@ void DSDDemod::configure(MessageQueue* messageQueue,
|
||||
int demodGain,
|
||||
int fmDeviation,
|
||||
int volume,
|
||||
int baudRate,
|
||||
int squelchGate,
|
||||
Real squelch,
|
||||
bool audioMute)
|
||||
@ -86,6 +88,7 @@ void DSDDemod::configure(MessageQueue* messageQueue,
|
||||
demodGain,
|
||||
fmDeviation,
|
||||
volume,
|
||||
baudRate,
|
||||
squelchGate,
|
||||
squelch,
|
||||
audioMute);
|
||||
@ -239,6 +242,7 @@ bool DSDDemod::handleMessage(const Message& cmd)
|
||||
m_config.m_demodGain = cfg.getDemodGain();
|
||||
m_config.m_fmDeviation = cfg.getFMDeviation();
|
||||
m_config.m_volume = cfg.getVolume();
|
||||
m_config.m_baudRate = cfg.getBaudRate();
|
||||
m_config.m_squelchGate = cfg.getSquelchGate();
|
||||
m_config.m_squelch = cfg.getSquelch();
|
||||
m_config.m_audioMute = cfg.getAudioMute();
|
||||
@ -249,6 +253,7 @@ bool DSDDemod::handleMessage(const Message& cmd)
|
||||
<< " m_demodGain: " << m_config.m_demodGain / 100.0
|
||||
<< " m_fmDeviation: " << m_config.m_fmDeviation * 100
|
||||
<< " m_volume: " << m_config.m_volume / 10.0
|
||||
<< " m_baudRate: " << m_config.m_baudRate
|
||||
<< " m_squelchGate" << m_config.m_squelchGate
|
||||
<< " m_squelch: " << m_config.m_squelch
|
||||
<< " m_audioMute: " << m_config.m_audioMute;
|
||||
@ -303,7 +308,12 @@ void DSDDemod::apply()
|
||||
m_dsdDecoder.setAudioGain(m_config.m_volume / 10.0f);
|
||||
}
|
||||
|
||||
m_running.m_inputSampleRate = m_config.m_inputSampleRate;
|
||||
if (m_config.m_baudRate != m_running.m_baudRate)
|
||||
{
|
||||
m_dsdDecoder.setBaudRate(m_config.m_baudRate);
|
||||
}
|
||||
|
||||
m_running.m_inputSampleRate = m_config.m_inputSampleRate;
|
||||
m_running.m_inputFrequencyOffset = m_config.m_inputFrequencyOffset;
|
||||
m_running.m_rfBandwidth = m_config.m_rfBandwidth;
|
||||
m_running.m_demodGain = m_config.m_demodGain;
|
||||
@ -311,6 +321,7 @@ void DSDDemod::apply()
|
||||
m_running.m_squelchGate = m_config.m_squelchGate;
|
||||
m_running.m_squelch = m_config.m_squelch;
|
||||
m_running.m_volume = m_config.m_volume;
|
||||
m_running.m_baudRate = m_config.m_baudRate;
|
||||
m_running.m_audioSampleRate = m_config.m_audioSampleRate;
|
||||
m_running.m_audioMute = m_config.m_audioMute;
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ public:
|
||||
int rfBandwidth,
|
||||
int demodGain,
|
||||
int volume,
|
||||
int baudRate,
|
||||
int fmDeviation,
|
||||
int squelchGate,
|
||||
Real squelch,
|
||||
@ -72,6 +73,7 @@ private:
|
||||
int getDemodGain() const { return m_demodGain; }
|
||||
int getFMDeviation() const { return m_fmDeviation; }
|
||||
int getVolume() const { return m_volume; }
|
||||
int getBaudRate() const { return m_baudRate; }
|
||||
int getSquelchGate() const { return m_squelchGate; }
|
||||
Real getSquelch() const { return m_squelch; }
|
||||
bool getAudioMute() const { return m_audioMute; }
|
||||
@ -80,11 +82,12 @@ private:
|
||||
int demodGain,
|
||||
int fmDeviation,
|
||||
int volume,
|
||||
int baudRate,
|
||||
int squelchGate,
|
||||
Real squelch,
|
||||
bool audioMute)
|
||||
{
|
||||
return new MsgConfigureDSDDemod(rfBandwidth, demodGain, fmDeviation, volume, squelchGate, squelch, audioMute);
|
||||
return new MsgConfigureDSDDemod(rfBandwidth, demodGain, fmDeviation, volume, baudRate, squelchGate, squelch, audioMute);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -92,6 +95,7 @@ private:
|
||||
Real m_demodGain;
|
||||
int m_fmDeviation;
|
||||
int m_volume;
|
||||
int m_baudRate;
|
||||
int m_squelchGate;
|
||||
Real m_squelch;
|
||||
bool m_audioMute;
|
||||
@ -100,6 +104,7 @@ private:
|
||||
int demodGain,
|
||||
int fmDeviation,
|
||||
int volume,
|
||||
int baudRate,
|
||||
int squelchGate,
|
||||
Real squelch,
|
||||
bool audioMute) :
|
||||
@ -108,6 +113,7 @@ private:
|
||||
m_demodGain(demodGain),
|
||||
m_fmDeviation(fmDeviation),
|
||||
m_volume(volume),
|
||||
m_baudRate(baudRate),
|
||||
m_squelchGate(squelchGate),
|
||||
m_squelch(squelch),
|
||||
m_audioMute(audioMute)
|
||||
@ -131,6 +137,7 @@ private:
|
||||
int m_rfBandwidth;
|
||||
int m_demodGain;
|
||||
int m_volume;
|
||||
int m_baudRate;
|
||||
int m_fmDeviation;
|
||||
int m_squelchGate;
|
||||
Real m_squelch;
|
||||
@ -143,6 +150,7 @@ private:
|
||||
m_rfBandwidth(-1),
|
||||
m_demodGain(-1),
|
||||
m_volume(-1),
|
||||
m_baudRate(4800),
|
||||
m_fmDeviation(1),
|
||||
m_squelchGate(1),
|
||||
m_squelch(0),
|
||||
|
@ -36,6 +36,11 @@
|
||||
|
||||
const QString DSDDemodGUI::m_channelID = "sdrangel.channel.dsddemod";
|
||||
|
||||
unsigned int DSDDemodBaudRates::m_rates[] = {2400, 4800};
|
||||
unsigned int DSDDemodBaudRates::m_nb_rates = 2;
|
||||
unsigned int DSDDemodBaudRates::m_defaultRateIndex = 1; // 4800 bauds
|
||||
|
||||
|
||||
DSDDemodGUI* DSDDemodGUI::create(PluginAPI* pluginAPI, DeviceAPI *deviceAPI)
|
||||
{
|
||||
DSDDemodGUI* gui = new DSDDemodGUI(pluginAPI, deviceAPI);
|
||||
@ -76,6 +81,7 @@ void DSDDemodGUI::resetToDefaults()
|
||||
ui->demodGain->setValue(100); // 100ths
|
||||
ui->fmDeviation->setValue(50); // x100 Hz
|
||||
ui->volume->setValue(20); // /10.0
|
||||
ui->baudRate->setCurrentIndex(DSDDemodBaudRates::getDefaultRateIndex());
|
||||
ui->squelchGate->setValue(5);
|
||||
ui->squelch->setValue(-40);
|
||||
ui->deltaFrequency->setValue(0);
|
||||
@ -96,6 +102,7 @@ QByteArray DSDDemodGUI::serialize() const
|
||||
s.writeS32(8, ui->squelchGate->value());
|
||||
s.writeS32(9, ui->volume->value());
|
||||
s.writeBlob(10, ui->scopeGUI->serialize());
|
||||
s.writeS32(11, ui->baudRate->currentIndex());
|
||||
return s.final();
|
||||
}
|
||||
|
||||
@ -141,6 +148,8 @@ bool DSDDemodGUI::deserialize(const QByteArray& data)
|
||||
ui->volume->setValue(tmp);
|
||||
d.readBlob(10, &bytetmp);
|
||||
ui->scopeGUI->deserialize(bytetmp);
|
||||
d.readS32(11, &tmp, 20);
|
||||
ui->baudRate->setCurrentIndex(tmp);
|
||||
|
||||
blockApplySettings(false);
|
||||
m_channelMarker.blockSignals(false);
|
||||
@ -210,6 +219,10 @@ void DSDDemodGUI::on_volume_valueChanged(int value)
|
||||
applySettings();
|
||||
}
|
||||
|
||||
void DSDDemodGUI::on_baudRate_currentIndexChanged(int index)
|
||||
{
|
||||
applySettings();
|
||||
}
|
||||
|
||||
void DSDDemodGUI::on_squelchGate_valueChanged(int value)
|
||||
{
|
||||
@ -335,6 +348,7 @@ void DSDDemodGUI::applySettings()
|
||||
ui->demodGain->value(),
|
||||
ui->fmDeviation->value(),
|
||||
ui->volume->value(),
|
||||
DSDDemodBaudRates::getRate(ui->baudRate->currentIndex()),
|
||||
ui->squelchGate->value(), // in 10ths of ms
|
||||
ui->squelch->value(),
|
||||
ui->audioMute->isChecked());
|
||||
@ -476,3 +490,28 @@ void DSDDemodGUI::tick()
|
||||
m_tickCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int DSDDemodBaudRates::getRate(unsigned int rate_index)
|
||||
{
|
||||
if (rate_index < m_nb_rates)
|
||||
{
|
||||
return m_rates[rate_index];
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_rates[m_defaultRateIndex];
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int DSDDemodBaudRates::getRateIndex(unsigned int rate)
|
||||
{
|
||||
for (unsigned int i=0; i < m_nb_rates; i++)
|
||||
{
|
||||
if (rate == m_rates[i])
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return m_defaultRateIndex;
|
||||
}
|
||||
|
@ -64,6 +64,7 @@ private slots:
|
||||
void on_rfBW_valueChanged(int index);
|
||||
void on_demodGain_valueChanged(int value);
|
||||
void on_volume_valueChanged(int value);
|
||||
void on_baudRate_currentIndexChanged(int index);
|
||||
void on_fmDeviation_valueChanged(int value);
|
||||
void on_squelchGate_valueChanged(int value);
|
||||
void on_squelch_valueChanged(int value);
|
||||
@ -109,4 +110,18 @@ private:
|
||||
void enterEvent(QEvent*);
|
||||
};
|
||||
|
||||
class DSDDemodBaudRates
|
||||
{
|
||||
public:
|
||||
static unsigned int getRate(unsigned int rate_index);
|
||||
static unsigned int getRateIndex(unsigned int rate);
|
||||
static unsigned int getDefaultRate() { return m_rates[m_defaultRateIndex]; }
|
||||
static unsigned int getDefaultRateIndex() { return m_defaultRateIndex; }
|
||||
static unsigned int getNbRates();
|
||||
private:
|
||||
static unsigned int m_nb_rates;
|
||||
static unsigned int m_rates[2];
|
||||
static unsigned int m_defaultRateIndex;
|
||||
};
|
||||
|
||||
#endif // INCLUDE_DSDDEMODGUI_H
|
||||
|
@ -137,9 +137,15 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="baudRate">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>55</width>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
|
Loading…
Reference in New Issue
Block a user