mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-06-15 13:02:27 -04:00
UDP sink plugin: implemented mono/stereo input toggle
This commit is contained in:
parent
242617ba7b
commit
ff23b6eb26
@ -144,20 +144,10 @@ void UDPSink::modulateSample()
|
|||||||
m_modSample.imag(0.0f);
|
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;
|
FixReal t;
|
||||||
Sample s;
|
readMonoSample(t);
|
||||||
|
|
||||||
if (m_running.m_sampleFormat == FormatNFMMono)
|
|
||||||
{
|
|
||||||
m_udpHandler.readSample(t);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_udpHandler.readSample(s);
|
|
||||||
t = (s.m_real + s.m_imag) / 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_inMovingAverage.feed((t*t)/1073741824.0);
|
m_inMovingAverage.feed((t*t)/1073741824.0);
|
||||||
m_inMagsq = m_inMovingAverage.average();
|
m_inMagsq = m_inMovingAverage.average();
|
||||||
@ -177,10 +167,10 @@ void UDPSink::modulateSample()
|
|||||||
m_modSample.imag(0.0f);
|
m_modSample.imag(0.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (m_running.m_sampleFormat == FormatAMMono)
|
else if (m_running.m_sampleFormat == FormatAM)
|
||||||
{
|
{
|
||||||
FixReal t;
|
FixReal t;
|
||||||
m_udpHandler.readSample(t);
|
readMonoSample(t);
|
||||||
m_inMovingAverage.feed((t*t)/1073741824.0);
|
m_inMovingAverage.feed((t*t)/1073741824.0);
|
||||||
m_inMagsq = m_inMovingAverage.average();
|
m_inMagsq = m_inMovingAverage.average();
|
||||||
|
|
||||||
@ -198,14 +188,14 @@ void UDPSink::modulateSample()
|
|||||||
m_modSample.imag(0.0f);
|
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;
|
FixReal t;
|
||||||
Complex c, ci;
|
Complex c, ci;
|
||||||
fftfilt::cmplx *filtered;
|
fftfilt::cmplx *filtered;
|
||||||
int n_out = 0;
|
int n_out = 0;
|
||||||
|
|
||||||
m_udpHandler.readSample(t);
|
readMonoSample(t);
|
||||||
m_inMovingAverage.feed((t*t)/1073741824.0);
|
m_inMovingAverage.feed((t*t)/1073741824.0);
|
||||||
m_inMagsq = m_inMovingAverage.average();
|
m_inMagsq = m_inMovingAverage.average();
|
||||||
|
|
||||||
@ -216,47 +206,6 @@ void UDPSink::modulateSample()
|
|||||||
ci.real((t / 32768.0f) * m_running.m_gain);
|
ci.real((t / 32768.0f) * m_running.m_gain);
|
||||||
ci.imag(0.0f);
|
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));
|
n_out = m_SSBFilter->runSSB(ci, &filtered, (m_running.m_sampleFormat == FormatUSB));
|
||||||
|
|
||||||
if (n_out > 0)
|
if (n_out > 0)
|
||||||
|
@ -38,12 +38,9 @@ public:
|
|||||||
enum SampleFormat {
|
enum SampleFormat {
|
||||||
FormatS16LE,
|
FormatS16LE,
|
||||||
FormatNFM,
|
FormatNFM,
|
||||||
FormatNFMMono,
|
|
||||||
FormatLSB,
|
FormatLSB,
|
||||||
FormatUSB,
|
FormatUSB,
|
||||||
FormatLSBMono,
|
FormatAM,
|
||||||
FormatUSBMono,
|
|
||||||
FormatAMMono,
|
|
||||||
FormatNone
|
FormatNone
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -385,6 +382,21 @@ private:
|
|||||||
m_squelchCloseCount = 0;
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -127,34 +127,10 @@ bool UDPSinkGUI::deserialize(const QByteArray& data)
|
|||||||
m_channelMarker.setCenterFrequency(s32tmp);
|
m_channelMarker.setCenterFrequency(s32tmp);
|
||||||
|
|
||||||
d.readS32(3, &s32tmp, UDPSink::FormatS16LE);
|
d.readS32(3, &s32tmp, UDPSink::FormatS16LE);
|
||||||
switch(s32tmp) {
|
if (s32tmp < (int) UDPSink::FormatNone) {
|
||||||
case UDPSink::FormatS16LE:
|
ui->sampleFormat->setCurrentIndex(s32tmp);
|
||||||
ui->sampleFormat->setCurrentIndex(0);
|
} else {
|
||||||
break;
|
ui->sampleFormat->setCurrentIndex(((int) UDPSink::FormatNone) - 1);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
d.readReal(4, &realtmp, 48000);
|
d.readReal(4, &realtmp, 48000);
|
||||||
ui->sampleRate->setText(QString("%1").arg(realtmp, 0));
|
ui->sampleRate->setText(QString("%1").arg(realtmp, 0));
|
||||||
@ -362,38 +338,34 @@ void UDPSinkGUI::applySettings(bool force)
|
|||||||
case 0:
|
case 0:
|
||||||
sampleFormat = UDPSink::FormatS16LE;
|
sampleFormat = UDPSink::FormatS16LE;
|
||||||
ui->fmDeviation->setEnabled(false);
|
ui->fmDeviation->setEnabled(false);
|
||||||
|
ui->stereoInput->setChecked(true);
|
||||||
|
ui->stereoInput->setEnabled(false);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
sampleFormat = UDPSink::FormatNFM;
|
sampleFormat = UDPSink::FormatNFM;
|
||||||
ui->fmDeviation->setEnabled(true);
|
ui->fmDeviation->setEnabled(true);
|
||||||
|
ui->stereoInput->setEnabled(true);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
sampleFormat = UDPSink::FormatNFMMono;
|
|
||||||
ui->fmDeviation->setEnabled(true);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
sampleFormat = UDPSink::FormatLSB;
|
sampleFormat = UDPSink::FormatLSB;
|
||||||
ui->fmDeviation->setEnabled(false);
|
ui->fmDeviation->setEnabled(false);
|
||||||
|
ui->stereoInput->setEnabled(true);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 3:
|
||||||
sampleFormat = UDPSink::FormatUSB;
|
sampleFormat = UDPSink::FormatUSB;
|
||||||
ui->fmDeviation->setEnabled(false);
|
ui->fmDeviation->setEnabled(false);
|
||||||
|
ui->stereoInput->setEnabled(true);
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 4:
|
||||||
sampleFormat = UDPSink::FormatLSBMono;
|
sampleFormat = UDPSink::FormatAM;
|
||||||
ui->fmDeviation->setEnabled(false);
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
sampleFormat = UDPSink::FormatUSBMono;
|
|
||||||
ui->fmDeviation->setEnabled(false);
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
sampleFormat = UDPSink::FormatAMMono;
|
|
||||||
ui->fmDeviation->setEnabled(false);
|
ui->fmDeviation->setEnabled(false);
|
||||||
|
ui->stereoInput->setEnabled(true);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sampleFormat = UDPSink::FormatS16LE;
|
sampleFormat = UDPSink::FormatS16LE;
|
||||||
ui->fmDeviation->setEnabled(false);
|
ui->fmDeviation->setEnabled(false);
|
||||||
|
ui->stereoInput->setChecked(true);
|
||||||
|
ui->stereoInput->setEnabled(false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -445,13 +417,13 @@ void UDPSinkGUI::on_deltaFrequency_changed(qint64 value)
|
|||||||
|
|
||||||
void UDPSinkGUI::on_sampleFormat_currentIndexChanged(int index)
|
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);
|
ui->fmDeviation->setEnabled(true);
|
||||||
} else {
|
} else {
|
||||||
ui->fmDeviation->setEnabled(false);
|
ui->fmDeviation->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index == (int) UDPSink::FormatAMMono) {
|
if (index == (int) UDPSink::FormatAM) {
|
||||||
ui->amModPercent->setEnabled(true);
|
ui->amModPercent->setEnabled(true);
|
||||||
} else {
|
} else {
|
||||||
ui->amModPercent->setEnabled(false);
|
ui->amModPercent->setEnabled(false);
|
||||||
|
@ -275,11 +275,6 @@
|
|||||||
<string>S16LE NFM</string>
|
<string>S16LE NFM</string>
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>S16LE NFM Mono</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>S16LE LSB</string>
|
<string>S16LE LSB</string>
|
||||||
@ -292,17 +287,7 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>S16LE LSB Mono</string>
|
<string>S16LE AM</string>
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>S16LE USB Mono</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>S16LE AM Mono</string>
|
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user