mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-07-23 03:05:30 -04:00
Implemented full SSB variable span with averaging in the SSB spectrum decimator
This commit is contained in:
parent
85610c6a86
commit
7727ae7a36
@ -63,8 +63,11 @@ void SSBDemod::configure(MessageQueue* messageQueue, Real Bandwidth, Real LowCut
|
|||||||
void SSBDemod::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly)
|
void SSBDemod::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly)
|
||||||
{
|
{
|
||||||
Complex ci;
|
Complex ci;
|
||||||
fftfilt::cmplx *sideband;
|
fftfilt::cmplx *sideband, sum;
|
||||||
|
Real avg;
|
||||||
int n_out;
|
int n_out;
|
||||||
|
int decim = 1<<(m_spanLog2 - 1);
|
||||||
|
unsigned char decim_mask = decim - 1; // counter LSB bit mask for decimation by 2^(m_scaleLog2 - 1)
|
||||||
|
|
||||||
for(SampleVector::const_iterator it = begin; it < end; ++it) {
|
for(SampleVector::const_iterator it = begin; it < end; ++it) {
|
||||||
Complex c(it->real() / 32768.0, it->imag() / 32768.0);
|
Complex c(it->real() / 32768.0, it->imag() / 32768.0);
|
||||||
@ -79,9 +82,17 @@ void SSBDemod::feed(SampleVector::const_iterator begin, SampleVector::const_iter
|
|||||||
for (int i = 0; i < n_out; i++) {
|
for (int i = 0; i < n_out; i++) {
|
||||||
Real demod = (sideband[i].real() + sideband[i].imag()) * 0.7 * 32768.0;
|
Real demod = (sideband[i].real() + sideband[i].imag()) * 0.7 * 32768.0;
|
||||||
|
|
||||||
// Downsample by 4x for audio display
|
// Downsample by 2^(m_scaleLog2 - 1) for SSB band spectrum display
|
||||||
if (!(m_undersampleCount++ & 3))
|
// smart decimation with bit gain using float arithmetic (23 bits significand)
|
||||||
m_sampleBuffer.push_back(Sample(demod, 0.0));
|
|
||||||
|
sum += sideband[i];
|
||||||
|
|
||||||
|
if (!(m_undersampleCount++ & decim_mask)) {
|
||||||
|
avg = (sum.real() + sum.imag()) * 0.7 * 32768.0 / decim;
|
||||||
|
m_sampleBuffer.push_back(Sample(avg, 0.0));
|
||||||
|
sum.real() = 0.0;
|
||||||
|
sum.imag() = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
qint16 sample = (qint16)(demod * m_volume * 10);
|
qint16 sample = (qint16)(demod * m_volume * 10);
|
||||||
m_audioBuffer[m_audioBufferFill].l = sample;
|
m_audioBuffer[m_audioBufferFill].l = sample;
|
||||||
|
@ -261,7 +261,7 @@ SSBDemodGUI::~SSBDemodGUI()
|
|||||||
|
|
||||||
bool SSBDemodGUI::setNewRate(int spanLog2)
|
bool SSBDemodGUI::setNewRate(int spanLog2)
|
||||||
{
|
{
|
||||||
if ((spanLog2 < 0) || (spanLog2 > 5)) {
|
if ((spanLog2 < 1) || (spanLog2 > 5)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user