1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-19 06:41:47 -05:00

SSB demod: re-implemented fixed DSB option

This commit is contained in:
f4exb 2015-12-26 04:50:29 +01:00
parent 2b98bc9d8a
commit 0613100bbd
2 changed files with 80 additions and 11 deletions

View File

@ -101,7 +101,15 @@ void SSBDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
if(m_interpolator.interpolate(&m_sampleDistanceRemain, c, &ci))
{
n_out = SSBFilter->runSSB(ci, &sideband, m_usb);
if (m_dsb)
{
n_out = DSBFilter->runDSB(ci, &sideband);
}
else
{
n_out = SSBFilter->runSSB(ci, &sideband, m_usb);
}
m_sampleDistanceRemain += (Real)m_sampleRate / m_audioSampleRate;
}
else
@ -121,9 +129,16 @@ void SSBDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
Real avgr = m_sum.real() / decim;
Real avgi = m_sum.imag() / decim;
m_magsq = (avgr * avgr + avgi * avgi) / (1<<30);
//avg = (sum.real() + sum.imag()) * 0.7 * 32768.0 / decim;
avg = (avgr + avgi) * 0.7;
m_sampleBuffer.push_back(Sample(avg, 0.0));
if (!m_dsb & !m_usb)
{ // invert spectrum for LSB
m_sampleBuffer.push_back(Sample(avgi, avgr));
}
else
{
m_sampleBuffer.push_back(Sample(avgr, avgi));
}
m_sum.real() = 0.0;
m_sum.imag() = 0.0;
}
@ -171,9 +186,9 @@ void SSBDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
}
m_audioBufferFill = 0;
if(m_sampleSink != 0)
if (m_sampleSink != 0)
{
m_sampleSink->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), true);
m_sampleSink->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), !m_dsb);
}
m_sampleBuffer.clear();

View File

@ -167,7 +167,32 @@ void SSBDemodGUI::on_audioFlipChannels_toggled(bool flip)
void SSBDemodGUI::on_dsb_toggled(bool dsb)
{
m_dsb = dsb;
if (!m_dsb)
{
if (ui->BW->value() < 0) {
m_channelMarker.setSidebands(ChannelMarker::lsb);
} else {
m_channelMarker.setSidebands(ChannelMarker::usb);
}
ui->glSpectrum->setCenterFrequency(m_rate/4);
ui->glSpectrum->setSampleRate(m_rate/2);
ui->glSpectrum->setSsbSpectrum(true);
on_lowCut_valueChanged(m_channelMarker.getLowCutoff()/100);
}
else
{
m_channelMarker.setSidebands(ChannelMarker::dsb);
ui->glSpectrum->setCenterFrequency(0);
ui->glSpectrum->setSampleRate(m_rate);
ui->glSpectrum->setSsbSpectrum(false);
}
applySettings();
setNewRate(m_spanLog2);
}
void SSBDemodGUI::on_deltaFrequency_changed(quint64 value)
@ -188,15 +213,23 @@ void SSBDemodGUI::on_BW_valueChanged(int value)
ui->BWText->setText(tr("%1k").arg(s));
m_channelMarker.setBandwidth(value * 100 * 2);
if (value < 0)
if (!m_dsb)
{
m_channelMarker.setSidebands(ChannelMarker::lsb);
if (value < 0)
{
m_channelMarker.setSidebands(ChannelMarker::lsb);
}
else
{
m_channelMarker.setSidebands(ChannelMarker::usb);
}
}
else
{
m_channelMarker.setSidebands(ChannelMarker::usb);
m_channelMarker.setSidebands(ChannelMarker::dsb);
}
on_lowCut_valueChanged(m_channelMarker.getLowCutoff()/100);
}
@ -323,6 +356,7 @@ SSBDemodGUI::SSBDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
ui->spectrumGUI->setBuddies(m_spectrumVis->getInputMessageQueue(), m_spectrumVis, ui->glSpectrum);
applySettings();
setNewRate(m_spanLog2);
}
SSBDemodGUI::~SSBDemodGUI()
@ -377,8 +411,28 @@ bool SSBDemodGUI::setNewRate(int spanLog2)
QString s = QString::number(m_rate/1000.0, 'f', 1);
ui->spanText->setText(tr("%1k").arg(s));
ui->glSpectrum->setCenterFrequency(m_rate/2);
ui->glSpectrum->setSampleRate(m_rate);
//ui->glSpectrum->setCenterFrequency(m_rate/2);
//ui->glSpectrum->setSampleRate(m_rate);
if (!m_dsb)
{
if (ui->BW->value() < 0) {
m_channelMarker.setSidebands(ChannelMarker::lsb);
} else {
m_channelMarker.setSidebands(ChannelMarker::usb);
}
ui->glSpectrum->setCenterFrequency(m_rate/2);
ui->glSpectrum->setSampleRate(m_rate);
ui->glSpectrum->setSsbSpectrum(true);
}
else
{
m_channelMarker.setSidebands(ChannelMarker::dsb);
ui->glSpectrum->setCenterFrequency(0);
ui->glSpectrum->setSampleRate(2*m_rate);
ui->glSpectrum->setSsbSpectrum(false);
}
return true;
}