2017-01-29 13:51:45 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2017 Edouard Griffiths, F4EXB //
|
|
|
|
// //
|
|
|
|
// This program is free software; you can redistribute it and/or modify //
|
|
|
|
// it under the terms of the GNU General Public License as published by //
|
|
|
|
// the Free Software Foundation as version 3 of the License, or //
|
|
|
|
// //
|
|
|
|
// This program is distributed in the hope that it will be useful, //
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
|
|
// GNU General Public License V3 for more details. //
|
|
|
|
// //
|
|
|
|
// You should have received a copy of the GNU General Public License //
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef INCLUDE_CHANALYZERNG_H
|
|
|
|
#define INCLUDE_CHANALYZERNG_H
|
|
|
|
|
|
|
|
#include <dsp/basebandsamplesink.h>
|
|
|
|
#include <QMutex>
|
|
|
|
#include <vector>
|
2017-02-28 16:11:13 -05:00
|
|
|
|
|
|
|
#include "dsp/interpolator.h"
|
2017-01-29 13:51:45 -05:00
|
|
|
#include "dsp/ncof.h"
|
|
|
|
#include "dsp/fftfilt.h"
|
|
|
|
#include "audio/audiofifo.h"
|
|
|
|
#include "util/message.h"
|
|
|
|
|
|
|
|
#define ssbFftLen 1024
|
|
|
|
|
|
|
|
class ChannelAnalyzerNG : public BasebandSampleSink {
|
|
|
|
public:
|
|
|
|
ChannelAnalyzerNG(BasebandSampleSink* m_sampleSink);
|
|
|
|
virtual ~ChannelAnalyzerNG();
|
|
|
|
|
|
|
|
void configure(MessageQueue* messageQueue,
|
2017-02-28 11:03:23 -05:00
|
|
|
int channelSampleRate,
|
2017-01-29 13:51:45 -05:00
|
|
|
Real Bandwidth,
|
|
|
|
Real LowCutoff,
|
|
|
|
int spanLog2,
|
|
|
|
bool ssb);
|
|
|
|
|
2017-02-28 17:12:14 -05:00
|
|
|
int getInputSampleRate() const { return m_running.m_inputSampleRate; }
|
2017-02-28 17:21:30 -05:00
|
|
|
int getChannelSampleRate() const { return m_running.m_channelSampleRate; }
|
2017-01-29 13:51:45 -05:00
|
|
|
Real getMagSq() const { return m_magsq; }
|
|
|
|
|
|
|
|
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly);
|
|
|
|
virtual void start();
|
|
|
|
virtual void stop();
|
|
|
|
virtual bool handleMessage(const Message& cmd);
|
|
|
|
|
|
|
|
private:
|
|
|
|
class MsgConfigureChannelAnalyzer : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
2017-02-28 16:29:33 -05:00
|
|
|
int getChannelSampleRate() const { return m_channelSampleRate; }
|
2017-01-29 13:51:45 -05:00
|
|
|
Real getBandwidth() const { return m_Bandwidth; }
|
|
|
|
Real getLoCutoff() const { return m_LowCutoff; }
|
|
|
|
int getSpanLog2() const { return m_spanLog2; }
|
|
|
|
bool getSSB() const { return m_ssb; }
|
|
|
|
|
2017-02-28 11:03:23 -05:00
|
|
|
static MsgConfigureChannelAnalyzer* create(
|
|
|
|
int channelSampleRate,
|
|
|
|
Real Bandwidth,
|
2017-01-29 13:51:45 -05:00
|
|
|
Real LowCutoff,
|
|
|
|
int spanLog2,
|
|
|
|
bool ssb)
|
|
|
|
{
|
2017-02-28 11:03:23 -05:00
|
|
|
return new MsgConfigureChannelAnalyzer(channelSampleRate, Bandwidth, LowCutoff, spanLog2, ssb);
|
2017-01-29 13:51:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2017-02-28 11:03:23 -05:00
|
|
|
int m_channelSampleRate;
|
2017-01-29 13:51:45 -05:00
|
|
|
Real m_Bandwidth;
|
|
|
|
Real m_LowCutoff;
|
|
|
|
int m_spanLog2;
|
|
|
|
bool m_ssb;
|
|
|
|
|
2017-02-28 11:03:23 -05:00
|
|
|
MsgConfigureChannelAnalyzer(
|
|
|
|
int channelSampleRate,
|
|
|
|
Real Bandwidth,
|
2017-01-29 13:51:45 -05:00
|
|
|
Real LowCutoff,
|
|
|
|
int spanLog2,
|
|
|
|
bool ssb) :
|
|
|
|
Message(),
|
2017-02-28 11:03:23 -05:00
|
|
|
m_channelSampleRate(channelSampleRate),
|
2017-01-29 13:51:45 -05:00
|
|
|
m_Bandwidth(Bandwidth),
|
|
|
|
m_LowCutoff(LowCutoff),
|
|
|
|
m_spanLog2(spanLog2),
|
|
|
|
m_ssb(ssb)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2017-02-28 16:00:24 -05:00
|
|
|
struct Config
|
|
|
|
{
|
|
|
|
int m_frequency;
|
|
|
|
int m_inputSampleRate;
|
|
|
|
int m_channelSampleRate;
|
2017-02-28 16:29:33 -05:00
|
|
|
Real m_Bandwidth;
|
|
|
|
Real m_LowCutoff;
|
2017-02-28 17:12:14 -05:00
|
|
|
int m_spanLog2;
|
|
|
|
bool m_ssb;
|
2017-02-28 16:00:24 -05:00
|
|
|
|
|
|
|
Config() :
|
|
|
|
m_frequency(0),
|
|
|
|
m_inputSampleRate(96000),
|
2017-02-28 16:29:33 -05:00
|
|
|
m_channelSampleRate(96000),
|
|
|
|
m_Bandwidth(5000),
|
2017-02-28 17:12:14 -05:00
|
|
|
m_LowCutoff(300),
|
|
|
|
m_spanLog2(3),
|
|
|
|
m_ssb(false)
|
2017-02-28 16:00:24 -05:00
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
Config m_config;
|
|
|
|
Config m_running;
|
|
|
|
|
2017-01-29 13:51:45 -05:00
|
|
|
int m_undersampleCount;
|
|
|
|
fftfilt::cmplx m_sum;
|
|
|
|
bool m_usb;
|
|
|
|
Real m_magsq;
|
|
|
|
|
|
|
|
NCOF m_nco;
|
2017-02-28 16:11:13 -05:00
|
|
|
Interpolator m_interpolator;
|
|
|
|
Real m_interpolatorDistance;
|
|
|
|
Real m_interpolatorDistanceRemain;
|
|
|
|
|
2017-01-29 13:51:45 -05:00
|
|
|
fftfilt* SSBFilter;
|
|
|
|
fftfilt* DSBFilter;
|
|
|
|
|
|
|
|
BasebandSampleSink* m_sampleSink;
|
|
|
|
SampleVector m_sampleBuffer;
|
|
|
|
QMutex m_settingsMutex;
|
2017-02-28 16:00:24 -05:00
|
|
|
|
|
|
|
void apply(bool force = false);
|
2017-01-29 13:51:45 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // INCLUDE_CHANALYZERNG_H
|