2014-12-16 18:27:32 -05:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <queue>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "DemodDefs.h"
|
|
|
|
#include "AudioThread.h"
|
2015-11-17 19:32:47 -05:00
|
|
|
#include "Modem.h"
|
2014-12-16 18:27:32 -05:00
|
|
|
|
2014-12-23 01:59:03 -05:00
|
|
|
typedef ThreadQueue<AudioThreadInput *> DemodulatorThreadOutputQueue;
|
2014-12-16 18:27:32 -05:00
|
|
|
|
2015-08-24 01:31:37 -04:00
|
|
|
#define DEMOD_VIS_SIZE 2048
|
2015-11-21 15:12:20 -05:00
|
|
|
#define DEMOD_SIGNAL_MIN -30
|
|
|
|
#define DEMOD_SIGNAL_MAX 30
|
|
|
|
|
2015-11-17 23:23:23 -05:00
|
|
|
class DemodulatorInstance;
|
2014-12-21 16:08:32 -05:00
|
|
|
|
2015-07-29 20:57:02 -04:00
|
|
|
class DemodulatorThread : public IOThread {
|
2014-12-16 18:27:32 -05:00
|
|
|
public:
|
|
|
|
|
2015-11-17 23:23:23 -05:00
|
|
|
DemodulatorThread(DemodulatorInstance *parent);
|
2014-12-16 21:30:03 -05:00
|
|
|
~DemodulatorThread();
|
2014-12-16 18:27:32 -05:00
|
|
|
|
2015-07-30 00:52:00 -04:00
|
|
|
void onBindOutput(std::string name, ThreadQueueBase *threadQueue);
|
|
|
|
|
2015-07-29 20:57:02 -04:00
|
|
|
void run();
|
2014-12-16 21:30:03 -05:00
|
|
|
void terminate();
|
2015-11-17 21:22:51 -05:00
|
|
|
|
2015-08-17 00:59:38 -04:00
|
|
|
void setMuted(bool state);
|
|
|
|
bool isMuted();
|
|
|
|
|
2014-12-31 19:45:01 -05:00
|
|
|
float getSignalLevel();
|
|
|
|
void setSquelchLevel(float signal_level_in);
|
|
|
|
float getSquelchLevel();
|
2015-11-18 21:09:51 -05:00
|
|
|
|
2016-02-11 01:32:39 -05:00
|
|
|
bool getSquelchBreak();
|
2015-11-21 15:12:20 -05:00
|
|
|
|
2014-12-16 18:27:32 -05:00
|
|
|
protected:
|
2015-11-21 15:12:20 -05:00
|
|
|
|
|
|
|
float abMagnitude(double alpha, double beta, float inphase, float quadrature);
|
|
|
|
float linearToDb(float linear);
|
|
|
|
|
2015-11-17 23:23:23 -05:00
|
|
|
DemodulatorInstance *demodInstance;
|
2015-07-28 21:56:39 -04:00
|
|
|
ReBuffer<AudioThreadInput> outputBuffers;
|
2015-01-01 03:48:32 -05:00
|
|
|
|
2015-08-17 00:59:38 -04:00
|
|
|
std::atomic_bool muted;
|
2014-12-16 18:27:32 -05:00
|
|
|
|
2015-01-03 17:07:39 -05:00
|
|
|
std::atomic<float> squelchLevel;
|
|
|
|
std::atomic<float> signalLevel;
|
2016-02-11 01:32:39 -05:00
|
|
|
bool squelchEnabled, squelchBreak;
|
2015-06-05 03:51:46 -04:00
|
|
|
|
2015-11-17 19:32:47 -05:00
|
|
|
Modem *cModem;
|
|
|
|
ModemKit *cModemKit;
|
|
|
|
|
2015-07-30 00:28:53 -04:00
|
|
|
DemodulatorThreadPostInputQueue* iqInputQueue;
|
|
|
|
AudioThreadInputQueue *audioOutputQueue;
|
|
|
|
DemodulatorThreadOutputQueue* audioVisOutputQueue;
|
|
|
|
DemodulatorThreadControlCommandQueue *threadQueueControl;
|
|
|
|
DemodulatorThreadCommandQueue* threadQueueNotify;
|
2014-12-16 18:27:32 -05:00
|
|
|
};
|