mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-02-03 09:44:01 -05:00
UDP source: moved samples format enum to settings class
This commit is contained in:
parent
d0f07f0ccd
commit
e3284760f8
@ -111,7 +111,7 @@ UDPSrc::~UDPSrc()
|
||||
|
||||
/** what needs the "apply" button validation */
|
||||
void UDPSrc::configure(MessageQueue* messageQueue,
|
||||
SampleFormat sampleFormat,
|
||||
UDPSrcSettings::SampleFormat sampleFormat,
|
||||
Real outputSampleRate,
|
||||
Real rfBandwidth,
|
||||
int fmDeviation,
|
||||
@ -182,9 +182,9 @@ void UDPSrc::feed(const SampleVector::const_iterator& begin, const SampleVector:
|
||||
double agcFactor = 1.0;
|
||||
|
||||
if ((m_running.m_agc) &&
|
||||
(m_running.m_sampleFormat != FormatNFM) &&
|
||||
(m_running.m_sampleFormat != FormatNFMMono) &&
|
||||
(m_running.m_sampleFormat != FormatS16LE))
|
||||
(m_running.m_sampleFormat != UDPSrcSettings::FormatNFM) &&
|
||||
(m_running.m_sampleFormat != UDPSrcSettings::FormatNFMMono) &&
|
||||
(m_running.m_sampleFormat != UDPSrcSettings::FormatS16LE))
|
||||
{
|
||||
agcFactor = m_agc.feedAndGetValue(ci);
|
||||
inMagSq = m_agc.getMagSq();
|
||||
@ -204,7 +204,7 @@ void UDPSrc::feed(const SampleVector::const_iterator& begin, const SampleVector:
|
||||
|
||||
calculateSquelch(m_inMagsq);
|
||||
|
||||
if (m_running.m_sampleFormat == FormatLSB) // binaural LSB
|
||||
if (m_running.m_sampleFormat == UDPSrcSettings::FormatLSB) // binaural LSB
|
||||
{
|
||||
ci *= agcFactor;
|
||||
int n_out = UDPFilter->runSSB(ci, &sideband, false);
|
||||
@ -220,7 +220,7 @@ void UDPSrc::feed(const SampleVector::const_iterator& begin, const SampleVector:
|
||||
}
|
||||
}
|
||||
}
|
||||
if (m_running.m_sampleFormat == FormatUSB) // binaural USB
|
||||
if (m_running.m_sampleFormat == UDPSrcSettings::FormatUSB) // binaural USB
|
||||
{
|
||||
ci *= agcFactor;
|
||||
int n_out = UDPFilter->runSSB(ci, &sideband, true);
|
||||
@ -236,19 +236,19 @@ void UDPSrc::feed(const SampleVector::const_iterator& begin, const SampleVector:
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (m_running.m_sampleFormat == FormatNFM)
|
||||
else if (m_running.m_sampleFormat == UDPSrcSettings::FormatNFM)
|
||||
{
|
||||
double demod = m_squelchOpen ? 32768.0 * m_phaseDiscri.phaseDiscriminator(ci) * m_running.m_gain : 0;
|
||||
m_udpBuffer->write(Sample(demod, demod));
|
||||
m_outMovingAverage.feed((demod * demod) / (1<<30));
|
||||
}
|
||||
else if (m_running.m_sampleFormat == FormatNFMMono)
|
||||
else if (m_running.m_sampleFormat == UDPSrcSettings::FormatNFMMono)
|
||||
{
|
||||
FixReal demod = m_squelchOpen ? (FixReal) (32768.0f * m_phaseDiscri.phaseDiscriminator(ci) * m_running.m_gain) : 0;
|
||||
m_udpBufferMono->write(demod);
|
||||
m_outMovingAverage.feed((demod * demod) / 1073741824.0);
|
||||
}
|
||||
else if (m_running.m_sampleFormat == FormatLSBMono) // Monaural LSB
|
||||
else if (m_running.m_sampleFormat == UDPSrcSettings::FormatLSBMono) // Monaural LSB
|
||||
{
|
||||
ci *= agcFactor;
|
||||
int n_out = UDPFilter->runSSB(ci, &sideband, false);
|
||||
@ -263,7 +263,7 @@ void UDPSrc::feed(const SampleVector::const_iterator& begin, const SampleVector:
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (m_running.m_sampleFormat == FormatUSBMono) // Monaural USB
|
||||
else if (m_running.m_sampleFormat == UDPSrcSettings::FormatUSBMono) // Monaural USB
|
||||
{
|
||||
ci *= agcFactor;
|
||||
int n_out = UDPFilter->runSSB(ci, &sideband, true);
|
||||
@ -278,13 +278,13 @@ void UDPSrc::feed(const SampleVector::const_iterator& begin, const SampleVector:
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (m_running.m_sampleFormat == FormatAMMono)
|
||||
else if (m_running.m_sampleFormat == UDPSrcSettings::FormatAMMono)
|
||||
{
|
||||
FixReal demod = m_squelchOpen ? (FixReal) (sqrt(inMagSq) * agcFactor * m_running.m_gain) : 0;
|
||||
m_udpBufferMono->write(demod);
|
||||
m_outMovingAverage.feed((demod * demod) / 1073741824.0);
|
||||
}
|
||||
else if (m_running.m_sampleFormat == FormatAMNoDCMono)
|
||||
else if (m_running.m_sampleFormat == UDPSrcSettings::FormatAMNoDCMono)
|
||||
{
|
||||
if (m_squelchOpen)
|
||||
{
|
||||
@ -300,7 +300,7 @@ void UDPSrc::feed(const SampleVector::const_iterator& begin, const SampleVector:
|
||||
m_outMovingAverage.feed(0);
|
||||
}
|
||||
}
|
||||
else if (m_running.m_sampleFormat == FormatAMBPFMono)
|
||||
else if (m_running.m_sampleFormat == UDPSrcSettings::FormatAMBPFMono)
|
||||
{
|
||||
if (m_squelchOpen)
|
||||
{
|
||||
@ -471,10 +471,10 @@ void UDPSrc::apply(bool force)
|
||||
m_interpolator.create(16, m_config.m_inputSampleRate, m_config.m_rfBandwidth / 2.0);
|
||||
m_sampleDistanceRemain = m_config.m_inputSampleRate / m_config.m_outputSampleRate;
|
||||
|
||||
if ((m_config.m_sampleFormat == FormatLSB) ||
|
||||
(m_config.m_sampleFormat == FormatLSBMono) ||
|
||||
(m_config.m_sampleFormat == FormatUSB) ||
|
||||
(m_config.m_sampleFormat == FormatUSBMono))
|
||||
if ((m_config.m_sampleFormat == UDPSrcSettings::FormatLSB) ||
|
||||
(m_config.m_sampleFormat == UDPSrcSettings::FormatLSBMono) ||
|
||||
(m_config.m_sampleFormat == UDPSrcSettings::FormatUSB) ||
|
||||
(m_config.m_sampleFormat == UDPSrcSettings::FormatUSBMono))
|
||||
{
|
||||
m_squelchGate = m_config.m_outputSampleRate * 0.05;
|
||||
}
|
||||
@ -511,10 +511,10 @@ void UDPSrc::apply(bool force)
|
||||
|
||||
if ((m_config.m_squelchGate != m_running.m_squelchGate) || force)
|
||||
{
|
||||
if ((m_config.m_sampleFormat == FormatLSB) ||
|
||||
(m_config.m_sampleFormat == FormatLSBMono) ||
|
||||
(m_config.m_sampleFormat == FormatUSB) ||
|
||||
(m_config.m_sampleFormat == FormatUSBMono))
|
||||
if ((m_config.m_sampleFormat == UDPSrcSettings::FormatLSB) ||
|
||||
(m_config.m_sampleFormat == UDPSrcSettings::FormatLSBMono) ||
|
||||
(m_config.m_sampleFormat == UDPSrcSettings::FormatUSB) ||
|
||||
(m_config.m_sampleFormat == UDPSrcSettings::FormatUSBMono))
|
||||
{
|
||||
m_squelchGate = m_config.m_outputSampleRate * 0.05;
|
||||
}
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "util/message.h"
|
||||
#include "audio/audiofifo.h"
|
||||
|
||||
#include "udpsrcsettings.h"
|
||||
|
||||
class QUdpSocket;
|
||||
class DeviceSourceAPI;
|
||||
@ -65,26 +66,26 @@ public:
|
||||
{ }
|
||||
};
|
||||
|
||||
enum SampleFormat {
|
||||
FormatS16LE,
|
||||
FormatNFM,
|
||||
FormatNFMMono,
|
||||
FormatLSB,
|
||||
FormatUSB,
|
||||
FormatLSBMono,
|
||||
FormatUSBMono,
|
||||
FormatAMMono,
|
||||
FormatAMNoDCMono,
|
||||
FormatAMBPFMono,
|
||||
FormatNone
|
||||
};
|
||||
// enum SampleFormat {
|
||||
// FormatS16LE,
|
||||
// FormatNFM,
|
||||
// FormatNFMMono,
|
||||
// FormatLSB,
|
||||
// FormatUSB,
|
||||
// FormatLSBMono,
|
||||
// FormatUSBMono,
|
||||
// FormatAMMono,
|
||||
// FormatAMNoDCMono,
|
||||
// FormatAMBPFMono,
|
||||
// FormatNone
|
||||
// };
|
||||
|
||||
UDPSrc(DeviceSourceAPI *deviceAPI);
|
||||
virtual ~UDPSrc();
|
||||
void setSpectrum(BasebandSampleSink* spectrum) { m_spectrum = spectrum; }
|
||||
|
||||
void configure(MessageQueue* messageQueue,
|
||||
SampleFormat sampleFormat,
|
||||
UDPSrcSettings::SampleFormat sampleFormat,
|
||||
Real outputSampleRate,
|
||||
Real rfBandwidth,
|
||||
int fmDeviation,
|
||||
@ -122,7 +123,7 @@ protected:
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
SampleFormat getSampleFormat() const { return m_sampleFormat; }
|
||||
UDPSrcSettings::SampleFormat getSampleFormat() const { return m_sampleFormat; }
|
||||
Real getOutputSampleRate() const { return m_outputSampleRate; }
|
||||
Real getRFBandwidth() const { return m_rfBandwidth; }
|
||||
int getFMDeviation() const { return m_fmDeviation; }
|
||||
@ -131,7 +132,7 @@ protected:
|
||||
int getAudioPort() const { return m_audioPort; }
|
||||
bool getForce() const { return m_force; }
|
||||
|
||||
static MsgUDPSrcConfigure* create(SampleFormat
|
||||
static MsgUDPSrcConfigure* create(UDPSrcSettings::SampleFormat
|
||||
sampleFormat,
|
||||
Real sampleRate,
|
||||
Real rfBandwidth,
|
||||
@ -152,7 +153,7 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
SampleFormat m_sampleFormat;
|
||||
UDPSrcSettings::SampleFormat m_sampleFormat;
|
||||
Real m_outputSampleRate;
|
||||
Real m_rfBandwidth;
|
||||
int m_fmDeviation;
|
||||
@ -161,7 +162,7 @@ protected:
|
||||
int m_audioPort;
|
||||
bool m_force;
|
||||
|
||||
MsgUDPSrcConfigure(SampleFormat sampleFormat,
|
||||
MsgUDPSrcConfigure(UDPSrcSettings::SampleFormat sampleFormat,
|
||||
Real outputSampleRate,
|
||||
Real rfBandwidth,
|
||||
int fmDeviation,
|
||||
@ -274,7 +275,7 @@ protected:
|
||||
|
||||
struct Config {
|
||||
Real m_outputSampleRate;
|
||||
SampleFormat m_sampleFormat;
|
||||
UDPSrcSettings::SampleFormat m_sampleFormat;
|
||||
Real m_inputSampleRate;
|
||||
qint64 m_inputFrequencyOffset;
|
||||
Real m_rfBandwidth;
|
||||
@ -295,7 +296,7 @@ protected:
|
||||
|
||||
Config() :
|
||||
m_outputSampleRate(48000),
|
||||
m_sampleFormat(FormatS16LE),
|
||||
m_sampleFormat(UDPSrcSettings::FormatS16LE),
|
||||
m_inputSampleRate(48000),
|
||||
m_inputFrequencyOffset(0),
|
||||
m_rfBandwidth(12500),
|
||||
|
@ -132,36 +132,36 @@ bool UDPSrcGUI::deserialize(const QByteArray& data)
|
||||
|
||||
d.readS32(2, &s32tmp, 0);
|
||||
m_channelMarker.setCenterFrequency(s32tmp);
|
||||
d.readS32(3, &s32tmp, UDPSrc::FormatS16LE);
|
||||
d.readS32(3, &s32tmp, UDPSrcSettings::FormatS16LE);
|
||||
switch(s32tmp) {
|
||||
case UDPSrc::FormatS16LE:
|
||||
case UDPSrcSettings::FormatS16LE:
|
||||
ui->sampleFormat->setCurrentIndex(0);
|
||||
break;
|
||||
case UDPSrc::FormatNFM:
|
||||
case UDPSrcSettings::FormatNFM:
|
||||
ui->sampleFormat->setCurrentIndex(1);
|
||||
break;
|
||||
case UDPSrc::FormatNFMMono:
|
||||
case UDPSrcSettings::FormatNFMMono:
|
||||
ui->sampleFormat->setCurrentIndex(2);
|
||||
break;
|
||||
case UDPSrc::FormatLSB:
|
||||
case UDPSrcSettings::FormatLSB:
|
||||
ui->sampleFormat->setCurrentIndex(3);
|
||||
break;
|
||||
case UDPSrc::FormatUSB:
|
||||
case UDPSrcSettings::FormatUSB:
|
||||
ui->sampleFormat->setCurrentIndex(4);
|
||||
break;
|
||||
case UDPSrc::FormatLSBMono:
|
||||
case UDPSrcSettings::FormatLSBMono:
|
||||
ui->sampleFormat->setCurrentIndex(5);
|
||||
break;
|
||||
case UDPSrc::FormatUSBMono:
|
||||
case UDPSrcSettings::FormatUSBMono:
|
||||
ui->sampleFormat->setCurrentIndex(6);
|
||||
break;
|
||||
case UDPSrc::FormatAMMono:
|
||||
case UDPSrcSettings::FormatAMMono:
|
||||
ui->sampleFormat->setCurrentIndex(7);
|
||||
break;
|
||||
case UDPSrc::FormatAMNoDCMono:
|
||||
case UDPSrcSettings::FormatAMNoDCMono:
|
||||
ui->sampleFormat->setCurrentIndex(8);
|
||||
break;
|
||||
case UDPSrc::FormatAMBPFMono:
|
||||
case UDPSrcSettings::FormatAMBPFMono:
|
||||
ui->sampleFormat->setCurrentIndex(9);
|
||||
break;
|
||||
default:
|
||||
@ -294,6 +294,9 @@ UDPSrcGUI::UDPSrcGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidget*
|
||||
m_channelMarker.setUDPReceivePort(9998);
|
||||
m_channelMarker.setVisible(true);
|
||||
|
||||
m_settings.setChannelMarker(&m_channelMarker);
|
||||
m_settings.setSpectrumGUI(ui->spectrumGUI);
|
||||
|
||||
connect(&m_channelMarker, SIGNAL(changed()), this, SLOT(channelMarkerChanged()));
|
||||
|
||||
m_deviceAPI->registerChannelInstance(m_channelID, this);
|
||||
@ -393,52 +396,52 @@ void UDPSrcGUI::applySettings(bool force)
|
||||
outputSampleRate, m_channelMarker.getCenterFrequency());
|
||||
m_udpSrc->getInputMessageQueue()->push(channelConfigMsg);
|
||||
|
||||
UDPSrc::SampleFormat sampleFormat;
|
||||
UDPSrcSettings::SampleFormat sampleFormat;
|
||||
|
||||
switch(ui->sampleFormat->currentIndex())
|
||||
{
|
||||
case 0:
|
||||
sampleFormat = UDPSrc::FormatS16LE;
|
||||
sampleFormat = UDPSrcSettings::FormatS16LE;
|
||||
ui->fmDeviation->setEnabled(false);
|
||||
break;
|
||||
case 1:
|
||||
sampleFormat = UDPSrc::FormatNFM;
|
||||
sampleFormat = UDPSrcSettings::FormatNFM;
|
||||
ui->fmDeviation->setEnabled(true);
|
||||
break;
|
||||
case 2:
|
||||
sampleFormat = UDPSrc::FormatNFMMono;
|
||||
sampleFormat = UDPSrcSettings::FormatNFMMono;
|
||||
ui->fmDeviation->setEnabled(true);
|
||||
break;
|
||||
case 3:
|
||||
sampleFormat = UDPSrc::FormatLSB;
|
||||
sampleFormat = UDPSrcSettings::FormatLSB;
|
||||
ui->fmDeviation->setEnabled(false);
|
||||
break;
|
||||
case 4:
|
||||
sampleFormat = UDPSrc::FormatUSB;
|
||||
sampleFormat = UDPSrcSettings::FormatUSB;
|
||||
ui->fmDeviation->setEnabled(false);
|
||||
break;
|
||||
case 5:
|
||||
sampleFormat = UDPSrc::FormatLSBMono;
|
||||
sampleFormat = UDPSrcSettings::FormatLSBMono;
|
||||
ui->fmDeviation->setEnabled(false);
|
||||
break;
|
||||
case 6:
|
||||
sampleFormat = UDPSrc::FormatUSBMono;
|
||||
sampleFormat = UDPSrcSettings::FormatUSBMono;
|
||||
ui->fmDeviation->setEnabled(false);
|
||||
break;
|
||||
case 7:
|
||||
sampleFormat = UDPSrc::FormatAMMono;
|
||||
sampleFormat = UDPSrcSettings::FormatAMMono;
|
||||
ui->fmDeviation->setEnabled(false);
|
||||
break;
|
||||
case 8:
|
||||
sampleFormat = UDPSrc::FormatAMNoDCMono;
|
||||
sampleFormat = UDPSrcSettings::FormatAMNoDCMono;
|
||||
ui->fmDeviation->setEnabled(false);
|
||||
break;
|
||||
case 9:
|
||||
sampleFormat = UDPSrc::FormatAMBPFMono;
|
||||
sampleFormat = UDPSrcSettings::FormatAMBPFMono;
|
||||
ui->fmDeviation->setEnabled(false);
|
||||
break;
|
||||
default:
|
||||
sampleFormat = UDPSrc::FormatS16LE;
|
||||
sampleFormat = UDPSrcSettings::FormatS16LE;
|
||||
ui->fmDeviation->setEnabled(false);
|
||||
break;
|
||||
}
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "util/messagequeue.h"
|
||||
|
||||
#include "udpsrc.h"
|
||||
#include "udpsrcsettings.h"
|
||||
|
||||
class PluginAPI;
|
||||
class DeviceSourceAPI;
|
||||
@ -83,13 +84,14 @@ private:
|
||||
PluginAPI* m_pluginAPI;
|
||||
DeviceSourceAPI* m_deviceAPI;
|
||||
UDPSrc* m_udpSrc;
|
||||
UDPSrcSettings m_settings;
|
||||
ChannelMarker m_channelMarker;
|
||||
MovingAverage<double> m_channelPowerAvg;
|
||||
MovingAverage<double> m_inPowerAvg;
|
||||
uint32_t m_tickCount;
|
||||
|
||||
// settings
|
||||
UDPSrc::SampleFormat m_sampleFormat;
|
||||
UDPSrcSettings::SampleFormat m_sampleFormat;
|
||||
Real m_outputSampleRate;
|
||||
Real m_rfBandwidth;
|
||||
int m_fmDeviation;
|
||||
|
Loading…
Reference in New Issue
Block a user