mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-09-28 15:56:33 -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_nextS16leId = 0;
|
||||
|
||||
m_sampleBufferSSB.resize(ssbFftLen);
|
||||
TCPFilter = new fftfilt(0.01, 16.0 / 48.0, ssbFftLen);
|
||||
m_last = 0;
|
||||
m_this = 0;
|
||||
m_scale = 20000;
|
||||
m_sampleBufferSSB.resize(tcpFftLen);
|
||||
TCPFilter = new fftfilt(0.001, 16.0 / 48.0, tcpFftLen);
|
||||
// if (!TCPFilter) segfault;
|
||||
}
|
||||
|
||||
@ -51,6 +54,7 @@ void TCPSrc::feed(SampleVector::const_iterator begin, SampleVector::const_iterat
|
||||
{
|
||||
Complex ci;
|
||||
cmplx* sideband;
|
||||
Real l, r;
|
||||
|
||||
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++)
|
||||
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) {
|
||||
Complex cj(it->real() / 20000.0, it->imag() / 20000.0);
|
||||
int n_out = TCPFilter->runSSB(cj, &sideband, true);
|
||||
if (n_out) {
|
||||
for (int i = 0; i < n_out; i+=2) {
|
||||
Real one = (sideband[i].real() + sideband[i].imag()) * 0.7 * 32000.0;
|
||||
Real two = (sideband[i+1].real() + sideband[i+1].imag()) * 0.7 * 32000.0;
|
||||
m_sampleBufferSSB.push_back(Sample(one, two));
|
||||
l = (sideband[i].real() + sideband[i].imag()) * 0.7 * 32000.0;
|
||||
r = (sideband[i+1].real() + sideband[i+1].imag()) * 0.7 * 32000.0;
|
||||
m_sampleBufferSSB.push_back(Sample(l, r));
|
||||
}
|
||||
for(int i = 0; i < m_ssbSockets.count(); i++)
|
||||
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()
|
||||
@ -129,7 +157,7 @@ bool TCPSrc::handleMessage(Message* cmd)
|
||||
}
|
||||
m_interpolator.create(16, m_inputSampleRate, m_rfBandwidth / 2.1);
|
||||
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();
|
||||
return true;
|
||||
} else if(MsgTCPSrcSpectrum::match(cmd)) {
|
||||
@ -160,6 +188,8 @@ void TCPSrc::onNewConnection()
|
||||
connect(connection, SIGNAL(disconnected()), this, SLOT(onDisconnected()));
|
||||
|
||||
switch(m_sampleFormat) {
|
||||
|
||||
case FormatNFM:
|
||||
case FormatSSB: {
|
||||
quint32 id = (FormatSSB << 24) | m_nextSSBId;
|
||||
MsgTCPSrcConnection* msg = MsgTCPSrcConnection::create(true, id, connection->peerAddress(), connection->peerPort());
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "dsp/interpolator.h"
|
||||
#include "util/message.h"
|
||||
|
||||
#define ssbFftLen 2048
|
||||
#define tcpFftLen 2048
|
||||
|
||||
class QTcpServer;
|
||||
class QTcpSocket;
|
||||
@ -20,7 +20,9 @@ class TCPSrc : public SampleSink {
|
||||
public:
|
||||
enum SampleFormat {
|
||||
FormatSSB,
|
||||
FormatS16LE
|
||||
FormatNFM,
|
||||
FormatS16LE,
|
||||
FormatNone
|
||||
};
|
||||
|
||||
TCPSrc(MessageQueue* uiMessageQueue, TCPSrcGUI* tcpSrcGUI, SampleSink* spectrum);
|
||||
@ -122,6 +124,9 @@ protected:
|
||||
Real m_rfBandwidth;
|
||||
int m_tcpPort;
|
||||
|
||||
Real m_scale;
|
||||
Complex m_last, m_this;
|
||||
|
||||
NCO m_nco;
|
||||
Interpolator m_interpolator;
|
||||
Real m_sampleDistanceRemain;
|
||||
|
@ -70,9 +70,12 @@ bool TCPSrcGUI::deserialize(const QByteArray& data)
|
||||
case TCPSrc::FormatSSB:
|
||||
ui->sampleFormat->setCurrentIndex(0);
|
||||
break;
|
||||
case TCPSrc::FormatS16LE:
|
||||
case TCPSrc::FormatNFM:
|
||||
ui->sampleFormat->setCurrentIndex(1);
|
||||
break;
|
||||
case TCPSrc::FormatS16LE:
|
||||
ui->sampleFormat->setCurrentIndex(2);
|
||||
break;
|
||||
default:
|
||||
ui->sampleFormat->setCurrentIndex(0);
|
||||
break;
|
||||
@ -195,6 +198,9 @@ void TCPSrcGUI::applySettings()
|
||||
sampleFormat = TCPSrc::FormatSSB;
|
||||
break;
|
||||
case 1:
|
||||
sampleFormat = TCPSrc::FormatNFM;
|
||||
break;
|
||||
case 2:
|
||||
sampleFormat = TCPSrc::FormatS16LE;
|
||||
break;
|
||||
default:
|
||||
|
@ -46,6 +46,11 @@
|
||||
<string>S16LE SSB</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>S16LE NFM</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>S16LE I/Q</string>
|
||||
|
Loading…
Reference in New Issue
Block a user