1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-22 08:04:49 -05:00

Fixed channel analyzer rate based displays

This commit is contained in:
f4exb 2015-06-21 20:58:35 +02:00
parent d6154eb0eb
commit cf198f0450
4 changed files with 33 additions and 63 deletions

View File

@ -31,24 +31,16 @@ ChannelAnalyzer::ChannelAnalyzer(SampleSink* sampleSink) :
{
m_Bandwidth = 5000;
m_LowCutoff = 300;
//m_volume = 2.0;
m_spanLog2 = 3;
m_sampleRate = 96000;
m_frequency = 0;
m_nco.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_usb = true;
m_ssb = true;
SSBFilter = new fftfilt(m_LowCutoff / 48000.0, m_Bandwidth / 48000.0, ssbFftLen);
DSBFilter = new fftfilt(m_Bandwidth / 48000.0, 2*ssbFftLen);
// if (!USBFilter) segfault;
SSBFilter = new fftfilt(m_LowCutoff / m_sampleRate, m_Bandwidth / m_sampleRate, ssbFftLen);
DSBFilter = new fftfilt(m_Bandwidth / m_sampleRate, 2*ssbFftLen);
}
ChannelAnalyzer::~ChannelAnalyzer()
@ -69,7 +61,6 @@ void ChannelAnalyzer::configure(MessageQueue* messageQueue,
void ChannelAnalyzer::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly)
{
Complex ci;
fftfilt::cmplx *sideband, sum;
int n_out;
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);
c *= m_nco.nextIQ();
/*
ci = c;
if (m_ssb) {
n_out = SSBFilter->runSSB(ci, &sideband, m_usb);
n_out = SSBFilter->runSSB(c, &sideband, m_usb);
} else {
n_out = DSBFilter->noFilt(ci, &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;
n_out = DSBFilter->runDSB(c, &sideband);
}
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))
{
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));
} else {
}
else
{
m_sampleBuffer.push_back(Sample(sum.real() * 32768.0, sum.imag() * 32768.0));
}
sum = 0;
}
}
}
@ -151,8 +126,6 @@ bool ChannelAnalyzer::handleMessage(Message* cmd)
//fprintf(stderr, "%d samples/sec, %lld Hz offset", signal->getSampleRate(), signal->getFrequencyOffset());
m_sampleRate = signal->getSampleRate();
m_nco.setFreq(-signal->getFrequencyOffset(), m_sampleRate);
m_interpolator.create(16, m_sampleRate, m_Bandwidth);
m_sampleDistanceRemain = m_sampleRate / 48000.0;
cmd->completed();
return true;
} else if(MsgConfigureChannelAnalyzer::match(cmd)) {
@ -177,12 +150,9 @@ bool ChannelAnalyzer::handleMessage(Message* cmd)
m_Bandwidth = band;
m_LowCutoff = lowCutoff;
m_interpolator.create(16, m_sampleRate, band * 2.0f);
SSBFilter->create_filter(m_LowCutoff / 48000.0f, m_Bandwidth / 48000.0f);
DSBFilter->create_dsb_filter(m_Bandwidth / 48000.0f);
//m_volume = cfg->getVolume();
//m_volume *= m_volume * 0.1;
//m_interpolator.create(16, m_sampleRate, band * 2.0f);
SSBFilter->create_filter(m_LowCutoff / m_sampleRate, m_Bandwidth / m_sampleRate);
DSBFilter->create_dsb_filter(m_Bandwidth / m_sampleRate);
m_spanLog2 = cfg->getSpanLog2();
m_ssb = cfg->getSSB();

View File

@ -41,6 +41,10 @@ public:
int spanLog2,
bool ssb);
int getSampleRate() const {
return m_sampleRate;
}
void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly);
void start();
void stop();
@ -82,12 +86,6 @@ private:
{ }
};
//struct AudioSample {
// qint16 l;
// qint16 r;
//};
//typedef std::vector<AudioSample> AudioVector;
Real m_Bandwidth;
Real m_LowCutoff;
int m_spanLog2;
@ -99,17 +97,11 @@ private:
NCO m_nco;
NCO m_nco_test;
Interpolator m_interpolator;
Real m_sampleDistanceRemain;
fftfilt* SSBFilter;
fftfilt* DSBFilter;
SampleSink* m_sampleSink;
SampleVector m_sampleBuffer;
//AudioVector m_audioBuffer;
//uint m_audioBufferFill;
//AudioFifo* m_audioFifo;
};
#endif // INCLUDE_CHANALYZER_H

View File

@ -128,10 +128,17 @@ void ChannelAnalyzerGUI::on_BW_valueChanged(int value)
ui->BWText->setText(tr("%1k").arg(s));
m_channelMarker->setBandwidth(value * 100 * 2);
if (value < 0) {
m_channelMarker->setSidebands(ChannelMarker::lsb);
} else {
m_channelMarker->setSidebands(ChannelMarker::usb);
if (ui->ssb->isChecked())
{
if (value < 0) {
m_channelMarker->setSidebands(ChannelMarker::lsb);
} else {
m_channelMarker->setSidebands(ChannelMarker::usb);
}
}
else
{
m_channelMarker->setSidebands(ChannelMarker::dsb);
}
on_lowCut_valueChanged(m_channelMarker->getLowCutoff()/100);
@ -282,12 +289,13 @@ ChannelAnalyzerGUI::~ChannelAnalyzerGUI()
bool ChannelAnalyzerGUI::setNewRate(int spanLog2)
{
if ((spanLog2 < 1) || (spanLog2 > 5)) {
if ((spanLog2 < 1) || (spanLog2 > 6)) {
return false;
}
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) {
ui->BW->setValue(-m_rate/100);

View File

@ -265,7 +265,7 @@
<number>1</number>
</property>
<property name="maximum">
<number>5</number>
<number>6</number>
</property>
<property name="pageStep">
<number>1</number>