mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-12-22 17:45:48 -05:00
Demispectrum.
This commit is contained in:
parent
bbe6d4505d
commit
fa780d9134
@ -15,7 +15,7 @@ public:
|
|||||||
|
|
||||||
void configure(MessageQueue* messageQueue, int sampleRate, int centerFrequency);
|
void configure(MessageQueue* messageQueue, int sampleRate, int centerFrequency);
|
||||||
|
|
||||||
void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool firstOfBurst);
|
void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly);
|
||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
bool handleMessage(Message* cmd);
|
bool handleMessage(Message* cmd);
|
||||||
|
@ -19,7 +19,7 @@ public:
|
|||||||
|
|
||||||
void configure(MessageQueue* msgQueue, TriggerChannel triggerChannel, Real triggerLevelHigh, Real triggerLevelLow);
|
void configure(MessageQueue* msgQueue, TriggerChannel triggerChannel, Real triggerLevelHigh, Real triggerLevelLow);
|
||||||
|
|
||||||
void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool firstOfBurst);
|
void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly);
|
||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
bool handleMessage(Message* message);
|
bool handleMessage(Message* message);
|
||||||
|
@ -16,7 +16,7 @@ public:
|
|||||||
|
|
||||||
void configure(MessageQueue* msgQueue, int fftSize, int overlapPercent, FFTWindow::Function window);
|
void configure(MessageQueue* msgQueue, int fftSize, int overlapPercent, FFTWindow::Function window);
|
||||||
|
|
||||||
void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool firstOfBurst);
|
void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly);
|
||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
bool handleMessage(Message* message);
|
bool handleMessage(Message* message);
|
||||||
|
@ -12,7 +12,7 @@ public:
|
|||||||
SampleSink();
|
SampleSink();
|
||||||
virtual ~SampleSink();
|
virtual ~SampleSink();
|
||||||
|
|
||||||
virtual void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool firstOfBurst) = 0;
|
virtual void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly) = 0;
|
||||||
virtual void start() = 0;
|
virtual void start() = 0;
|
||||||
virtual void stop() = 0;
|
virtual void stop() = 0;
|
||||||
virtual bool handleMessage(Message* cmd) = 0;
|
virtual bool handleMessage(Message* cmd) = 0;
|
||||||
|
@ -19,7 +19,7 @@ public:
|
|||||||
|
|
||||||
MessageQueue* getMessageQueue() { return &m_messageQueue; }
|
MessageQueue* getMessageQueue() { return &m_messageQueue; }
|
||||||
|
|
||||||
void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool firstOfBurst);
|
void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly);
|
||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
bool handleMessage(Message* cmd);
|
bool handleMessage(Message* cmd);
|
||||||
|
@ -57,7 +57,7 @@ void NFMDemod::configure(MessageQueue* messageQueue, Real rfBandwidth, Real afBa
|
|||||||
}
|
}
|
||||||
|
|
||||||
int framedrop = 0;
|
int framedrop = 0;
|
||||||
void NFMDemod::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool firstOfBurst)
|
void NFMDemod::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly)
|
||||||
{
|
{
|
||||||
Complex ci;
|
Complex ci;
|
||||||
bool consumed;
|
bool consumed;
|
||||||
@ -109,7 +109,7 @@ void NFMDemod::feed(SampleVector::const_iterator begin, SampleVector::const_iter
|
|||||||
m_audioBufferFill = 0;
|
m_audioBufferFill = 0;
|
||||||
|
|
||||||
if(m_sampleSink != NULL)
|
if(m_sampleSink != NULL)
|
||||||
m_sampleSink->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), firstOfBurst);
|
m_sampleSink->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), true);
|
||||||
m_sampleBuffer.clear();
|
m_sampleBuffer.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ public:
|
|||||||
|
|
||||||
void configure(MessageQueue* messageQueue, Real rfBandwidth, Real afBandwidth, Real volume, Real squelch);
|
void configure(MessageQueue* messageQueue, Real rfBandwidth, Real afBandwidth, Real volume, Real squelch);
|
||||||
|
|
||||||
void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool firstOfBurst);
|
void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly);
|
||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
bool handleMessage(Message* cmd);
|
bool handleMessage(Message* cmd);
|
||||||
|
@ -53,7 +53,7 @@ void SSBDemod::configure(MessageQueue* messageQueue, Real Bandwidth, Real volume
|
|||||||
}
|
}
|
||||||
|
|
||||||
int undersamplecount = 0;
|
int undersamplecount = 0;
|
||||||
void SSBDemod::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool firstOfBurst)
|
void SSBDemod::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly)
|
||||||
{
|
{
|
||||||
Complex ci;
|
Complex ci;
|
||||||
bool consumed;
|
bool consumed;
|
||||||
@ -88,7 +88,7 @@ void SSBDemod::feed(SampleVector::const_iterator begin, SampleVector::const_iter
|
|||||||
m_audioBufferFill = 0;
|
m_audioBufferFill = 0;
|
||||||
|
|
||||||
if(m_sampleSink != NULL)
|
if(m_sampleSink != NULL)
|
||||||
m_sampleSink->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), firstOfBurst);
|
m_sampleSink->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), true);
|
||||||
m_sampleBuffer.clear();
|
m_sampleBuffer.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ public:
|
|||||||
|
|
||||||
void configure(MessageQueue* messageQueue, Real Bandwidth, Real volume);
|
void configure(MessageQueue* messageQueue, Real Bandwidth, Real volume);
|
||||||
|
|
||||||
void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool firstOfBurst);
|
void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly);
|
||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
bool handleMessage(Message* cmd);
|
bool handleMessage(Message* cmd);
|
||||||
|
@ -43,7 +43,7 @@ void TCPSrc::setSpectrum(MessageQueue* messageQueue, bool enabled)
|
|||||||
cmd->submit(messageQueue, this);
|
cmd->submit(messageQueue, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TCPSrc::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool firstOfBurst)
|
void TCPSrc::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly)
|
||||||
{
|
{
|
||||||
Complex ci;
|
Complex ci;
|
||||||
bool consumed;
|
bool consumed;
|
||||||
@ -60,7 +60,7 @@ void TCPSrc::feed(SampleVector::const_iterator begin, SampleVector::const_iterat
|
|||||||
}
|
}
|
||||||
|
|
||||||
if((m_spectrum != NULL) && (m_spectrumEnabled))
|
if((m_spectrum != NULL) && (m_spectrumEnabled))
|
||||||
m_spectrum->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), firstOfBurst);
|
m_spectrum->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), positiveOnly);
|
||||||
|
|
||||||
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);
|
||||||
|
@ -26,7 +26,7 @@ public:
|
|||||||
void configure(MessageQueue* messageQueue, SampleFormat sampleFormat, Real outputSampleRate, Real rfBandwidth, int tcpPort);
|
void configure(MessageQueue* messageQueue, SampleFormat sampleFormat, Real outputSampleRate, Real rfBandwidth, int tcpPort);
|
||||||
void setSpectrum(MessageQueue* messageQueue, bool enabled);
|
void setSpectrum(MessageQueue* messageQueue, bool enabled);
|
||||||
|
|
||||||
void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool firstOfBurst);
|
void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly);
|
||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
bool handleMessage(Message* cmd);
|
bool handleMessage(Message* cmd);
|
||||||
|
@ -44,7 +44,7 @@ void TetraDemod::configure(MessageQueue* messageQueue)
|
|||||||
cmd->submit(messageQueue, this);
|
cmd->submit(messageQueue, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TetraDemod::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool firstOfBurst)
|
void TetraDemod::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly)
|
||||||
{
|
{
|
||||||
size_t count = end - begin;
|
size_t count = end - begin;
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ void TetraDemod::feed(SampleVector::const_iterator begin, SampleVector::const_it
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(m_sampleSink != NULL)
|
if(m_sampleSink != NULL)
|
||||||
m_sampleSink->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), firstOfBurst);
|
m_sampleSink->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), positiveOnly);
|
||||||
m_sampleBuffer.clear();
|
m_sampleBuffer.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ public:
|
|||||||
|
|
||||||
void configure(MessageQueue* messageQueue);
|
void configure(MessageQueue* messageQueue);
|
||||||
|
|
||||||
void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool firstOfBurst);
|
void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly);
|
||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
bool handleMessage(Message* cmd);
|
bool handleMessage(Message* cmd);
|
||||||
|
@ -23,8 +23,13 @@ void Channelizer::configure(MessageQueue* messageQueue, int sampleRate, int cent
|
|||||||
cmd->submit(messageQueue, this);
|
cmd->submit(messageQueue, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Channelizer::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool firstOfBurst)
|
void Channelizer::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly)
|
||||||
{
|
{
|
||||||
|
if(m_sampleSink == NULL) {
|
||||||
|
m_sampleBuffer.clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for(SampleVector::const_iterator sample = begin; sample != end; ++sample) {
|
for(SampleVector::const_iterator sample = begin; sample != end; ++sample) {
|
||||||
Sample s(*sample);
|
Sample s(*sample);
|
||||||
FilterStages::iterator stage = m_filterStages.begin();
|
FilterStages::iterator stage = m_filterStages.begin();
|
||||||
@ -37,9 +42,7 @@ void Channelizer::feed(SampleVector::const_iterator begin, SampleVector::const_i
|
|||||||
m_sampleBuffer.push_back(s);
|
m_sampleBuffer.push_back(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_sampleSink != NULL)
|
m_sampleSink->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), positiveOnly);
|
||||||
m_sampleSink->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), firstOfBurst);
|
|
||||||
|
|
||||||
m_sampleBuffer.clear();
|
m_sampleBuffer.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,7 +200,7 @@ void DSPEngine::work()
|
|||||||
{
|
{
|
||||||
SampleFifo* sampleFifo = m_sampleSource->getSampleFifo();
|
SampleFifo* sampleFifo = m_sampleSource->getSampleFifo();
|
||||||
size_t samplesDone = 0;
|
size_t samplesDone = 0;
|
||||||
bool firstOfBurst = true;
|
bool positiveOnly = false;
|
||||||
|
|
||||||
while((sampleFifo->fill() > 0) && (m_messageQueue.countPending() == 0) && (samplesDone < m_sampleRate)) {
|
while((sampleFifo->fill() > 0) && (m_messageQueue.countPending() == 0) && (samplesDone < m_sampleRate)) {
|
||||||
SampleVector::iterator part1begin;
|
SampleVector::iterator part1begin;
|
||||||
@ -219,7 +219,7 @@ void DSPEngine::work()
|
|||||||
imbalance(part1begin, part1end);
|
imbalance(part1begin, part1end);
|
||||||
// feed data to handlers
|
// feed data to handlers
|
||||||
for(SampleSinks::const_iterator it = m_sampleSinks.begin(); it != m_sampleSinks.end(); it++)
|
for(SampleSinks::const_iterator it = m_sampleSinks.begin(); it != m_sampleSinks.end(); it++)
|
||||||
(*it)->feed(part1begin, part1end, firstOfBurst);
|
(*it)->feed(part1begin, part1end, positiveOnly);
|
||||||
}
|
}
|
||||||
// second part of FIFO data (used when block wraps around)
|
// second part of FIFO data (used when block wraps around)
|
||||||
if(part2begin != part2end) {
|
if(part2begin != part2end) {
|
||||||
@ -230,9 +230,8 @@ void DSPEngine::work()
|
|||||||
imbalance(part2begin, part2end);
|
imbalance(part2begin, part2end);
|
||||||
// feed data to handlers
|
// feed data to handlers
|
||||||
for(SampleSinks::const_iterator it = m_sampleSinks.begin(); it != m_sampleSinks.end(); it++)
|
for(SampleSinks::const_iterator it = m_sampleSinks.begin(); it != m_sampleSinks.end(); it++)
|
||||||
(*it)->feed(part2begin, part2end, firstOfBurst);
|
(*it)->feed(part2begin, part2end, positiveOnly);
|
||||||
}
|
}
|
||||||
firstOfBurst = false;
|
|
||||||
|
|
||||||
// adjust FIFO pointers
|
// adjust FIFO pointers
|
||||||
sampleFifo->readCommit(count);
|
sampleFifo->readCommit(count);
|
||||||
|
@ -21,7 +21,7 @@ void ScopeVis::configure(MessageQueue* msgQueue, TriggerChannel triggerChannel,
|
|||||||
cmd->submit(msgQueue, this);
|
cmd->submit(msgQueue, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScopeVis::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool firstOfBurst)
|
void ScopeVis::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly)
|
||||||
{
|
{
|
||||||
while(begin < end) {
|
while(begin < end) {
|
||||||
if(m_triggerChannel == TriggerChannelI) {
|
if(m_triggerChannel == TriggerChannelI) {
|
||||||
|
@ -34,7 +34,7 @@ void SpectrumVis::configure(MessageQueue* msgQueue, int fftSize, int overlapPerc
|
|||||||
cmd->submit(msgQueue, this);
|
cmd->submit(msgQueue, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpectrumVis::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool firstOfBurst)
|
void SpectrumVis::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly)
|
||||||
{
|
{
|
||||||
// if no visualisation is set, send the samples to /dev/null
|
// if no visualisation is set, send the samples to /dev/null
|
||||||
if(m_glSpectrum == NULL)
|
if(m_glSpectrum == NULL)
|
||||||
@ -60,7 +60,15 @@ void SpectrumVis::feed(SampleVector::const_iterator begin, SampleVector::const_i
|
|||||||
Real ofs = 20.0f * log10f(1.0f / m_fftSize);
|
Real ofs = 20.0f * log10f(1.0f / m_fftSize);
|
||||||
Real mult = (10.0f / log2f(10.0f));
|
Real mult = (10.0f / log2f(10.0f));
|
||||||
const Complex* fftOut = m_fft->out();
|
const Complex* fftOut = m_fft->out();
|
||||||
for(size_t i = 0; i < m_fftSize; i++) {
|
size_t spectrumStart = 0;
|
||||||
|
|
||||||
|
if ( positiveOnly ) {
|
||||||
|
Real logZero = ofs + mult * log2f( 0 );
|
||||||
|
for(size_t i = 0; i < m_fftSize / 2; i++)
|
||||||
|
m_logPowerSpectrum[i] = logZero;
|
||||||
|
spectrumStart = m_fftSize / 2;
|
||||||
|
}
|
||||||
|
for(size_t i = spectrumStart; i < m_fftSize; i++) {
|
||||||
Complex c = fftOut[((i + (m_fftSize >> 1)) & (m_fftSize - 1))];
|
Complex c = fftOut[((i + (m_fftSize >> 1)) & (m_fftSize - 1))];
|
||||||
Real v = c.real() * c.real() + c.imag() * c.imag();
|
Real v = c.real() * c.real() + c.imag() * c.imag();
|
||||||
v = mult * log2f(v) + ofs;
|
v = mult * log2f(v) + ofs;
|
||||||
|
@ -27,9 +27,9 @@ ThreadedSampleSink::~ThreadedSampleSink()
|
|||||||
delete m_thread;
|
delete m_thread;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadedSampleSink::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool firstOfBurst)
|
void ThreadedSampleSink::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly)
|
||||||
{
|
{
|
||||||
Q_UNUSED(firstOfBurst);
|
Q_UNUSED(positiveOnly);
|
||||||
m_sampleFifo.write(begin, end);
|
m_sampleFifo.write(begin, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ bool ThreadedSampleSink::handleMessage(Message* cmd)
|
|||||||
|
|
||||||
void ThreadedSampleSink::handleData()
|
void ThreadedSampleSink::handleData()
|
||||||
{
|
{
|
||||||
bool firstOfBurst = true;
|
bool positiveOnly = false;
|
||||||
|
|
||||||
while((m_sampleFifo.fill() > 0) && (m_messageQueue.countPending() == 0)) {
|
while((m_sampleFifo.fill() > 0) && (m_messageQueue.countPending() == 0)) {
|
||||||
SampleVector::iterator part1begin;
|
SampleVector::iterator part1begin;
|
||||||
@ -68,15 +68,14 @@ void ThreadedSampleSink::handleData()
|
|||||||
if(part1begin != part1end) {
|
if(part1begin != part1end) {
|
||||||
// handle data
|
// handle data
|
||||||
if(m_sampleSink != NULL)
|
if(m_sampleSink != NULL)
|
||||||
m_sampleSink->feed(part1begin, part1end, firstOfBurst);
|
m_sampleSink->feed(part1begin, part1end, positiveOnly);
|
||||||
}
|
}
|
||||||
// second part of FIFO data (used when block wraps around)
|
// second part of FIFO data (used when block wraps around)
|
||||||
if(part2begin != part2end) {
|
if(part2begin != part2end) {
|
||||||
// handle data
|
// handle data
|
||||||
if(m_sampleSink != NULL)
|
if(m_sampleSink != NULL)
|
||||||
m_sampleSink->feed(part2begin, part2end, firstOfBurst);
|
m_sampleSink->feed(part2begin, part2end, positiveOnly);
|
||||||
}
|
}
|
||||||
firstOfBurst = false;
|
|
||||||
|
|
||||||
// adjust FIFO pointers
|
// adjust FIFO pointers
|
||||||
m_sampleFifo.readCommit(count);
|
m_sampleFifo.readCommit(count);
|
||||||
|
Loading…
Reference in New Issue
Block a user