1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-16 05:11:49 -05:00

SSB demod: binaural option

This commit is contained in:
f4exb 2015-12-05 18:48:15 +01:00
parent f8c36546b0
commit b07d9c838d
6 changed files with 95 additions and 28 deletions

View File

@ -19,7 +19,7 @@ These plugins come from the parent code base and have been maintained so that th
- Channels:
- lora
- tcpsrc
- tcpsrc (although it has evolved please use the udpsrc plugin instead)
<h2>Unsupported plugins</h2>
@ -180,6 +180,9 @@ For Debian Jessie or Stretch:
- Scope: trigger countdown
- Scope: multiple trigger chaining
- Scope: new mode with linear IQ (two traces) on the primary display and polar IQ on the secondary display
- New USB source plugin to connect to an external demodulator (ex: GNU radio) via USB ports
- Binaural option for SSB demod
- DSB option for SSB
<h2>Major redesign</h2>

View File

@ -29,7 +29,8 @@ MESSAGE_CLASS_DEFINITION(SSBDemod::MsgConfigureSSBDemod, Message)
SSBDemod::SSBDemod(SampleSink* sampleSink) :
m_sampleSink(sampleSink),
m_audioFifo(4, 24000),
m_settingsMutex(QMutex::Recursive)
m_settingsMutex(QMutex::Recursive),
m_audioBinaual(false)
{
setObjectName("SSBDemod");
@ -66,9 +67,14 @@ SSBDemod::~SSBDemod()
DSPEngine::instance()->removeAudioSink(&m_audioFifo);
}
void SSBDemod::configure(MessageQueue* messageQueue, Real Bandwidth, Real LowCutoff, Real volume, int spanLog2)
void SSBDemod::configure(MessageQueue* messageQueue,
Real Bandwidth,
Real LowCutoff,
Real volume,
int spanLog2,
bool audioBinaural)
{
Message* cmd = MsgConfigureSSBDemod::create(Bandwidth, LowCutoff, volume, spanLog2);
Message* cmd = MsgConfigureSSBDemod::create(Bandwidth, LowCutoff, volume, spanLog2, audioBinaural);
messageQueue->push(cmd);
}
@ -102,9 +108,6 @@ void SSBDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
for (int i = 0; i < n_out; i++)
{
//Real demod = (sideband[i].real() + sideband[i].imag()) * 0.7 * 32768.0;
Real demod = (sideband[i].real() + sideband[i].imag()) * 0.7;
// Downsample by 2^(m_scaleLog2 - 1) for SSB band spectrum display
// smart decimation with bit gain using float arithmetic (23 bits significand)
@ -122,9 +125,19 @@ void SSBDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
sum.imag() = 0.0;
}
if (m_audioBinaual)
{
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())
@ -220,13 +233,15 @@ bool SSBDemod::handleMessage(const Message& cmd)
m_volume *= m_volume * 0.1;
m_spanLog2 = cfg.getSpanLog2();
m_audioBinaual = cfg.getAudioBinaural();
m_settingsMutex.unlock();
qDebug() << " - MsgConfigureSSBDemod: m_Bandwidth: " << m_Bandwidth
qDebug() << "SBDemod::handleMessage: MsgConfigureSSBDemod: m_Bandwidth: " << m_Bandwidth
<< " m_LowCutoff: " << m_LowCutoff
<< " m_volume: " << m_volume
<< " m_spanLog2: " << m_spanLog2;
<< " m_spanLog2: " << m_spanLog2
<< " m_audioBinaual: " << m_audioBinaual;
return true;
}

View File

@ -34,7 +34,12 @@ public:
SSBDemod(SampleSink* sampleSink);
virtual ~SSBDemod();
void configure(MessageQueue* messageQueue, Real Bandwidth, Real LowCutoff, Real volume, int spanLog2);
void configure(MessageQueue* messageQueue,
Real Bandwidth,
Real LowCutoff,
Real volume,
int spanLog2,
bool audioBinaural);
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly);
virtual void start();
@ -52,10 +57,15 @@ private:
Real getLoCutoff() const { return m_LowCutoff; }
Real getVolume() const { return m_volume; }
int getSpanLog2() const { return m_spanLog2; }
bool getAudioBinaural() const { return m_audioBinaural; }
static MsgConfigureSSBDemod* create(Real Bandwidth, Real LowCutoff, Real volume, int spanLog2)
static MsgConfigureSSBDemod* create(Real Bandwidth,
Real LowCutoff,
Real volume,
int spanLog2,
bool audioBinaural)
{
return new MsgConfigureSSBDemod(Bandwidth, LowCutoff, volume, spanLog2);
return new MsgConfigureSSBDemod(Bandwidth, LowCutoff, volume, spanLog2, audioBinaural);
}
private:
@ -63,13 +73,19 @@ private:
Real m_LowCutoff;
Real m_volume;
int m_spanLog2;
bool m_audioBinaural;
MsgConfigureSSBDemod(Real Bandwidth, Real LowCutoff, Real volume, int spanLog2) :
MsgConfigureSSBDemod(Real Bandwidth,
Real LowCutoff,
Real volume,
int spanLog2,
bool audioBinaural) :
Message(),
m_Bandwidth(Bandwidth),
m_LowCutoff(LowCutoff),
m_volume(volume),
m_spanLog2(spanLog2)
m_spanLog2(spanLog2),
m_audioBinaural(audioBinaural)
{ }
};
@ -77,6 +93,7 @@ private:
qint16 l;
qint16 r;
};
typedef std::vector<AudioSample> AudioVector;
Real m_Bandwidth;
@ -86,6 +103,7 @@ private:
int m_undersampleCount;
int m_sampleRate;
int m_frequency;
bool m_audioBinaual;
bool m_usb;
Real m_magsq;

View File

@ -71,6 +71,7 @@ QByteArray SSBDemodGUI::serialize() const
s.writeU32(5, m_channelMarker.getColor().rgb());
s.writeS32(6, ui->lowCut->value());
s.writeS32(7, ui->spanLog2->value());
s.writeBool(8, m_audioBinaural);
return s.final();
}
@ -108,6 +109,8 @@ bool SSBDemodGUI::deserialize(const QByteArray& data)
d.readS32(7, &tmp, 20);
ui->spanLog2->setValue(tmp);
setNewRate(tmp);
d.readBool(8, &m_audioBinaural);
ui->audioBinaural->setChecked(m_audioBinaural);
blockApplySettings(false);
m_channelMarker.blockSignals(false);
@ -143,6 +146,12 @@ void SSBDemodGUI::on_deltaMinus_toggled(bool minus)
}
}
void SSBDemodGUI::on_audioBinaural_toggled(bool binaural)
{
m_audioBinaural = binaural;
applySettings();
}
void SSBDemodGUI::on_deltaFrequency_changed(quint64 value)
{
if (ui->deltaMinus->isChecked())
@ -257,6 +266,7 @@ SSBDemodGUI::SSBDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
m_doApplySettings(true),
m_rate(6000),
m_spanLog2(3),
m_audioBinaural(false),
m_channelPowerDbAvg(20,0)
{
ui->setupUi(this);
@ -374,7 +384,8 @@ void SSBDemodGUI::applySettings()
ui->BW->value() * 100.0,
ui->lowCut->value() * 100.0,
ui->volume->value() / 10.0,
m_spanLog2);
m_spanLog2,
m_audioBinaural);
}
}

View File

@ -40,6 +40,7 @@ private slots:
void viewChanged();
void on_deltaFrequency_changed(quint64 value);
void on_deltaMinus_toggled(bool minus);
void on_audioBinaural_toggled(bool binaural);
void on_BW_valueChanged(int value);
void on_lowCut_valueChanged(int value);
void on_volume_valueChanged(int value);
@ -56,6 +57,7 @@ private:
bool m_doApplySettings;
int m_rate;
int m_spanLog2;
bool m_audioBinaural;
MovingAverage<Real> m_channelPowerDbAvg;
ThreadedSampleSink* m_threadedChannelizer;

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>302</width>
<height>544</height>
<height>483</height>
</rect>
</property>
<property name="minimumSize">
@ -25,7 +25,7 @@
<x>5</x>
<y>35</y>
<width>281</width>
<height>349</height>
<height>151</height>
</rect>
</property>
<property name="windowTitle">
@ -142,6 +142,24 @@
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="audioBinaural">
<property name="toolTip">
<string>Binaural audio</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../../sdrbase/resources/res.qrc">
<normaloff>:/mono.png</normaloff>
<normalon>:/stereo.png</normalon>:/mono.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
@ -332,8 +350,8 @@
<widget class="QWidget" name="spectrumContainer" native="true">
<property name="geometry">
<rect>
<x>30</x>
<y>390</y>
<x>40</x>
<y>190</y>
<width>218</width>
<height>284</height>
</rect>
@ -380,12 +398,6 @@
</widget>
</widget>
<customwidgets>
<customwidget>
<class>RollupWidget</class>
<extends>QWidget</extends>
<header>gui/rollupwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ValueDial</class>
<extends>QWidget</extends>
@ -404,6 +416,12 @@
<header>gui/glspectrumgui.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>RollupWidget</class>
<extends>QWidget</extends>
<header>gui/rollupwidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../../../sdrbase/resources/res.qrc"/>