mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-14 12:22:00 -05:00
Fixed channel analyzer rate based displays
This commit is contained in:
parent
d6154eb0eb
commit
cf198f0450
@ -31,24 +31,16 @@ ChannelAnalyzer::ChannelAnalyzer(SampleSink* sampleSink) :
|
|||||||
{
|
{
|
||||||
m_Bandwidth = 5000;
|
m_Bandwidth = 5000;
|
||||||
m_LowCutoff = 300;
|
m_LowCutoff = 300;
|
||||||
//m_volume = 2.0;
|
|
||||||
m_spanLog2 = 3;
|
m_spanLog2 = 3;
|
||||||
m_sampleRate = 96000;
|
m_sampleRate = 96000;
|
||||||
m_frequency = 0;
|
m_frequency = 0;
|
||||||
m_nco.setFreq(m_frequency, m_sampleRate);
|
m_nco.setFreq(m_frequency, m_sampleRate);
|
||||||
m_nco_test.setFreq(m_frequency, m_sampleRate);
|
m_nco_test.setFreq(m_frequency, m_sampleRate);
|
||||||
m_interpolator.create(16, m_sampleRate, 5000);
|
|
||||||
m_sampleDistanceRemain = (Real)m_sampleRate / 48000.0;
|
|
||||||
|
|
||||||
//m_audioBuffer.resize(512);
|
|
||||||
//m_audioBufferFill = 0;
|
|
||||||
m_undersampleCount = 0;
|
m_undersampleCount = 0;
|
||||||
|
|
||||||
m_usb = true;
|
m_usb = true;
|
||||||
m_ssb = true;
|
m_ssb = true;
|
||||||
SSBFilter = new fftfilt(m_LowCutoff / 48000.0, m_Bandwidth / 48000.0, ssbFftLen);
|
SSBFilter = new fftfilt(m_LowCutoff / m_sampleRate, m_Bandwidth / m_sampleRate, ssbFftLen);
|
||||||
DSBFilter = new fftfilt(m_Bandwidth / 48000.0, 2*ssbFftLen);
|
DSBFilter = new fftfilt(m_Bandwidth / m_sampleRate, 2*ssbFftLen);
|
||||||
// if (!USBFilter) segfault;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ChannelAnalyzer::~ChannelAnalyzer()
|
ChannelAnalyzer::~ChannelAnalyzer()
|
||||||
@ -69,7 +61,6 @@ void ChannelAnalyzer::configure(MessageQueue* messageQueue,
|
|||||||
|
|
||||||
void ChannelAnalyzer::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly)
|
void ChannelAnalyzer::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly)
|
||||||
{
|
{
|
||||||
Complex ci;
|
|
||||||
fftfilt::cmplx *sideband, sum;
|
fftfilt::cmplx *sideband, sum;
|
||||||
int n_out;
|
int n_out;
|
||||||
int decim = 1<<(m_spanLog2 - 1);
|
int decim = 1<<(m_spanLog2 - 1);
|
||||||
@ -79,30 +70,10 @@ void ChannelAnalyzer::feed(SampleVector::const_iterator begin, SampleVector::con
|
|||||||
Complex c(it->real() / 32768.0, it->imag() / 32768.0);
|
Complex c(it->real() / 32768.0, it->imag() / 32768.0);
|
||||||
c *= m_nco.nextIQ();
|
c *= m_nco.nextIQ();
|
||||||
|
|
||||||
/*
|
|
||||||
ci = c;
|
|
||||||
if (m_ssb) {
|
if (m_ssb) {
|
||||||
n_out = SSBFilter->runSSB(ci, &sideband, m_usb);
|
n_out = SSBFilter->runSSB(c, &sideband, m_usb);
|
||||||
} else {
|
} else {
|
||||||
n_out = DSBFilter->noFilt(ci, &sideband);
|
n_out = DSBFilter->runDSB(c, &sideband);
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
if(m_interpolator.interpolate(&m_sampleDistanceRemain, c, &ci))
|
|
||||||
{
|
|
||||||
if (m_ssb)
|
|
||||||
{
|
|
||||||
n_out = SSBFilter->runSSB(ci, &sideband, m_usb);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
n_out = DSBFilter->runDSB(ci, &sideband);
|
|
||||||
}
|
|
||||||
m_sampleDistanceRemain += (Real)m_sampleRate / 48000.0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
n_out = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < n_out; i++)
|
for (int i = 0; i < n_out; i++)
|
||||||
@ -115,14 +86,18 @@ void ChannelAnalyzer::feed(SampleVector::const_iterator begin, SampleVector::con
|
|||||||
if (!(m_undersampleCount++ & decim_mask))
|
if (!(m_undersampleCount++ & decim_mask))
|
||||||
{
|
{
|
||||||
sum /= decim;
|
sum /= decim;
|
||||||
if (m_ssb & !m_usb) { // invert spectrum for LSB
|
|
||||||
|
if (m_ssb & !m_usb)
|
||||||
|
{ // invert spectrum for LSB
|
||||||
m_sampleBuffer.push_back(Sample(sum.imag() * 32768.0, sum.real() * 32768.0));
|
m_sampleBuffer.push_back(Sample(sum.imag() * 32768.0, sum.real() * 32768.0));
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
m_sampleBuffer.push_back(Sample(sum.real() * 32768.0, sum.imag() * 32768.0));
|
m_sampleBuffer.push_back(Sample(sum.real() * 32768.0, sum.imag() * 32768.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
sum = 0;
|
sum = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,8 +126,6 @@ bool ChannelAnalyzer::handleMessage(Message* cmd)
|
|||||||
//fprintf(stderr, "%d samples/sec, %lld Hz offset", signal->getSampleRate(), signal->getFrequencyOffset());
|
//fprintf(stderr, "%d samples/sec, %lld Hz offset", signal->getSampleRate(), signal->getFrequencyOffset());
|
||||||
m_sampleRate = signal->getSampleRate();
|
m_sampleRate = signal->getSampleRate();
|
||||||
m_nco.setFreq(-signal->getFrequencyOffset(), m_sampleRate);
|
m_nco.setFreq(-signal->getFrequencyOffset(), m_sampleRate);
|
||||||
m_interpolator.create(16, m_sampleRate, m_Bandwidth);
|
|
||||||
m_sampleDistanceRemain = m_sampleRate / 48000.0;
|
|
||||||
cmd->completed();
|
cmd->completed();
|
||||||
return true;
|
return true;
|
||||||
} else if(MsgConfigureChannelAnalyzer::match(cmd)) {
|
} else if(MsgConfigureChannelAnalyzer::match(cmd)) {
|
||||||
@ -177,12 +150,9 @@ bool ChannelAnalyzer::handleMessage(Message* cmd)
|
|||||||
m_Bandwidth = band;
|
m_Bandwidth = band;
|
||||||
m_LowCutoff = lowCutoff;
|
m_LowCutoff = lowCutoff;
|
||||||
|
|
||||||
m_interpolator.create(16, m_sampleRate, band * 2.0f);
|
//m_interpolator.create(16, m_sampleRate, band * 2.0f);
|
||||||
SSBFilter->create_filter(m_LowCutoff / 48000.0f, m_Bandwidth / 48000.0f);
|
SSBFilter->create_filter(m_LowCutoff / m_sampleRate, m_Bandwidth / m_sampleRate);
|
||||||
DSBFilter->create_dsb_filter(m_Bandwidth / 48000.0f);
|
DSBFilter->create_dsb_filter(m_Bandwidth / m_sampleRate);
|
||||||
|
|
||||||
//m_volume = cfg->getVolume();
|
|
||||||
//m_volume *= m_volume * 0.1;
|
|
||||||
|
|
||||||
m_spanLog2 = cfg->getSpanLog2();
|
m_spanLog2 = cfg->getSpanLog2();
|
||||||
m_ssb = cfg->getSSB();
|
m_ssb = cfg->getSSB();
|
||||||
|
@ -41,6 +41,10 @@ public:
|
|||||||
int spanLog2,
|
int spanLog2,
|
||||||
bool ssb);
|
bool ssb);
|
||||||
|
|
||||||
|
int getSampleRate() const {
|
||||||
|
return m_sampleRate;
|
||||||
|
}
|
||||||
|
|
||||||
void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly);
|
void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly);
|
||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
@ -82,12 +86,6 @@ private:
|
|||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
//struct AudioSample {
|
|
||||||
// qint16 l;
|
|
||||||
// qint16 r;
|
|
||||||
//};
|
|
||||||
//typedef std::vector<AudioSample> AudioVector;
|
|
||||||
|
|
||||||
Real m_Bandwidth;
|
Real m_Bandwidth;
|
||||||
Real m_LowCutoff;
|
Real m_LowCutoff;
|
||||||
int m_spanLog2;
|
int m_spanLog2;
|
||||||
@ -99,17 +97,11 @@ private:
|
|||||||
|
|
||||||
NCO m_nco;
|
NCO m_nco;
|
||||||
NCO m_nco_test;
|
NCO m_nco_test;
|
||||||
Interpolator m_interpolator;
|
|
||||||
Real m_sampleDistanceRemain;
|
|
||||||
fftfilt* SSBFilter;
|
fftfilt* SSBFilter;
|
||||||
fftfilt* DSBFilter;
|
fftfilt* DSBFilter;
|
||||||
|
|
||||||
SampleSink* m_sampleSink;
|
SampleSink* m_sampleSink;
|
||||||
SampleVector m_sampleBuffer;
|
SampleVector m_sampleBuffer;
|
||||||
|
|
||||||
//AudioVector m_audioBuffer;
|
|
||||||
//uint m_audioBufferFill;
|
|
||||||
//AudioFifo* m_audioFifo;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INCLUDE_CHANALYZER_H
|
#endif // INCLUDE_CHANALYZER_H
|
||||||
|
@ -128,10 +128,17 @@ void ChannelAnalyzerGUI::on_BW_valueChanged(int value)
|
|||||||
ui->BWText->setText(tr("%1k").arg(s));
|
ui->BWText->setText(tr("%1k").arg(s));
|
||||||
m_channelMarker->setBandwidth(value * 100 * 2);
|
m_channelMarker->setBandwidth(value * 100 * 2);
|
||||||
|
|
||||||
if (value < 0) {
|
if (ui->ssb->isChecked())
|
||||||
m_channelMarker->setSidebands(ChannelMarker::lsb);
|
{
|
||||||
} else {
|
if (value < 0) {
|
||||||
m_channelMarker->setSidebands(ChannelMarker::usb);
|
m_channelMarker->setSidebands(ChannelMarker::lsb);
|
||||||
|
} else {
|
||||||
|
m_channelMarker->setSidebands(ChannelMarker::usb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_channelMarker->setSidebands(ChannelMarker::dsb);
|
||||||
}
|
}
|
||||||
|
|
||||||
on_lowCut_valueChanged(m_channelMarker->getLowCutoff()/100);
|
on_lowCut_valueChanged(m_channelMarker->getLowCutoff()/100);
|
||||||
@ -282,12 +289,13 @@ ChannelAnalyzerGUI::~ChannelAnalyzerGUI()
|
|||||||
|
|
||||||
bool ChannelAnalyzerGUI::setNewRate(int spanLog2)
|
bool ChannelAnalyzerGUI::setNewRate(int spanLog2)
|
||||||
{
|
{
|
||||||
if ((spanLog2 < 1) || (spanLog2 > 5)) {
|
if ((spanLog2 < 1) || (spanLog2 > 6)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_spanLog2 = spanLog2;
|
m_spanLog2 = spanLog2;
|
||||||
m_rate = 48000 / (1<<spanLog2);
|
//m_rate = 48000 / (1<<spanLog2);
|
||||||
|
m_rate = m_channelAnalyzer->getSampleRate() / (1<<spanLog2);
|
||||||
|
|
||||||
if (ui->BW->value() < -m_rate/100) {
|
if (ui->BW->value() < -m_rate/100) {
|
||||||
ui->BW->setValue(-m_rate/100);
|
ui->BW->setValue(-m_rate/100);
|
||||||
|
@ -265,7 +265,7 @@
|
|||||||
<number>1</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<number>5</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="pageStep">
|
<property name="pageStep">
|
||||||
<number>1</number>
|
<number>1</number>
|
||||||
|
Loading…
Reference in New Issue
Block a user