1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2025-04-04 18:48:34 -04:00

UDP sink plugin: implemented mono/stereo input toggle

This commit is contained in:
f4exb 2017-08-25 10:32:18 +02:00
parent 242617ba7b
commit ff23b6eb26
4 changed files with 40 additions and 122 deletions

View File

@ -144,20 +144,10 @@ void UDPSink::modulateSample()
m_modSample.imag(0.0f);
}
}
else if ((m_running.m_sampleFormat == FormatNFMMono) || (m_running.m_sampleFormat == FormatNFM))
else if (m_running.m_sampleFormat == FormatNFM)
{
FixReal t;
Sample s;
if (m_running.m_sampleFormat == FormatNFMMono)
{
m_udpHandler.readSample(t);
}
else
{
m_udpHandler.readSample(s);
t = (s.m_real + s.m_imag) / 2;
}
readMonoSample(t);
m_inMovingAverage.feed((t*t)/1073741824.0);
m_inMagsq = m_inMovingAverage.average();
@ -177,10 +167,10 @@ void UDPSink::modulateSample()
m_modSample.imag(0.0f);
}
}
else if (m_running.m_sampleFormat == FormatAMMono)
else if (m_running.m_sampleFormat == FormatAM)
{
FixReal t;
m_udpHandler.readSample(t);
readMonoSample(t);
m_inMovingAverage.feed((t*t)/1073741824.0);
m_inMagsq = m_inMovingAverage.average();
@ -198,14 +188,14 @@ void UDPSink::modulateSample()
m_modSample.imag(0.0f);
}
}
else if ((m_running.m_sampleFormat == FormatLSBMono) || (m_running.m_sampleFormat == FormatUSBMono))
else if ((m_running.m_sampleFormat == FormatLSB) || (m_running.m_sampleFormat == FormatUSB))
{
FixReal t;
Complex c, ci;
fftfilt::cmplx *filtered;
int n_out = 0;
m_udpHandler.readSample(t);
readMonoSample(t);
m_inMovingAverage.feed((t*t)/1073741824.0);
m_inMagsq = m_inMovingAverage.average();
@ -216,47 +206,6 @@ void UDPSink::modulateSample()
ci.real((t / 32768.0f) * m_running.m_gain);
ci.imag(0.0f);
n_out = m_SSBFilter->runSSB(ci, &filtered, (m_running.m_sampleFormat == FormatUSBMono));
if (n_out > 0)
{
memcpy((void *) m_SSBFilterBuffer, (const void *) filtered, n_out*sizeof(Complex));
m_SSBFilterBufferIndex = 0;
}
c = m_SSBFilterBuffer[m_SSBFilterBufferIndex];
m_modSample.real(m_SSBFilterBuffer[m_SSBFilterBufferIndex].real() * 32768.0f);
m_modSample.imag(m_SSBFilterBuffer[m_SSBFilterBufferIndex].imag() * 32768.0f);
m_SSBFilterBufferIndex++;
calculateLevel(m_modSample);
}
else
{
m_modSample.real(0.0f);
m_modSample.imag(0.0f);
}
}
else if ((m_running.m_sampleFormat == FormatLSB) || (m_running.m_sampleFormat == FormatUSB))
{
Sample s;
Complex c, ci;
fftfilt::cmplx *filtered;
int n_out = 0;
m_udpHandler.readSample(s);
uint64_t magsq = s.m_real * s.m_real + s.m_imag * s.m_imag;
m_inMovingAverage.feed(magsq/1073741824.0);
m_inMagsq = m_inMovingAverage.average();
calculateSquelch(m_inMagsq);
if (m_squelchOpen)
{
ci.real((s.m_real / 32768.0f) * m_running.m_gain);
ci.imag((s.m_imag / 32768.0f) * m_running.m_gain);
n_out = m_SSBFilter->runSSB(ci, &filtered, (m_running.m_sampleFormat == FormatUSB));
if (n_out > 0)

View File

@ -38,12 +38,9 @@ public:
enum SampleFormat {
FormatS16LE,
FormatNFM,
FormatNFMMono,
FormatLSB,
FormatUSB,
FormatLSBMono,
FormatUSBMono,
FormatAMMono,
FormatAM,
FormatNone
};
@ -385,6 +382,21 @@ private:
m_squelchCloseCount = 0;
}
}
inline void readMonoSample(FixReal& t)
{
Sample s;
if (m_running.m_stereoInput)
{
m_udpHandler.readSample(s);
t = (s.m_real + s.m_imag) / 2;
}
else
{
m_udpHandler.readSample(t);
}
}
};

View File

@ -127,34 +127,10 @@ bool UDPSinkGUI::deserialize(const QByteArray& data)
m_channelMarker.setCenterFrequency(s32tmp);
d.readS32(3, &s32tmp, UDPSink::FormatS16LE);
switch(s32tmp) {
case UDPSink::FormatS16LE:
ui->sampleFormat->setCurrentIndex(0);
break;
case UDPSink::FormatNFM:
ui->sampleFormat->setCurrentIndex(1);
break;
case UDPSink::FormatNFMMono:
ui->sampleFormat->setCurrentIndex(2);
break;
case UDPSink::FormatLSB:
ui->sampleFormat->setCurrentIndex(3);
break;
case UDPSink::FormatUSB:
ui->sampleFormat->setCurrentIndex(4);
break;
case UDPSink::FormatLSBMono:
ui->sampleFormat->setCurrentIndex(5);
break;
case UDPSink::FormatUSBMono:
ui->sampleFormat->setCurrentIndex(6);
break;
case UDPSink::FormatAMMono:
ui->sampleFormat->setCurrentIndex(7);
break;
default:
ui->sampleFormat->setCurrentIndex(0);
break;
if (s32tmp < (int) UDPSink::FormatNone) {
ui->sampleFormat->setCurrentIndex(s32tmp);
} else {
ui->sampleFormat->setCurrentIndex(((int) UDPSink::FormatNone) - 1);
}
d.readReal(4, &realtmp, 48000);
ui->sampleRate->setText(QString("%1").arg(realtmp, 0));
@ -362,38 +338,34 @@ void UDPSinkGUI::applySettings(bool force)
case 0:
sampleFormat = UDPSink::FormatS16LE;
ui->fmDeviation->setEnabled(false);
ui->stereoInput->setChecked(true);
ui->stereoInput->setEnabled(false);
break;
case 1:
sampleFormat = UDPSink::FormatNFM;
ui->fmDeviation->setEnabled(true);
ui->stereoInput->setEnabled(true);
break;
case 2:
sampleFormat = UDPSink::FormatNFMMono;
ui->fmDeviation->setEnabled(true);
break;
case 3:
sampleFormat = UDPSink::FormatLSB;
ui->fmDeviation->setEnabled(false);
ui->stereoInput->setEnabled(true);
break;
case 4:
case 3:
sampleFormat = UDPSink::FormatUSB;
ui->fmDeviation->setEnabled(false);
ui->stereoInput->setEnabled(true);
break;
case 5:
sampleFormat = UDPSink::FormatLSBMono;
ui->fmDeviation->setEnabled(false);
break;
case 6:
sampleFormat = UDPSink::FormatUSBMono;
ui->fmDeviation->setEnabled(false);
break;
case 7:
sampleFormat = UDPSink::FormatAMMono;
case 4:
sampleFormat = UDPSink::FormatAM;
ui->fmDeviation->setEnabled(false);
ui->stereoInput->setEnabled(true);
break;
default:
sampleFormat = UDPSink::FormatS16LE;
ui->fmDeviation->setEnabled(false);
ui->stereoInput->setChecked(true);
ui->stereoInput->setEnabled(false);
break;
}
@ -445,13 +417,13 @@ void UDPSinkGUI::on_deltaFrequency_changed(qint64 value)
void UDPSinkGUI::on_sampleFormat_currentIndexChanged(int index)
{
if ((index == (int) UDPSink::FormatNFM) || (index == (int) UDPSink::FormatNFMMono)) {
if ((index == (int) UDPSink::FormatNFM)) {
ui->fmDeviation->setEnabled(true);
} else {
ui->fmDeviation->setEnabled(false);
}
if (index == (int) UDPSink::FormatAMMono) {
if (index == (int) UDPSink::FormatAM) {
ui->amModPercent->setEnabled(true);
} else {
ui->amModPercent->setEnabled(false);

View File

@ -275,11 +275,6 @@
<string>S16LE NFM</string>
</property>
</item>
<item>
<property name="text">
<string>S16LE NFM Mono</string>
</property>
</item>
<item>
<property name="text">
<string>S16LE LSB</string>
@ -292,17 +287,7 @@
</item>
<item>
<property name="text">
<string>S16LE LSB Mono</string>
</property>
</item>
<item>
<property name="text">
<string>S16LE USB Mono</string>
</property>
</item>
<item>
<property name="text">
<string>S16LE AM Mono</string>
<string>S16LE AM</string>
</property>
</item>
</widget>