1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2025-11-12 09:10:34 -05:00
sdrangel/plugins/channeltx/modchirpchat/chirpchatmodbaseband.h

120 lines
4.4 KiB
C
Raw Normal View History

2020-02-10 08:45:55 +01:00
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2020 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 //
// (at your option) any later version. //
// //
// 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/>. //
///////////////////////////////////////////////////////////////////////////////////
2020-03-04 07:51:27 +01:00
#ifndef INCLUDE_CHIRPCHATMODBASEBAND_H
#define INCLUDE_CHIRPCHATMODBASEBAND_H
2020-02-10 08:45:55 +01:00
#include <QObject>
#include <QMutex>
#include "dsp/samplesourcefifo.h"
#include "util/message.h"
#include "util/messagequeue.h"
2020-03-04 07:51:27 +01:00
#include "chirpchatmodsource.h"
2020-02-10 08:45:55 +01:00
class UpChannelizer;
2020-03-04 07:51:27 +01:00
class ChirpChatModBaseband : public QObject
2020-02-10 08:45:55 +01:00
{
Q_OBJECT
public:
2020-03-04 07:51:27 +01:00
class MsgConfigureChirpChatModBaseband : public Message {
2020-02-10 08:45:55 +01:00
MESSAGE_CLASS_DECLARATION
public:
2020-03-04 07:51:27 +01:00
const ChirpChatModSettings& getSettings() const { return m_settings; }
2020-02-10 08:45:55 +01:00
bool getForce() const { return m_force; }
2020-03-04 07:51:27 +01:00
static MsgConfigureChirpChatModBaseband* create(const ChirpChatModSettings& settings, bool force)
2020-02-10 08:45:55 +01:00
{
2020-03-04 07:51:27 +01:00
return new MsgConfigureChirpChatModBaseband(settings, force);
2020-02-10 08:45:55 +01:00
}
private:
2020-03-04 07:51:27 +01:00
ChirpChatModSettings m_settings;
2020-02-10 08:45:55 +01:00
bool m_force;
2020-03-04 07:51:27 +01:00
MsgConfigureChirpChatModBaseband(const ChirpChatModSettings& settings, bool force) :
2020-02-10 08:45:55 +01:00
Message(),
m_settings(settings),
m_force(force)
{ }
};
2020-03-04 07:51:27 +01:00
class MsgConfigureChirpChatModPayload : public Message {
MESSAGE_CLASS_DECLARATION
public:
2020-02-18 10:30:42 +01:00
const std::vector<unsigned short>& getPayload() const { return m_payload; }
2020-03-04 07:51:27 +01:00
static MsgConfigureChirpChatModPayload* create() {
return new MsgConfigureChirpChatModPayload();
}
2020-03-04 07:51:27 +01:00
static MsgConfigureChirpChatModPayload* create(const std::vector<unsigned short>& payload) {
return new MsgConfigureChirpChatModPayload(payload);
}
private:
2020-02-18 10:30:42 +01:00
std::vector<unsigned short> m_payload;
2020-03-04 07:51:27 +01:00
MsgConfigureChirpChatModPayload() : // This is empty payload notification
Message()
{}
2020-03-04 07:51:27 +01:00
MsgConfigureChirpChatModPayload(const std::vector<unsigned short>& payload) :
Message()
{ m_payload = payload; }
};
2020-03-04 07:51:27 +01:00
ChirpChatModBaseband();
~ChirpChatModBaseband();
2020-02-10 08:45:55 +01:00
void reset();
void pull(const SampleVector::iterator& begin, unsigned int nbSamples);
MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; } //!< Get the queue for asynchronous inbound communication
double getMagSq() const { return m_source.getMagSq(); }
int getChannelSampleRate() const;
bool getActive() const { return m_source.getActive(); }
2020-02-10 08:45:55 +01:00
signals:
/**
* Level changed
* \param rmsLevel RMS level in range 0.0 - 1.0
* \param peakLevel Peak level in range 0.0 - 1.0
* \param numSamples Number of audio samples analyzed
*/
void levelChanged(qreal rmsLevel, qreal peakLevel, int numSamples);
private:
SampleSourceFifo m_sampleFifo;
UpChannelizer *m_channelizer;
2020-03-04 07:51:27 +01:00
ChirpChatModSource m_source;
2020-02-10 08:45:55 +01:00
MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication
2020-03-04 07:51:27 +01:00
ChirpChatModSettings m_settings;
2020-02-10 08:45:55 +01:00
QMutex m_mutex;
void processFifo(SampleVector& data, unsigned int iBegin, unsigned int iEnd);
bool handleMessage(const Message& cmd);
2020-03-04 07:51:27 +01:00
void applySettings(const ChirpChatModSettings& settings, bool force = false);
2020-02-10 08:45:55 +01:00
private slots:
void handleInputMessages();
void handleData(); //!< Handle data when samples have to be processed
};
2020-03-04 07:51:27 +01:00
#endif // INCLUDE_CHIRPCHATMODBASEBAND_H