1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-17 23:28:50 -05:00

Channel analyzer: in the scope+spectrum combo show the spectrum of the scope captured data possibly triggered and not just the free running spectrum of the channel

This commit is contained in:
f4exb 2015-07-15 01:19:39 +02:00
parent 72e461d17b
commit 347360db90
5 changed files with 45 additions and 1 deletions

View File

@ -32,6 +32,7 @@ public:
void setSampleRate(int sampleRate);
int getSampleRate() const { return m_sampleRate; }
SampleVector::const_iterator getTriggerPoint() const { return m_triggerPoint; }
private:
class MsgConfigureScopeVis : public Message {
@ -76,6 +77,7 @@ private:
bool m_triggerOneShot;
bool m_armed;
int m_sampleRate;
SampleVector::const_iterator m_triggerPoint;
bool triggerCondition(SampleVector::const_iterator& it);
};

View File

@ -17,6 +17,7 @@ public:
void configure(MessageQueue* msgQueue, int fftSize, int overlapPercent, FFTWindow::Function window);
void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly);
void feedTriggered(SampleVector::const_iterator triggerPoint, SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly);
void start();
void stop();
bool handleMessageKeep(Message* message);
@ -34,6 +35,7 @@ private:
size_t m_overlapSize;
size_t m_refillSize;
size_t m_fftBufferFill;
bool m_needMoreSamples;
GLSpectrum* m_glSpectrum;

View File

@ -30,6 +30,22 @@ void ScopeVis::configure(MessageQueue* msgQueue, TriggerChannel triggerChannel,
void ScopeVis::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly)
{
if (m_triggerChannel == TriggerFreeRun) {
m_triggerPoint = begin;
}
else if (m_triggerState == Triggered) {
m_triggerPoint = begin;
}
else if (m_triggerState == Untriggered) {
m_triggerPoint = end;
}
else if (m_triggerState == WaitForReset) {
m_triggerPoint = end;
}
else {
m_triggerPoint = begin;
}
while(begin < end)
{
if (m_triggerChannel == TriggerFreeRun)
@ -62,6 +78,7 @@ void ScopeVis::feed(SampleVector::const_iterator begin, SampleVector::const_iter
if (m_armed) {
m_triggerState = Triggered;
m_armed = false;
m_triggerPoint = begin;
break;
}
}

View File

@ -10,8 +10,9 @@ SpectrumScopeComboVis::SpectrumScopeComboVis(SpectrumVis* spectrumVis, ScopeVis*
void SpectrumScopeComboVis::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly)
{
m_spectrumVis->feed(begin, end, positiveOnly);
m_scopeVis->feed(begin, end, false);
SampleVector::const_iterator triggerPoint = m_scopeVis->getTriggerPoint();
m_spectrumVis->feedTriggered(triggerPoint, begin, end, positiveOnly);
}
void SpectrumScopeComboVis::start()

View File

@ -18,6 +18,7 @@ SpectrumVis::SpectrumVis(GLSpectrum* glSpectrum) :
m_fftBuffer(MAX_FFT_SIZE),
m_logPowerSpectrum(MAX_FFT_SIZE),
m_fftBufferFill(0),
m_needMoreSamples(false),
m_glSpectrum(glSpectrum)
{
handleConfigure(1024, 0, FFTWindow::BlackmanHarris);
@ -34,6 +35,25 @@ void SpectrumVis::configure(MessageQueue* msgQueue, int fftSize, int overlapPerc
cmd->submit(msgQueue, this);
}
void SpectrumVis::feedTriggered(SampleVector::const_iterator triggerPoint, SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly)
{
if (triggerPoint == end)
{
// the following piece of code allows to terminate the FFT that ends past the end of scope captured data
// that is the spectrum will include the captured data
// just do nothing if you want the spectrum to be included inside the scope captured data
// that is to drop the FFT that dangles past the end of captured data
if (m_needMoreSamples) {
feed(begin, end, positiveOnly);
m_needMoreSamples = false; // force finish
}
}
else
{
feed(triggerPoint, end, positiveOnly); // normal feed from trigger point
}
}
void SpectrumVis::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly)
{
// if no visualisation is set, send the samples to /dev/null
@ -94,11 +114,13 @@ void SpectrumVis::feed(SampleVector::const_iterator begin, SampleVector::const_i
// start over
m_fftBufferFill = m_overlapSize;
m_needMoreSamples = false;
} else {
// not enough samples for FFT - just fill in new data and return
for(std::vector<Complex>::iterator it = m_fftBuffer.begin() + m_fftBufferFill; begin < end; ++begin)
*it++ = Complex(begin->real() / 32768.0, begin->imag() / 32768.0);
m_fftBufferFill += todo;
m_needMoreSamples = true;
}
}
}