1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-23 10:05:46 -05:00

Revert "SSB demod: implemented DSB option"

This reverts commit 5e0e3a01e1.
This commit is contained in:
f4exb 2015-12-26 03:23:18 +01:00
parent 111f00b230
commit 4de446053d
4 changed files with 98 additions and 152 deletions

View File

@ -50,20 +50,20 @@ SSBDemod::SSBDemod(SampleSink* sampleSink) :
m_audioBuffer.resize(1<<9);
m_audioBufferFill = 0;
m_undersampleCount = 0;
m_sum = 0;
m_usb = true;
m_magsq = 0.0f;
SSBFilter = new fftfilt(m_LowCutoff / m_audioSampleRate, m_Bandwidth / m_audioSampleRate, ssbFftLen);
DSBFilter = new fftfilt((2*m_Bandwidth) / m_sampleRate, 2*ssbFftLen);
DSPEngine::instance()->addAudioSink(&m_audioFifo);
}
SSBDemod::~SSBDemod()
{
if (SSBFilter) delete SSBFilter;
if (DSBFilter) delete DSBFilter;
if (SSBFilter)
{
delete SSBFilter;
}
DSPEngine::instance()->removeAudioSink(&m_audioFifo);
}
@ -84,7 +84,7 @@ void SSBDemod::configure(MessageQueue* messageQueue,
void SSBDemod::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly)
{
Complex ci;
fftfilt::cmplx *sideband;
fftfilt::cmplx *sideband, sum;
Real avg;
int n_out;
@ -101,81 +101,68 @@ void SSBDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
if(m_interpolator.interpolate(&m_sampleDistanceRemain, c, &ci))
{
if (m_dsb)
{
n_out = DSBFilter->runDSB(ci, &sideband);
}
else
{
n_out = SSBFilter->runSSB(ci, &sideband, m_usb);
}
for (int i = 0; i < n_out; i++)
{
// Downsample by 2^(m_scaleLog2 - 1) for SSB band spectrum display
// smart decimation with bit gain using float arithmetic (23 bits significand)
m_sum += sideband[i];
if (!(m_undersampleCount++ & decim_mask))
{
m_sum /= decim;
m_magsq = (m_sum.real() * m_sum.real() + m_sum.imag() * m_sum.imag())/ (1<<30);
if (!m_dsb & !m_usb)
{ // invert spectrum for LSB
m_sampleBuffer.push_back(Sample(m_sum.imag(), m_sum.real()));
}
else
{
m_sampleBuffer.push_back(Sample(m_sum.real(), m_sum.imag()));
}
m_sum = 0;
}
if (m_audioBinaual)
{
if (m_audioFlipChannels)
{
m_audioBuffer[m_audioBufferFill].r = (qint16)(sideband[i].imag() * m_volume * 100);
m_audioBuffer[m_audioBufferFill].l = (qint16)(sideband[i].real() * m_volume * 100);
}
else
{
m_audioBuffer[m_audioBufferFill].r = (qint16)(sideband[i].real() * m_volume * 100);
m_audioBuffer[m_audioBufferFill].l = (qint16)(sideband[i].imag() * m_volume * 100);
}
}
else
{
Real demod = (sideband[i].real() + sideband[i].imag()) * 0.7;
qint16 sample = (qint16)(demod * m_volume * 100);
m_audioBuffer[m_audioBufferFill].l = sample;
m_audioBuffer[m_audioBufferFill].r = sample;
}
++m_audioBufferFill;
if (m_audioBufferFill >= m_audioBuffer.size())
{
uint res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], m_audioBufferFill, 1);
if (res != m_audioBufferFill)
{
qDebug("lost %u samples", m_audioBufferFill - res);
}
m_audioBufferFill = 0;
}
}
n_out = SSBFilter->runSSB(ci, &sideband, m_usb);
m_sampleDistanceRemain += (Real)m_sampleRate / m_audioSampleRate;
}
else
{
n_out = 0;
}
for (int i = 0; i < n_out; i++)
{
// Downsample by 2^(m_scaleLog2 - 1) for SSB band spectrum display
// smart decimation with bit gain using float arithmetic (23 bits significand)
sum += sideband[i];
if (!(m_undersampleCount++ & decim_mask))
{
Real avgr = sum.real() / decim;
Real avgi = 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));
sum.real() = 0.0;
sum.imag() = 0.0;
}
if (m_audioBinaual)
{
if (m_audioFlipChannels)
{
m_audioBuffer[m_audioBufferFill].r = (qint16)(sideband[i].imag() * m_volume * 100);
m_audioBuffer[m_audioBufferFill].l = (qint16)(sideband[i].real() * m_volume * 100);
}
else
{
m_audioBuffer[m_audioBufferFill].r = (qint16)(sideband[i].real() * m_volume * 100);
m_audioBuffer[m_audioBufferFill].l = (qint16)(sideband[i].imag() * m_volume * 100);
}
}
else
{
Real demod = (sideband[i].real() + sideband[i].imag()) * 0.7;
qint16 sample = (qint16)(demod * m_volume * 100);
m_audioBuffer[m_audioBufferFill].l = sample;
m_audioBuffer[m_audioBufferFill].r = sample;
}
++m_audioBufferFill;
if (m_audioBufferFill >= m_audioBuffer.size())
{
uint res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], m_audioBufferFill, 1);
if (res != m_audioBufferFill)
{
qDebug("lost %u samples", m_audioBufferFill - res);
}
m_audioBufferFill = 0;
}
}
}
if (m_audioFifo.write((const quint8*)&m_audioBuffer[0], m_audioBufferFill, 0) != m_audioBufferFill)
@ -186,7 +173,7 @@ void SSBDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
if(m_sampleSink != 0)
{
m_sampleSink->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), !m_dsb);
m_sampleSink->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), true);
}
m_sampleBuffer.clear();
@ -252,7 +239,6 @@ bool SSBDemod::handleMessage(const Message& cmd)
m_interpolator.create(16, m_sampleRate, band * 2.0f);
SSBFilter->create_filter(m_LowCutoff / (float) m_audioSampleRate, m_Bandwidth / (float) m_audioSampleRate);
DSBFilter->create_dsb_filter((2*m_Bandwidth) / m_sampleRate);
m_volume = cfg.getVolume();
m_volume *= m_volume * 0.1;

View File

@ -43,7 +43,6 @@ public:
bool audioFlipChannels,
bool dsb);
int getSampleRate() const { return m_sampleRate; }
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly);
virtual void start();
virtual void stop();
@ -113,7 +112,6 @@ private:
Real m_LowCutoff;
Real m_volume;
int m_spanLog2;
fftfilt::cmplx m_sum;
int m_undersampleCount;
int m_sampleRate;
int m_frequency;
@ -127,7 +125,6 @@ private:
Interpolator m_interpolator;
Real m_sampleDistanceRemain;
fftfilt* SSBFilter;
fftfilt* DSBFilter;
SampleSink* m_sampleSink;
SampleVector m_sampleBuffer;

View File

@ -167,31 +167,7 @@ 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();
}
applySettings();
}
void SSBDemodGUI::on_deltaFrequency_changed(quint64 value)
@ -212,17 +188,13 @@ void SSBDemodGUI::on_BW_valueChanged(int value)
ui->BWText->setText(tr("%1k").arg(s));
m_channelMarker.setBandwidth(value * 100 * 2);
if (!m_dsb)
if (value < 0)
{
if (value < 0) {
m_channelMarker.setSidebands(ChannelMarker::lsb);
} else {
m_channelMarker.setSidebands(ChannelMarker::usb);
}
m_channelMarker.setSidebands(ChannelMarker::lsb);
}
else
{
m_channelMarker.setSidebands(ChannelMarker::dsb);
m_channelMarker.setSidebands(ChannelMarker::usb);
}
on_lowCut_valueChanged(m_channelMarker.getLowCutoff()/100);
@ -234,18 +206,25 @@ int SSBDemodGUI::getEffectiveLowCutoff(int lowCutoff)
int effectiveLowCutoff = lowCutoff;
const int guard = 100;
if (ssbBW < 0) {
if (effectiveLowCutoff < ssbBW + guard) {
if (ssbBW < 0)
{
if (effectiveLowCutoff < ssbBW + guard)
{
effectiveLowCutoff = ssbBW + guard;
}
if (effectiveLowCutoff > 0) {
if (effectiveLowCutoff > 0)
{
effectiveLowCutoff = 0;
}
} else {
if (effectiveLowCutoff > ssbBW - guard) {
}
else
{
if (effectiveLowCutoff > ssbBW - guard)
{
effectiveLowCutoff = ssbBW - guard;
}
if (effectiveLowCutoff < 0) {
if (effectiveLowCutoff < 0)
{
effectiveLowCutoff = 0;
}
}
@ -344,7 +323,6 @@ SSBDemodGUI::SSBDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
ui->spectrumGUI->setBuddies(m_spectrumVis->getInputMessageQueue(), m_spectrumVis, ui->glSpectrum);
applySettings();
setNewRate(m_spanLog2);
}
SSBDemodGUI::~SSBDemodGUI()
@ -361,27 +339,33 @@ SSBDemodGUI::~SSBDemodGUI()
bool SSBDemodGUI::setNewRate(int spanLog2)
{
if ((spanLog2 < 0) || (spanLog2 > 6)) {
if ((spanLog2 < 1) || (spanLog2 > 5))
{
return false;
}
m_spanLog2 = spanLog2;
//m_rate = 48000 / (1<<spanLog2);
m_rate = m_ssbDemod->getSampleRate() / (1<<spanLog2);
m_rate = 48000 / (1<<spanLog2);
if (ui->BW->value() < -m_rate/200) {
ui->BW->setValue(-m_rate/200);
if (ui->BW->value() < -m_rate/100)
{
ui->BW->setValue(-m_rate/100);
m_channelMarker.setBandwidth(-m_rate*2);
} else if (ui->BW->value() > m_rate/200) {
ui->BW->setValue(m_rate/200);
}
else if (ui->BW->value() > m_rate/100)
{
ui->BW->setValue(m_rate/100);
m_channelMarker.setBandwidth(m_rate*2);
}
if (ui->lowCut->value() < -m_rate/200) {
ui->lowCut->setValue(-m_rate/200);
if (ui->lowCut->value() < -m_rate/100)
{
ui->lowCut->setValue(-m_rate/100);
m_channelMarker.setLowCutoff(-m_rate);
} else if (ui->lowCut->value() > m_rate/200) {
ui->lowCut->setValue(m_rate/200);
}
else if (ui->lowCut->value() > m_rate/100)
{
ui->lowCut->setValue(m_rate/100);
m_channelMarker.setLowCutoff(m_rate);
}
@ -393,26 +377,8 @@ bool SSBDemodGUI::setNewRate(int spanLog2)
QString s = QString::number(m_rate/1000.0, 'f', 1);
ui->spanText->setText(tr("%1k").arg(s));
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);
}
else
{
m_channelMarker.setSidebands(ChannelMarker::dsb);
ui->glSpectrum->setCenterFrequency(0);
ui->glSpectrum->setSampleRate(m_rate);
ui->glSpectrum->setSsbSpectrum(false);
}
ui->glSpectrum->setCenterFrequency(m_rate/2);
ui->glSpectrum->setSampleRate(m_rate);
return true;
}

View File

@ -201,9 +201,6 @@
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>false</bool>
</property>
</widget>
</item>
</layout>