mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-02-03 09:44:01 -05:00
UDP source: send audio samples always on 16 bits. Options to send raw I/Q in either 16 or 24 bits regardless of sample size at compile time
This commit is contained in:
parent
da362823dc
commit
befc08f2e1
@ -61,7 +61,6 @@ UDPSrc::UDPSrc(DeviceSourceAPI *deviceAPI) :
|
||||
m_udpBuffer16 = new UDPSink<Sample16>(this, udpBlockSize, m_settings.m_udpPort);
|
||||
m_udpBufferMono16 = new UDPSink<int16_t>(this, udpBlockSize, m_settings.m_udpPort);
|
||||
m_udpBuffer24 = new UDPSink<Sample24>(this, udpBlockSize, m_settings.m_udpPort);
|
||||
m_udpBufferMono24 = new UDPSink<int32_t>(this, udpBlockSize, m_settings.m_udpPort);
|
||||
m_audioSocket = new QUdpSocket(this);
|
||||
m_udpAudioBuf = new char[m_udpAudioPayloadSize];
|
||||
|
||||
@ -113,7 +112,6 @@ UDPSrc::~UDPSrc()
|
||||
{
|
||||
delete m_audioSocket;
|
||||
delete m_udpBuffer24;
|
||||
delete m_udpBufferMono24;
|
||||
delete m_udpBuffer16;
|
||||
delete m_udpBufferMono16;
|
||||
delete[] m_udpAudioBuf;
|
||||
@ -153,7 +151,8 @@ void UDPSrc::feed(const SampleVector::const_iterator& begin, const SampleVector:
|
||||
if ((m_settings.m_agc) &&
|
||||
(m_settings.m_sampleFormat != UDPSrcSettings::FormatNFM) &&
|
||||
(m_settings.m_sampleFormat != UDPSrcSettings::FormatNFMMono) &&
|
||||
(m_settings.m_sampleFormat != UDPSrcSettings::FormatIQ))
|
||||
(m_settings.m_sampleFormat != UDPSrcSettings::FormatIQ16) &&
|
||||
(m_settings.m_sampleFormat != UDPSrcSettings::FormatIQ24))
|
||||
{
|
||||
agcFactor = m_agc.feedAndGetValue(ci);
|
||||
inMagSq = m_agc.getMagSq();
|
||||
@ -494,7 +493,6 @@ void UDPSrc::applySettings(const UDPSrcSettings& settings, bool force)
|
||||
<< " m_squelchGate" << settings.m_squelchGate
|
||||
<< " m_agc" << settings.m_agc
|
||||
<< " m_sampleFormat: " << settings.m_sampleFormat
|
||||
<< " m_sampleSize: " << 16 + settings.m_sampleSize*8
|
||||
<< " m_outputSampleRate: " << settings.m_outputSampleRate
|
||||
<< " m_rfBandwidth: " << settings.m_rfBandwidth
|
||||
<< " m_fmDeviation: " << settings.m_fmDeviation
|
||||
@ -582,7 +580,6 @@ void UDPSrc::applySettings(const UDPSrcSettings& settings, bool force)
|
||||
m_udpBuffer16->setAddress(const_cast<QString&>(settings.m_udpAddress));
|
||||
m_udpBufferMono16->setAddress(const_cast<QString&>(settings.m_udpAddress));
|
||||
m_udpBuffer24->setAddress(const_cast<QString&>(settings.m_udpAddress));
|
||||
m_udpBufferMono24->setAddress(const_cast<QString&>(settings.m_udpAddress));
|
||||
}
|
||||
|
||||
if ((settings.m_udpPort != m_settings.m_udpPort) || force)
|
||||
@ -590,7 +587,6 @@ void UDPSrc::applySettings(const UDPSrcSettings& settings, bool force)
|
||||
m_udpBuffer16->setPort(settings.m_udpPort);
|
||||
m_udpBufferMono16->setPort(settings.m_udpPort);
|
||||
m_udpBuffer24->setPort(settings.m_udpPort);
|
||||
m_udpBufferMono24->setPort(settings.m_udpPort);
|
||||
}
|
||||
|
||||
if ((settings.m_audioPort != m_settings.m_audioPort) || force)
|
||||
|
@ -186,7 +186,6 @@ protected:
|
||||
UDPSink<Sample16> *m_udpBuffer16;
|
||||
UDPSink<int16_t> *m_udpBufferMono16;
|
||||
UDPSink<Sample24> *m_udpBuffer24;
|
||||
UDPSink<int32_t> *m_udpBufferMono24;
|
||||
|
||||
AudioVector m_audioBuffer;
|
||||
uint m_audioBufferFill;
|
||||
@ -281,18 +280,22 @@ protected:
|
||||
{
|
||||
if (SDR_RX_SAMP_SZ == 16)
|
||||
{
|
||||
if (m_settings.m_sampleSize == UDPSrcSettings::Size16bits) {
|
||||
if (m_settings.m_sampleFormat == UDPSrcSettings::FormatIQ16) {
|
||||
m_udpBuffer16->write(Sample16(real, imag));
|
||||
} else if (m_settings.m_sampleSize == UDPSrcSettings::Size24bits) {
|
||||
} else if (m_settings.m_sampleFormat == UDPSrcSettings::FormatIQ24) {
|
||||
m_udpBuffer24->write(Sample24(real<<8, imag<<8));
|
||||
} else {
|
||||
m_udpBuffer16->write(Sample16(real, imag));
|
||||
}
|
||||
}
|
||||
else if (SDR_RX_SAMP_SZ == 24)
|
||||
{
|
||||
if (m_settings.m_sampleSize == UDPSrcSettings::Size16bits) {
|
||||
if (m_settings.m_sampleFormat == UDPSrcSettings::FormatIQ16) {
|
||||
m_udpBuffer16->write(Sample16(real>>8, imag>>8));
|
||||
} else if (m_settings.m_sampleSize == UDPSrcSettings::Size24bits) {
|
||||
} else if (m_settings.m_sampleFormat == UDPSrcSettings::FormatIQ24) {
|
||||
m_udpBuffer24->write(Sample24(real, imag));
|
||||
} else {
|
||||
m_udpBuffer16->write(Sample16(real>>8, imag>>8));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -301,38 +304,22 @@ protected:
|
||||
{
|
||||
if (SDR_RX_SAMP_SZ == 16)
|
||||
{
|
||||
if (m_settings.m_sampleSize == UDPSrcSettings::Size16bits) {
|
||||
m_udpBufferMono16->write(sample);
|
||||
} else if (m_settings.m_sampleSize == UDPSrcSettings::Size24bits) {
|
||||
m_udpBufferMono24->write(sample<<8);
|
||||
}
|
||||
m_udpBufferMono16->write(sample);
|
||||
}
|
||||
else if (SDR_RX_SAMP_SZ == 24)
|
||||
{
|
||||
if (m_settings.m_sampleSize == UDPSrcSettings::Size16bits) {
|
||||
m_udpBufferMono16->write(sample>>8);
|
||||
} else if (m_settings.m_sampleSize == UDPSrcSettings::Size24bits) {
|
||||
m_udpBufferMono24->write(sample);
|
||||
}
|
||||
m_udpBufferMono16->write(sample>>8);
|
||||
}
|
||||
}
|
||||
|
||||
void udpWriteNorm(Real real, Real imag)
|
||||
{
|
||||
if (m_settings.m_sampleSize == UDPSrcSettings::Size16bits) {
|
||||
m_udpBuffer16->write(Sample16(real*32768.0, imag*32768.0));
|
||||
} else if (m_settings.m_sampleSize == UDPSrcSettings::Size24bits) {
|
||||
m_udpBuffer24->write(Sample24(real*8388608.0, imag*8388608.0));
|
||||
}
|
||||
m_udpBuffer16->write(Sample16(real*32768.0, imag*32768.0));
|
||||
}
|
||||
|
||||
void udpWriteNormMono(Real sample)
|
||||
{
|
||||
if (m_settings.m_sampleSize == UDPSrcSettings::Size16bits) {
|
||||
m_udpBufferMono16->write(sample*32768.0);
|
||||
} else if (m_settings.m_sampleSize == UDPSrcSettings::Size24bits) {
|
||||
m_udpBufferMono24->write(sample*8388608.0);
|
||||
}
|
||||
m_udpBufferMono16->write(sample*32768.0);
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -251,36 +251,39 @@ void UDPSrcGUI::setSampleFormatIndex(const UDPSrcSettings::SampleFormat& sampleF
|
||||
{
|
||||
switch(sampleFormat)
|
||||
{
|
||||
case UDPSrcSettings::FormatIQ:
|
||||
case UDPSrcSettings::FormatIQ16:
|
||||
ui->sampleFormat->setCurrentIndex(0);
|
||||
break;
|
||||
case UDPSrcSettings::FormatNFM:
|
||||
case UDPSrcSettings::FormatIQ24:
|
||||
ui->sampleFormat->setCurrentIndex(1);
|
||||
break;
|
||||
case UDPSrcSettings::FormatNFMMono:
|
||||
case UDPSrcSettings::FormatNFM:
|
||||
ui->sampleFormat->setCurrentIndex(2);
|
||||
break;
|
||||
case UDPSrcSettings::FormatLSB:
|
||||
case UDPSrcSettings::FormatNFMMono:
|
||||
ui->sampleFormat->setCurrentIndex(3);
|
||||
break;
|
||||
case UDPSrcSettings::FormatUSB:
|
||||
case UDPSrcSettings::FormatLSB:
|
||||
ui->sampleFormat->setCurrentIndex(4);
|
||||
break;
|
||||
case UDPSrcSettings::FormatLSBMono:
|
||||
case UDPSrcSettings::FormatUSB:
|
||||
ui->sampleFormat->setCurrentIndex(5);
|
||||
break;
|
||||
case UDPSrcSettings::FormatUSBMono:
|
||||
case UDPSrcSettings::FormatLSBMono:
|
||||
ui->sampleFormat->setCurrentIndex(6);
|
||||
break;
|
||||
case UDPSrcSettings::FormatAMMono:
|
||||
case UDPSrcSettings::FormatUSBMono:
|
||||
ui->sampleFormat->setCurrentIndex(7);
|
||||
break;
|
||||
case UDPSrcSettings::FormatAMNoDCMono:
|
||||
case UDPSrcSettings::FormatAMMono:
|
||||
ui->sampleFormat->setCurrentIndex(8);
|
||||
break;
|
||||
case UDPSrcSettings::FormatAMBPFMono:
|
||||
case UDPSrcSettings::FormatAMNoDCMono:
|
||||
ui->sampleFormat->setCurrentIndex(9);
|
||||
break;
|
||||
case UDPSrcSettings::FormatAMBPFMono:
|
||||
ui->sampleFormat->setCurrentIndex(10);
|
||||
break;
|
||||
default:
|
||||
ui->sampleFormat->setCurrentIndex(0);
|
||||
break;
|
||||
@ -292,47 +295,51 @@ void UDPSrcGUI::setSampleFormat(int index)
|
||||
switch(index)
|
||||
{
|
||||
case 0:
|
||||
m_settings.m_sampleFormat = UDPSrcSettings::FormatIQ;
|
||||
m_settings.m_sampleFormat = UDPSrcSettings::FormatIQ16;
|
||||
ui->fmDeviation->setEnabled(false);
|
||||
break;
|
||||
case 1:
|
||||
m_settings.m_sampleFormat = UDPSrcSettings::FormatIQ24;
|
||||
ui->fmDeviation->setEnabled(false);
|
||||
break;
|
||||
case 2:
|
||||
m_settings.m_sampleFormat = UDPSrcSettings::FormatNFM;
|
||||
ui->fmDeviation->setEnabled(true);
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
m_settings.m_sampleFormat = UDPSrcSettings::FormatNFMMono;
|
||||
ui->fmDeviation->setEnabled(true);
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
m_settings.m_sampleFormat = UDPSrcSettings::FormatLSB;
|
||||
ui->fmDeviation->setEnabled(false);
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
m_settings.m_sampleFormat = UDPSrcSettings::FormatUSB;
|
||||
ui->fmDeviation->setEnabled(false);
|
||||
break;
|
||||
case 5:
|
||||
case 6:
|
||||
m_settings.m_sampleFormat = UDPSrcSettings::FormatLSBMono;
|
||||
ui->fmDeviation->setEnabled(false);
|
||||
break;
|
||||
case 6:
|
||||
case 7:
|
||||
m_settings.m_sampleFormat = UDPSrcSettings::FormatUSBMono;
|
||||
ui->fmDeviation->setEnabled(false);
|
||||
break;
|
||||
case 7:
|
||||
case 8:
|
||||
m_settings.m_sampleFormat = UDPSrcSettings::FormatAMMono;
|
||||
ui->fmDeviation->setEnabled(false);
|
||||
break;
|
||||
case 8:
|
||||
case 9:
|
||||
m_settings.m_sampleFormat = UDPSrcSettings::FormatAMNoDCMono;
|
||||
ui->fmDeviation->setEnabled(false);
|
||||
break;
|
||||
case 9:
|
||||
case 10:
|
||||
m_settings.m_sampleFormat = UDPSrcSettings::FormatAMBPFMono;
|
||||
ui->fmDeviation->setEnabled(false);
|
||||
break;
|
||||
default:
|
||||
m_settings.m_sampleFormat = UDPSrcSettings::FormatIQ;
|
||||
m_settings.m_sampleFormat = UDPSrcSettings::FormatIQ16;
|
||||
ui->fmDeviation->setEnabled(false);
|
||||
break;
|
||||
}
|
||||
@ -384,18 +391,6 @@ void UDPSrcGUI::on_sampleFormat_currentIndexChanged(int index)
|
||||
ui->applyBtn->setStyleSheet("QPushButton { background-color : green; }");
|
||||
}
|
||||
|
||||
void UDPSrcGUI::on_sampleSize_currentIndexChanged(int index)
|
||||
{
|
||||
if ((index < 0) || (index >= UDPSrcSettings::SizeNone)) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_settings.m_sampleSize = (UDPSrcSettings::SampleSize) index;
|
||||
|
||||
ui->applyBtn->setEnabled(true);
|
||||
ui->applyBtn->setStyleSheet("QPushButton { background-color : green; }");
|
||||
}
|
||||
|
||||
void UDPSrcGUI::on_sampleRate_textEdited(const QString& arg1 __attribute__((unused)))
|
||||
{
|
||||
bool ok;
|
||||
|
@ -94,7 +94,6 @@ private:
|
||||
private slots:
|
||||
void on_deltaFrequency_changed(qint64 value);
|
||||
void on_sampleFormat_currentIndexChanged(int index);
|
||||
void on_sampleSize_currentIndexChanged(int index);
|
||||
void on_sampleRate_textEdited(const QString& arg1);
|
||||
void on_rfBandwidth_textEdited(const QString& arg1);
|
||||
void on_fmDeviation_textEdited(const QString& arg1);
|
||||
|
@ -386,7 +386,12 @@
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>I/Q</string>
|
||||
<string>I/Q 16bits</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>I/Q 24bits</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
@ -436,23 +441,6 @@
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="sampleSize">
|
||||
<property name="toolTip">
|
||||
<string>Samples size</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>16 bits</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>24 bits</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
const PluginDescriptor UDPSrcPlugin::m_pluginDescriptor = {
|
||||
QString("UDP Channel Source"),
|
||||
QString("3.12.0"),
|
||||
QString("3.14.3"),
|
||||
QString("(c) Edouard Griffiths, F4EXB"),
|
||||
QString("https://github.com/f4exb/sdrangel"),
|
||||
true,
|
||||
|
@ -31,8 +31,7 @@ UDPSrcSettings::UDPSrcSettings() :
|
||||
void UDPSrcSettings::resetToDefaults()
|
||||
{
|
||||
m_outputSampleRate = 48000;
|
||||
m_sampleFormat = FormatIQ;
|
||||
m_sampleSize = Size16bits;
|
||||
m_sampleFormat = FormatIQ16;
|
||||
m_inputFrequencyOffset = 0;
|
||||
m_rfBandwidth = 12500;
|
||||
m_fmDeviation = 2500;
|
||||
@ -78,7 +77,6 @@ QByteArray UDPSrcSettings::serialize() const
|
||||
s.writeS32(17, m_squelchGate);
|
||||
s.writeBool(18, m_agc);
|
||||
s.writeString(19, m_title);
|
||||
s.writeS32(20, (int) m_sampleFormat);
|
||||
|
||||
return s.final();
|
||||
|
||||
@ -108,12 +106,12 @@ bool UDPSrcSettings::deserialize(const QByteArray& data)
|
||||
d.readS32(2, &s32tmp, 0);
|
||||
m_inputFrequencyOffset = s32tmp;
|
||||
|
||||
d.readS32(3, &s32tmp, FormatIQ);
|
||||
d.readS32(3, &s32tmp, FormatIQ16);
|
||||
|
||||
if ((s32tmp >= 0) && (s32tmp < (int) FormatNone)) {
|
||||
m_sampleFormat = (SampleFormat) s32tmp;
|
||||
} else {
|
||||
m_sampleFormat = FormatIQ;
|
||||
m_sampleFormat = FormatIQ16;
|
||||
}
|
||||
|
||||
d.readReal(4, &m_outputSampleRate, 48000.0);
|
||||
@ -136,14 +134,6 @@ bool UDPSrcSettings::deserialize(const QByteArray& data)
|
||||
d.readBool(18, &m_agc, false);
|
||||
d.readString(19, &m_title, "UDP Sample Source");
|
||||
|
||||
d.readS32(20, &s32tmp, Size16bits);
|
||||
|
||||
if ((s32tmp >= 0) && (s32tmp < (int) SizeNone)) {
|
||||
m_sampleSize = (SampleSize) s32tmp;
|
||||
} else {
|
||||
m_sampleSize = Size16bits;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
@ -26,7 +26,8 @@ class Serializable;
|
||||
struct UDPSrcSettings
|
||||
{
|
||||
enum SampleFormat {
|
||||
FormatIQ,
|
||||
FormatIQ16,
|
||||
FormatIQ24,
|
||||
FormatNFM,
|
||||
FormatNFMMono,
|
||||
FormatLSB,
|
||||
@ -39,15 +40,8 @@ struct UDPSrcSettings
|
||||
FormatNone
|
||||
};
|
||||
|
||||
enum SampleSize {
|
||||
Size16bits,
|
||||
Size24bits,
|
||||
SizeNone
|
||||
};
|
||||
|
||||
float m_outputSampleRate;
|
||||
SampleFormat m_sampleFormat;
|
||||
SampleSize m_sampleSize;
|
||||
int64_t m_inputFrequencyOffset;
|
||||
float m_rfBandwidth;
|
||||
int m_fmDeviation;
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
const PluginDescriptor UDPSinkPlugin::m_pluginDescriptor = {
|
||||
QString("UDP Channel Sink"),
|
||||
QString("3.14.2"),
|
||||
QString("3.14.3"),
|
||||
QString("(c) Edouard Griffiths, F4EXB"),
|
||||
QString("https://github.com/f4exb/sdrangel"),
|
||||
true,
|
||||
|
Loading…
Reference in New Issue
Block a user