2015-06-21 06:46:47 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
2015-10-03 23:28:11 -04:00
|
|
|
// Copyright (C) 2015 Edouard Griffiths, F4EXB //
|
2015-06-21 06:46:47 -04:00
|
|
|
// //
|
|
|
|
// 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_CHANALYZER_H
|
|
|
|
#define INCLUDE_CHANALYZER_H
|
|
|
|
|
2016-10-02 16:29:04 -04:00
|
|
|
#include <dsp/basebandsamplesink.h>
|
2015-08-24 17:23:45 -04:00
|
|
|
#include <QMutex>
|
2015-06-21 06:46:47 -04:00
|
|
|
#include <vector>
|
2016-12-19 02:26:48 -05:00
|
|
|
#include "dsp/ncof.h"
|
2015-06-21 06:46:47 -04:00
|
|
|
#include "dsp/fftfilt.h"
|
|
|
|
#include "audio/audiofifo.h"
|
|
|
|
#include "util/message.h"
|
|
|
|
|
|
|
|
#define ssbFftLen 1024
|
|
|
|
|
2017-09-28 17:06:06 -04:00
|
|
|
class DeviceSourceAPI;
|
|
|
|
class ThreadedBasebandSampleSink;
|
|
|
|
class DownChannelizer;
|
|
|
|
|
2016-10-02 16:29:04 -04:00
|
|
|
class ChannelAnalyzer : public BasebandSampleSink {
|
2015-06-21 06:46:47 -04:00
|
|
|
public:
|
2017-09-28 17:06:06 -04:00
|
|
|
class MsgConfigureChannelAnalyzer : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
Real getBandwidth() const { return m_Bandwidth; }
|
|
|
|
Real getLoCutoff() const { return m_LowCutoff; }
|
|
|
|
int getSpanLog2() const { return m_spanLog2; }
|
|
|
|
bool getSSB() const { return m_ssb; }
|
|
|
|
|
|
|
|
static MsgConfigureChannelAnalyzer* create(Real Bandwidth,
|
|
|
|
Real LowCutoff,
|
|
|
|
int spanLog2,
|
|
|
|
bool ssb)
|
|
|
|
{
|
|
|
|
return new MsgConfigureChannelAnalyzer(Bandwidth, LowCutoff, spanLog2, ssb);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
Real m_Bandwidth;
|
|
|
|
Real m_LowCutoff;
|
|
|
|
int m_spanLog2;
|
|
|
|
bool m_ssb;
|
|
|
|
|
|
|
|
MsgConfigureChannelAnalyzer(Real Bandwidth,
|
|
|
|
Real LowCutoff,
|
|
|
|
int spanLog2,
|
|
|
|
bool ssb) :
|
|
|
|
Message(),
|
|
|
|
m_Bandwidth(Bandwidth),
|
|
|
|
m_LowCutoff(LowCutoff),
|
|
|
|
m_spanLog2(spanLog2),
|
|
|
|
m_ssb(ssb)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
class MsgConfigureChannelizer : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
int getCenterFrequency() const { return m_centerFrequency; }
|
|
|
|
|
|
|
|
static MsgConfigureChannelizer* create(int centerFrequency)
|
|
|
|
{
|
|
|
|
return new MsgConfigureChannelizer(centerFrequency);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
int m_centerFrequency;
|
|
|
|
|
|
|
|
MsgConfigureChannelizer(int centerFrequency) :
|
|
|
|
Message(),
|
|
|
|
m_centerFrequency(centerFrequency)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
class MsgReportChannelSampleRateChanged : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
static MsgReportChannelSampleRateChanged* create()
|
|
|
|
{
|
|
|
|
return new MsgReportChannelSampleRateChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
MsgReportChannelSampleRateChanged() :
|
|
|
|
Message()
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
ChannelAnalyzer(DeviceSourceAPI *deviceAPI);
|
2015-08-17 02:29:34 -04:00
|
|
|
virtual ~ChannelAnalyzer();
|
2017-09-28 17:06:06 -04:00
|
|
|
void setSampleSink(BasebandSampleSink* sampleSink) { m_sampleSink = sampleSink; }
|
2015-06-21 06:46:47 -04:00
|
|
|
|
|
|
|
void configure(MessageQueue* messageQueue,
|
|
|
|
Real Bandwidth,
|
|
|
|
Real LowCutoff,
|
|
|
|
int spanLog2,
|
|
|
|
bool ssb);
|
|
|
|
|
2015-10-03 23:28:11 -04:00
|
|
|
int getSampleRate() const { return m_sampleRate; }
|
|
|
|
Real getMagSq() const { return m_magsq; }
|
2015-06-21 14:58:35 -04:00
|
|
|
|
2015-08-25 02:24:23 -04:00
|
|
|
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly);
|
2015-08-17 02:29:34 -04:00
|
|
|
virtual void start();
|
|
|
|
virtual void stop();
|
|
|
|
virtual bool handleMessage(const Message& cmd);
|
2015-06-21 06:46:47 -04:00
|
|
|
|
2017-09-28 17:06:06 -04:00
|
|
|
private slots:
|
|
|
|
void channelSampleRateChanged();
|
|
|
|
|
2015-06-21 06:46:47 -04:00
|
|
|
private:
|
2017-09-28 17:06:06 -04:00
|
|
|
DeviceSourceAPI *m_deviceAPI;
|
|
|
|
ThreadedBasebandSampleSink* m_threadedChannelizer;
|
|
|
|
DownChannelizer* m_channelizer;
|
2015-06-21 06:46:47 -04:00
|
|
|
|
|
|
|
Real m_Bandwidth;
|
|
|
|
Real m_LowCutoff;
|
|
|
|
int m_spanLog2;
|
|
|
|
int m_undersampleCount;
|
2015-09-27 20:39:48 -04:00
|
|
|
fftfilt::cmplx m_sum;
|
2015-06-21 06:46:47 -04:00
|
|
|
int m_sampleRate;
|
|
|
|
int m_frequency;
|
|
|
|
bool m_usb;
|
|
|
|
bool m_ssb;
|
2015-10-03 23:28:11 -04:00
|
|
|
Real m_magsq;
|
2015-06-21 06:46:47 -04:00
|
|
|
|
2016-12-19 02:26:48 -05:00
|
|
|
NCOF m_nco;
|
2015-06-21 06:46:47 -04:00
|
|
|
fftfilt* SSBFilter;
|
|
|
|
fftfilt* DSBFilter;
|
|
|
|
|
2016-10-02 16:29:04 -04:00
|
|
|
BasebandSampleSink* m_sampleSink;
|
2015-06-21 06:46:47 -04:00
|
|
|
SampleVector m_sampleBuffer;
|
2015-08-24 17:23:45 -04:00
|
|
|
QMutex m_settingsMutex;
|
2015-06-21 06:46:47 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // INCLUDE_CHANALYZER_H
|