diff --git a/plugins/channel/ssb/ssbdemod.cpp b/plugins/channel/ssb/ssbdemod.cpp index b40bf5a51..1af3069f2 100644 --- a/plugins/channel/ssb/ssbdemod.cpp +++ b/plugins/channel/ssb/ssbdemod.cpp @@ -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(); diff --git a/plugins/channel/ssb/ssbdemodgui.cpp b/plugins/channel/ssb/ssbdemodgui.cpp index f82291702..3fac4c794 100644 --- a/plugins/channel/ssb/ssbdemodgui.cpp +++ b/plugins/channel/ssb/ssbdemodgui.cpp @@ -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; }