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

SSB demod: implemented copy audio to UDP

This commit is contained in:
f4exb 2017-11-21 21:33:46 +01:00
parent 5371d6a1b4
commit a57fdb8bd7
7 changed files with 80 additions and 13 deletions

View File

@ -35,6 +35,7 @@ MESSAGE_CLASS_DEFINITION(SSBDemod::MsgConfigureSSBDemodPrivate, Message)
MESSAGE_CLASS_DEFINITION(SSBDemod::MsgConfigureChannelizer, Message) MESSAGE_CLASS_DEFINITION(SSBDemod::MsgConfigureChannelizer, Message)
const QString SSBDemod::m_channelID = "de.maintech.sdrangelove.channel.ssb"; const QString SSBDemod::m_channelID = "de.maintech.sdrangelove.channel.ssb";
const int SSBDemod::m_udpBlockSize = 512;
SSBDemod::SSBDemod(DeviceSourceAPI *deviceAPI) : SSBDemod::SSBDemod(DeviceSourceAPI *deviceAPI) :
m_deviceAPI(deviceAPI), m_deviceAPI(deviceAPI),
@ -85,6 +86,7 @@ SSBDemod::SSBDemod(DeviceSourceAPI *deviceAPI) :
DSBFilter = new fftfilt((2.0f * m_Bandwidth) / m_audioSampleRate, 2 * ssbFftLen); DSBFilter = new fftfilt((2.0f * m_Bandwidth) / m_audioSampleRate, 2 * ssbFftLen);
DSPEngine::instance()->addAudioSink(&m_audioFifo); DSPEngine::instance()->addAudioSink(&m_audioFifo);
m_udpBufferAudio = new UDPSink<qint16>(this, m_udpBlockSize, m_settings.m_udpPort);
m_channelizer = new DownChannelizer(this); m_channelizer = new DownChannelizer(this);
m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this); m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this);
@ -98,13 +100,14 @@ SSBDemod::~SSBDemod()
{ {
if (SSBFilter) delete SSBFilter; if (SSBFilter) delete SSBFilter;
if (DSBFilter) delete DSBFilter; if (DSBFilter) delete DSBFilter;
DSPEngine::instance()->removeAudioSink(&m_audioFifo); DSPEngine::instance()->removeAudioSink(&m_audioFifo);
m_deviceAPI->removeChannelAPI(this); m_deviceAPI->removeChannelAPI(this);
m_deviceAPI->removeThreadedSink(m_threadedChannelizer); m_deviceAPI->removeThreadedSink(m_threadedChannelizer);
delete m_threadedChannelizer; delete m_threadedChannelizer;
delete m_channelizer; delete m_channelizer;
delete m_udpBufferAudio;
} }
void SSBDemod::configure(MessageQueue* messageQueue, void SSBDemod::configure(MessageQueue* messageQueue,
@ -216,6 +219,8 @@ void SSBDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
{ {
m_audioBuffer[m_audioBufferFill].r = 0; m_audioBuffer[m_audioBufferFill].r = 0;
m_audioBuffer[m_audioBufferFill].l = 0; m_audioBuffer[m_audioBufferFill].l = 0;
if (m_settings.m_copyAudioToUDP) { m_udpBufferAudio->write(0); }
} }
else else
{ {
@ -231,6 +236,8 @@ void SSBDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
m_audioBuffer[m_audioBufferFill].r = (qint16)(sideband[i].real() * m_volume * agcVal); m_audioBuffer[m_audioBufferFill].r = (qint16)(sideband[i].real() * m_volume * agcVal);
m_audioBuffer[m_audioBufferFill].l = (qint16)(sideband[i].imag() * m_volume * agcVal); m_audioBuffer[m_audioBufferFill].l = (qint16)(sideband[i].imag() * m_volume * agcVal);
} }
if (m_settings.m_copyAudioToUDP) { m_udpBufferAudio->write(m_audioBuffer[m_audioBufferFill].r + m_audioBuffer[m_audioBufferFill].l); }
} }
else else
{ {
@ -238,6 +245,8 @@ void SSBDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
qint16 sample = (qint16)(demod * m_volume * agcVal); qint16 sample = (qint16)(demod * m_volume * agcVal);
m_audioBuffer[m_audioBufferFill].l = sample; m_audioBuffer[m_audioBufferFill].l = sample;
m_audioBuffer[m_audioBufferFill].r = sample; m_audioBuffer[m_audioBufferFill].r = sample;
if (m_settings.m_copyAudioToUDP) { m_udpBufferAudio->write(sample); }
} }
} }
@ -336,6 +345,7 @@ bool SSBDemod::handleMessage(const Message& cmd)
<< " m_audioFlipChannels: " << settings.m_audioFlipChannels << " m_audioFlipChannels: " << settings.m_audioFlipChannels
<< " m_dsb: " << settings.m_dsb << " m_dsb: " << settings.m_dsb
<< " m_audioMute: " << settings.m_audioMute << " m_audioMute: " << settings.m_audioMute
<< " m_copyAudioToUDP: " << settings.m_copyAudioToUDP
<< " m_agcActive: " << settings.m_agc << " m_agcActive: " << settings.m_agc
<< " m_agcClamping: " << settings.m_agcClamping << " m_agcClamping: " << settings.m_agcClamping
<< " m_agcTimeLog2: " << settings.m_agcTimeLog2 << " m_agcTimeLog2: " << settings.m_agcTimeLog2
@ -451,13 +461,12 @@ void SSBDemod::applySettings(const SSBDemodSettings& settings, bool force)
<< " agcClamping: " << agcClamping; << " agcClamping: " << agcClamping;
} }
// TODO: if ((m_settings.m_udpAddress != settings.m_udpAddress)
// if ((m_settings.m_udpAddress != settings.m_udpAddress) || (m_settings.m_udpPort != settings.m_udpPort) || force)
// || (m_settings.m_udpPort != settings.m_udpPort) || force) {
// { m_udpBufferAudio->setAddress(const_cast<QString&>(settings.m_udpAddress));
// m_udpBufferAudio->setAddress(const_cast<QString&>(settings.m_udpAddress)); m_udpBufferAudio->setPort(settings.m_udpPort);
// m_udpBufferAudio->setPort(settings.m_udpPort); }
// }
m_spanLog2 = settings.m_spanLog2; m_spanLog2 = settings.m_spanLog2;
m_audioBinaual = settings.m_audioBinaural; m_audioBinaual = settings.m_audioBinaural;

View File

@ -268,6 +268,8 @@ private:
uint m_audioBufferFill; uint m_audioBufferFill;
AudioFifo m_audioFifo; AudioFifo m_audioFifo;
quint32 m_audioSampleRate; quint32 m_audioSampleRate;
UDPSink<qint16> *m_udpBufferAudio;
static const int m_udpBlockSize;
QMutex m_settingsMutex; QMutex m_settingsMutex;

View File

@ -8,11 +8,12 @@
#include "ui_ssbdemodgui.h" #include "ui_ssbdemodgui.h"
#include "dsp/spectrumvis.h" #include "dsp/spectrumvis.h"
#include "dsp/dspengine.h"
#include "gui/glspectrum.h" #include "gui/glspectrum.h"
#include "gui/basicchannelsettingsdialog.h"
#include "plugin/pluginapi.h" #include "plugin/pluginapi.h"
#include "util/simpleserializer.h" #include "util/simpleserializer.h"
#include "util/db.h" #include "util/db.h"
#include "dsp/dspengine.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "ssbdemod.h" #include "ssbdemod.h"
@ -196,6 +197,31 @@ void SSBDemodGUI::on_flipSidebands_clicked(bool checked __attribute__((unused)))
ui->lowCut->setValue(-lcValue); ui->lowCut->setValue(-lcValue);
} }
void SSBDemodGUI::on_copyAudioToUDP_toggled(bool checked)
{
m_settings.m_copyAudioToUDP = checked;
applySettings();
}
void SSBDemodGUI::onMenuDialogCalled(const QPoint &p)
{
BasicChannelSettingsDialog dialog(&m_channelMarker, this);
dialog.move(p);
dialog.exec();
m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency();
m_settings.m_udpAddress = m_channelMarker.getUDPAddress(),
m_settings.m_udpPort = m_channelMarker.getUDPSendPort(),
m_settings.m_rgbColor = m_channelMarker.getColor().rgb();
m_settings.m_title = m_channelMarker.getTitle();
setWindowTitle(m_settings.m_title);
setTitleColor(m_settings.m_rgbColor);
displayUDPAddress();
applySettings();
}
void SSBDemodGUI::onWidgetRolled(QWidget* widget __attribute__((unused)), bool rollDown __attribute__((unused))) void SSBDemodGUI::onWidgetRolled(QWidget* widget __attribute__((unused)), bool rollDown __attribute__((unused)))
{ {
} }
@ -216,6 +242,7 @@ SSBDemodGUI::SSBDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseban
ui->setupUi(this); ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose, true); setAttribute(Qt::WA_DeleteOnClose, true);
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool))); connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &)));
m_spectrumVis = new SpectrumVis(ui->glSpectrum); m_spectrumVis = new SpectrumVis(ui->glSpectrum);
m_ssbDemod = (SSBDemod*) rxChannel; //new SSBDemod(m_deviceUISet->m_deviceSourceAPI); m_ssbDemod = (SSBDemod*) rxChannel; //new SSBDemod(m_deviceUISet->m_deviceSourceAPI);
@ -396,8 +423,8 @@ void SSBDemodGUI::displaySettings()
{ {
m_channelMarker.blockSignals(true); m_channelMarker.blockSignals(true);
m_channelMarker.setCenterFrequency(m_settings.m_inputFrequencyOffset); m_channelMarker.setCenterFrequency(m_settings.m_inputFrequencyOffset);
m_channelMarker.setTitle(m_settings.m_title);
m_channelMarker.setBandwidth(m_settings.m_rfBandwidth * 2); m_channelMarker.setBandwidth(m_settings.m_rfBandwidth * 2);
m_channelMarker.setTitle(m_settings.m_title);
m_channelMarker.setLowCutoff(m_settings.m_lowCutoff); m_channelMarker.setLowCutoff(m_settings.m_lowCutoff);
ui->flipSidebands->setEnabled(!m_settings.m_dsb); ui->flipSidebands->setEnabled(!m_settings.m_dsb);
@ -474,13 +501,14 @@ void SSBDemodGUI::displaySettings()
ui->agcThresholdGate->setValue(m_settings.m_agcThresholdGate); ui->agcThresholdGate->setValue(m_settings.m_agcThresholdGate);
s = QString::number(ui->agcThresholdGate->value(), 'f', 0); s = QString::number(ui->agcThresholdGate->value(), 'f', 0);
ui->agcThresholdGateText->setText(s); ui->agcThresholdGateText->setText(s);
ui->copyAudioToUDP->setChecked(m_settings.m_copyAudioToUDP);
blockApplySettings(false); blockApplySettings(false);
} }
void SSBDemodGUI::displayUDPAddress() void SSBDemodGUI::displayUDPAddress()
{ {
//TODO: ui->copyAudioToUDP->setToolTip(QString("Copy audio output to UDP %1:%2").arg(m_settings.m_udpAddress).arg(m_settings.m_udpPort)); ui->copyAudioToUDP->setToolTip(QString("Copy audio output to UDP %1:%2").arg(m_settings.m_udpAddress).arg(m_settings.m_udpPort));
} }
void SSBDemodGUI::displayAGCPowerThreshold(int value) void SSBDemodGUI::displayAGCPowerThreshold(int value)

View File

@ -95,7 +95,9 @@ private slots:
void on_audioMute_toggled(bool checked); void on_audioMute_toggled(bool checked);
void on_spanLog2_valueChanged(int value); void on_spanLog2_valueChanged(int value);
void on_flipSidebands_clicked(bool checked); void on_flipSidebands_clicked(bool checked);
void on_copyAudioToUDP_toggled(bool copy);
void onWidgetRolled(QWidget* widget, bool rollDown); void onWidgetRolled(QWidget* widget, bool rollDown);
void onMenuDialogCalled(const QPoint& p);
void tick(); void tick();
}; };

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>385</width> <width>385</width>
<height>160</height> <height>190</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -37,7 +37,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>385</width> <width>385</width>
<height>151</height> <height>171</height>
</rect> </rect>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
@ -359,6 +359,12 @@
</item> </item>
<item> <item>
<widget class="TickedSlider" name="BW"> <widget class="TickedSlider" name="BW">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16</height>
</size>
</property>
<property name="toolTip"> <property name="toolTip">
<string>Lowpass filter cutoff frequency</string> <string>Lowpass filter cutoff frequency</string>
</property> </property>
@ -542,6 +548,12 @@
</item> </item>
<item> <item>
<widget class="TickedSlider" name="lowCut"> <widget class="TickedSlider" name="lowCut">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16</height>
</size>
</property>
<property name="toolTip"> <property name="toolTip">
<string>Highpass filter cutoff frequency (SSB)</string> <string>Highpass filter cutoff frequency (SSB)</string>
</property> </property>
@ -821,6 +833,16 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item>
<widget class="ButtonSwitch" name="copyAudioToUDP">
<property name="toolTip">
<string>Copy audio to UDP</string>
</property>
<property name="text">
<string>U</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QToolButton" name="audioMute"> <widget class="QToolButton" name="audioMute">
<property name="toolTip"> <property name="toolTip">

View File

@ -36,6 +36,7 @@ void SSBDemodSettings::resetToDefaults()
m_audioMute = false; m_audioMute = false;
m_agc = false; m_agc = false;
m_agcClamping = false; m_agcClamping = false;
m_copyAudioToUDP = false;
m_agcPowerThreshold = -40; m_agcPowerThreshold = -40;
m_agcThresholdGate = 4; m_agcThresholdGate = 4;
m_agcTimeLog2 = 7; m_agcTimeLog2 = 7;
@ -46,6 +47,8 @@ void SSBDemodSettings::resetToDefaults()
m_inputSampleRate = 96000; m_inputSampleRate = 96000;
m_inputFrequencyOffset = 0; m_inputFrequencyOffset = 0;
m_audioSampleRate = DSPEngine::instance()->getAudioSampleRate(); m_audioSampleRate = DSPEngine::instance()->getAudioSampleRate();
m_udpAddress = "127.0.0.1";
m_udpPort = 9999;
m_rgbColor = QColor(0, 255, 0).rgb(); m_rgbColor = QColor(0, 255, 0).rgb();
m_title = "SSB Demodulator"; m_title = "SSB Demodulator";
} }

View File

@ -36,6 +36,7 @@ struct SSBDemodSettings
bool m_audioMute; bool m_audioMute;
bool m_agc; bool m_agc;
bool m_agcClamping; bool m_agcClamping;
bool m_copyAudioToUDP;
int m_agcTimeLog2; int m_agcTimeLog2;
int m_agcPowerThreshold; int m_agcPowerThreshold;
int m_agcThresholdGate; int m_agcThresholdGate;