mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-09-19 23:18:04 -04:00
TCP NFM.
This commit is contained in:
parent
a7bc5d649e
commit
64de524abc
@ -26,8 +26,11 @@ TCPSrc::TCPSrc(MessageQueue* uiMessageQueue, TCPSrcGUI* tcpSrcGUI, SampleSink* s
|
|||||||
m_nextSSBId = 0;
|
m_nextSSBId = 0;
|
||||||
m_nextS16leId = 0;
|
m_nextS16leId = 0;
|
||||||
|
|
||||||
m_sampleBufferSSB.resize(ssbFftLen);
|
m_last = 0;
|
||||||
TCPFilter = new fftfilt(0.01, 16.0 / 48.0, ssbFftLen);
|
m_this = 0;
|
||||||
|
m_scale = 20000;
|
||||||
|
m_sampleBufferSSB.resize(tcpFftLen);
|
||||||
|
TCPFilter = new fftfilt(0.001, 16.0 / 48.0, tcpFftLen);
|
||||||
// if (!TCPFilter) segfault;
|
// if (!TCPFilter) segfault;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,6 +54,7 @@ void TCPSrc::feed(SampleVector::const_iterator begin, SampleVector::const_iterat
|
|||||||
{
|
{
|
||||||
Complex ci;
|
Complex ci;
|
||||||
cmplx* sideband;
|
cmplx* sideband;
|
||||||
|
Real l, r;
|
||||||
|
|
||||||
m_sampleBuffer.clear();
|
m_sampleBuffer.clear();
|
||||||
|
|
||||||
@ -70,15 +74,15 @@ void TCPSrc::feed(SampleVector::const_iterator begin, SampleVector::const_iterat
|
|||||||
for(int i = 0; i < m_s16leSockets.count(); i++)
|
for(int i = 0; i < m_s16leSockets.count(); i++)
|
||||||
m_s16leSockets[i].socket->write((const char*)&m_sampleBuffer[0], m_sampleBuffer.size() * 4);
|
m_s16leSockets[i].socket->write((const char*)&m_sampleBuffer[0], m_sampleBuffer.size() * 4);
|
||||||
|
|
||||||
if(m_ssbSockets.count() > 0) {
|
if((m_sampleFormat == FormatSSB) && (m_ssbSockets.count() > 0)) {
|
||||||
for(SampleVector::const_iterator it = m_sampleBuffer.begin(); it != m_sampleBuffer.end(); ++it) {
|
for(SampleVector::const_iterator it = m_sampleBuffer.begin(); it != m_sampleBuffer.end(); ++it) {
|
||||||
Complex cj(it->real() / 20000.0, it->imag() / 20000.0);
|
Complex cj(it->real() / 20000.0, it->imag() / 20000.0);
|
||||||
int n_out = TCPFilter->runSSB(cj, &sideband, true);
|
int n_out = TCPFilter->runSSB(cj, &sideband, true);
|
||||||
if (n_out) {
|
if (n_out) {
|
||||||
for (int i = 0; i < n_out; i+=2) {
|
for (int i = 0; i < n_out; i+=2) {
|
||||||
Real one = (sideband[i].real() + sideband[i].imag()) * 0.7 * 32000.0;
|
l = (sideband[i].real() + sideband[i].imag()) * 0.7 * 32000.0;
|
||||||
Real two = (sideband[i+1].real() + sideband[i+1].imag()) * 0.7 * 32000.0;
|
r = (sideband[i+1].real() + sideband[i+1].imag()) * 0.7 * 32000.0;
|
||||||
m_sampleBufferSSB.push_back(Sample(one, two));
|
m_sampleBufferSSB.push_back(Sample(l, r));
|
||||||
}
|
}
|
||||||
for(int i = 0; i < m_ssbSockets.count(); i++)
|
for(int i = 0; i < m_ssbSockets.count(); i++)
|
||||||
m_ssbSockets[i].socket->write((const char*)&m_sampleBufferSSB[0], n_out * 2);
|
m_ssbSockets[i].socket->write((const char*)&m_sampleBufferSSB[0], n_out * 2);
|
||||||
@ -86,6 +90,30 @@ void TCPSrc::feed(SampleVector::const_iterator begin, SampleVector::const_iterat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if((m_sampleFormat == FormatNFM) && (m_ssbSockets.count() > 0)) {
|
||||||
|
for(SampleVector::const_iterator it = m_sampleBuffer.begin(); it != m_sampleBuffer.end(); ++it) {
|
||||||
|
Complex cj(it->real() / 20000.0, it->imag() / 20000.0);
|
||||||
|
int n_out = TCPFilter->runFilt(cj, &sideband);
|
||||||
|
if (n_out) {
|
||||||
|
Real sum = 1.0;
|
||||||
|
for (int i = 0; i < n_out; i+=2) {
|
||||||
|
l = m_this.real() * (m_last.imag() - sideband[i].imag())
|
||||||
|
- m_this.imag() * (m_last.real() - sideband[i].real());
|
||||||
|
m_last = sideband[i];
|
||||||
|
r = m_last.real() * (m_this.imag() - sideband[i+1].imag())
|
||||||
|
- m_last.imag() * (m_this.real() - sideband[i+1].real());
|
||||||
|
m_this = sideband[i+1];
|
||||||
|
m_sampleBufferSSB.push_back(Sample(l * m_scale, r * m_scale));
|
||||||
|
sum += m_this.real() * m_this.real() + m_this.imag() * m_this.imag();
|
||||||
|
}
|
||||||
|
m_scale = 0.8 * m_scale + 0.2 * 20000 * tcpFftLen / sum;
|
||||||
|
for(int i = 0; i < m_ssbSockets.count(); i++)
|
||||||
|
m_ssbSockets[i].socket->write((const char*)&m_sampleBufferSSB[0], n_out * 2);
|
||||||
|
m_sampleBufferSSB.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TCPSrc::start()
|
void TCPSrc::start()
|
||||||
@ -129,7 +157,7 @@ bool TCPSrc::handleMessage(Message* cmd)
|
|||||||
}
|
}
|
||||||
m_interpolator.create(16, m_inputSampleRate, m_rfBandwidth / 2.1);
|
m_interpolator.create(16, m_inputSampleRate, m_rfBandwidth / 2.1);
|
||||||
m_sampleDistanceRemain = m_inputSampleRate / m_outputSampleRate;
|
m_sampleDistanceRemain = m_inputSampleRate / m_outputSampleRate;
|
||||||
TCPFilter->create_filter(0.3f / 48.0f, m_rfBandwidth / 2.0 / m_outputSampleRate);
|
TCPFilter->create_filter(0.048f / 48.0f, m_rfBandwidth / 2.0 / m_outputSampleRate);
|
||||||
cmd->completed();
|
cmd->completed();
|
||||||
return true;
|
return true;
|
||||||
} else if(MsgTCPSrcSpectrum::match(cmd)) {
|
} else if(MsgTCPSrcSpectrum::match(cmd)) {
|
||||||
@ -160,6 +188,8 @@ void TCPSrc::onNewConnection()
|
|||||||
connect(connection, SIGNAL(disconnected()), this, SLOT(onDisconnected()));
|
connect(connection, SIGNAL(disconnected()), this, SLOT(onDisconnected()));
|
||||||
|
|
||||||
switch(m_sampleFormat) {
|
switch(m_sampleFormat) {
|
||||||
|
|
||||||
|
case FormatNFM:
|
||||||
case FormatSSB: {
|
case FormatSSB: {
|
||||||
quint32 id = (FormatSSB << 24) | m_nextSSBId;
|
quint32 id = (FormatSSB << 24) | m_nextSSBId;
|
||||||
MsgTCPSrcConnection* msg = MsgTCPSrcConnection::create(true, id, connection->peerAddress(), connection->peerPort());
|
MsgTCPSrcConnection* msg = MsgTCPSrcConnection::create(true, id, connection->peerAddress(), connection->peerPort());
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#include "dsp/interpolator.h"
|
#include "dsp/interpolator.h"
|
||||||
#include "util/message.h"
|
#include "util/message.h"
|
||||||
|
|
||||||
#define ssbFftLen 2048
|
#define tcpFftLen 2048
|
||||||
|
|
||||||
class QTcpServer;
|
class QTcpServer;
|
||||||
class QTcpSocket;
|
class QTcpSocket;
|
||||||
@ -20,7 +20,9 @@ class TCPSrc : public SampleSink {
|
|||||||
public:
|
public:
|
||||||
enum SampleFormat {
|
enum SampleFormat {
|
||||||
FormatSSB,
|
FormatSSB,
|
||||||
FormatS16LE
|
FormatNFM,
|
||||||
|
FormatS16LE,
|
||||||
|
FormatNone
|
||||||
};
|
};
|
||||||
|
|
||||||
TCPSrc(MessageQueue* uiMessageQueue, TCPSrcGUI* tcpSrcGUI, SampleSink* spectrum);
|
TCPSrc(MessageQueue* uiMessageQueue, TCPSrcGUI* tcpSrcGUI, SampleSink* spectrum);
|
||||||
@ -122,6 +124,9 @@ protected:
|
|||||||
Real m_rfBandwidth;
|
Real m_rfBandwidth;
|
||||||
int m_tcpPort;
|
int m_tcpPort;
|
||||||
|
|
||||||
|
Real m_scale;
|
||||||
|
Complex m_last, m_this;
|
||||||
|
|
||||||
NCO m_nco;
|
NCO m_nco;
|
||||||
Interpolator m_interpolator;
|
Interpolator m_interpolator;
|
||||||
Real m_sampleDistanceRemain;
|
Real m_sampleDistanceRemain;
|
||||||
|
@ -70,9 +70,12 @@ bool TCPSrcGUI::deserialize(const QByteArray& data)
|
|||||||
case TCPSrc::FormatSSB:
|
case TCPSrc::FormatSSB:
|
||||||
ui->sampleFormat->setCurrentIndex(0);
|
ui->sampleFormat->setCurrentIndex(0);
|
||||||
break;
|
break;
|
||||||
case TCPSrc::FormatS16LE:
|
case TCPSrc::FormatNFM:
|
||||||
ui->sampleFormat->setCurrentIndex(1);
|
ui->sampleFormat->setCurrentIndex(1);
|
||||||
break;
|
break;
|
||||||
|
case TCPSrc::FormatS16LE:
|
||||||
|
ui->sampleFormat->setCurrentIndex(2);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
ui->sampleFormat->setCurrentIndex(0);
|
ui->sampleFormat->setCurrentIndex(0);
|
||||||
break;
|
break;
|
||||||
@ -195,6 +198,9 @@ void TCPSrcGUI::applySettings()
|
|||||||
sampleFormat = TCPSrc::FormatSSB;
|
sampleFormat = TCPSrc::FormatSSB;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
|
sampleFormat = TCPSrc::FormatNFM;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
sampleFormat = TCPSrc::FormatS16LE;
|
sampleFormat = TCPSrc::FormatS16LE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -46,6 +46,11 @@
|
|||||||
<string>S16LE SSB</string>
|
<string>S16LE SSB</string>
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>S16LE NFM</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>S16LE I/Q</string>
|
<string>S16LE I/Q</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user