2014-12-16 18:27:32 -05:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <queue>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "DemodDefs.h"
|
|
|
|
#include "AudioThread.h"
|
|
|
|
|
2014-12-23 01:59:03 -05:00
|
|
|
typedef ThreadQueue<AudioThreadInput *> DemodulatorThreadOutputQueue;
|
2014-12-16 18:27:32 -05:00
|
|
|
|
2014-12-28 21:14:08 -05:00
|
|
|
#define DEMOD_VIS_SIZE 1024
|
2014-12-21 16:08:32 -05:00
|
|
|
|
2014-12-16 18:27:32 -05:00
|
|
|
class DemodulatorThread {
|
|
|
|
public:
|
|
|
|
|
2015-01-03 17:07:39 -05:00
|
|
|
DemodulatorThread(DemodulatorThreadPostInputQueue* iqInputQueue, DemodulatorThreadControlCommandQueue *threadQueueControl,
|
2014-12-24 01:28:33 -05:00
|
|
|
DemodulatorThreadCommandQueue* threadQueueNotify);
|
2014-12-16 21:30:03 -05:00
|
|
|
~DemodulatorThread();
|
2014-12-16 18:27:32 -05:00
|
|
|
|
|
|
|
#ifdef __APPLE__
|
2014-12-16 21:30:03 -05:00
|
|
|
void *threadMain();
|
2014-12-16 18:27:32 -05:00
|
|
|
#else
|
2014-12-16 21:30:03 -05:00
|
|
|
void threadMain();
|
2014-12-16 18:27:32 -05:00
|
|
|
#endif
|
|
|
|
|
2015-01-03 17:07:39 -05:00
|
|
|
void setVisualOutputQueue(DemodulatorThreadOutputQueue *tQueue);
|
|
|
|
void setAudioOutputQueue(AudioThreadInputQueue *tQueue);
|
2014-12-16 18:27:32 -05:00
|
|
|
|
2014-12-16 21:30:03 -05:00
|
|
|
void terminate();
|
2014-12-16 18:27:32 -05:00
|
|
|
|
2015-01-01 18:08:54 -05:00
|
|
|
void setStereo(bool state);
|
|
|
|
bool isStereo();
|
2014-12-26 20:58:42 -05:00
|
|
|
|
2014-12-31 19:45:01 -05:00
|
|
|
float getSignalLevel();
|
|
|
|
void setSquelchLevel(float signal_level_in);
|
|
|
|
float getSquelchLevel();
|
|
|
|
|
2015-01-01 18:08:54 -05:00
|
|
|
void setDemodulatorType(int demod_type_in);
|
|
|
|
int getDemodulatorType();
|
2015-06-05 03:51:46 -04:00
|
|
|
|
|
|
|
void setDemodulatorLock(bool demod_lock_in);
|
|
|
|
int getDemodulatorLock();
|
2015-06-10 04:50:14 -04:00
|
|
|
|
|
|
|
void setDemodulatorCons(int demod_cons_in);
|
|
|
|
int getDemodulatorCons();
|
2014-12-31 19:45:01 -05:00
|
|
|
|
2014-12-16 18:27:32 -05:00
|
|
|
#ifdef __APPLE__
|
2014-12-16 21:30:03 -05:00
|
|
|
static void *pthread_helper(void *context) {
|
|
|
|
return ((DemodulatorThread *) context)->threadMain();
|
|
|
|
}
|
2014-12-16 18:27:32 -05:00
|
|
|
#endif
|
|
|
|
|
|
|
|
protected:
|
2015-01-03 17:07:39 -05:00
|
|
|
std::deque<AudioThreadInput *> outputBuffers;
|
|
|
|
std::deque<AudioThreadInput *>::iterator outputBuffersI;
|
2015-01-01 03:48:32 -05:00
|
|
|
|
2015-01-03 17:07:39 -05:00
|
|
|
std::vector<liquid_float_complex> agcData;
|
|
|
|
std::vector<float> agcAMData;
|
|
|
|
std::vector<float> demodOutputData;
|
|
|
|
std::vector<float> demodStereoData;
|
|
|
|
std::vector<float> resampledOutputData;
|
|
|
|
std::vector<float> resampledStereoData;
|
2015-01-01 03:48:32 -05:00
|
|
|
|
2015-01-03 17:07:39 -05:00
|
|
|
DemodulatorThreadPostInputQueue* iqInputQueue;
|
|
|
|
DemodulatorThreadOutputQueue* audioVisOutputQueue;
|
|
|
|
AudioThreadInputQueue *audioOutputQueue;
|
2014-12-16 18:27:32 -05:00
|
|
|
|
2015-01-03 17:07:39 -05:00
|
|
|
freqdem demodFM;
|
|
|
|
ampmodem demodAM;
|
|
|
|
ampmodem demodAM_DSB_CSP;
|
2015-01-07 20:23:15 -05:00
|
|
|
ampmodem demodAM_DSB;
|
2015-01-03 17:07:39 -05:00
|
|
|
ampmodem demodAM_LSB;
|
|
|
|
ampmodem demodAM_USB;
|
2015-06-10 04:50:14 -04:00
|
|
|
|
|
|
|
modem demodASK;
|
|
|
|
modem demodASK2;
|
|
|
|
modem demodASK4;
|
|
|
|
modem demodASK8;
|
|
|
|
modem demodASK16;
|
|
|
|
modem demodASK32;
|
|
|
|
modem demodASK64;
|
|
|
|
modem demodASK128;
|
|
|
|
modem demodASK256;
|
|
|
|
|
2015-06-03 05:23:16 -04:00
|
|
|
modem demodAPSK;
|
|
|
|
modem demodBPSK;
|
|
|
|
modem demodDPSK;
|
|
|
|
modem demodPSK;
|
|
|
|
modem demodOOK;
|
|
|
|
modem demodSQAM;
|
|
|
|
modem demodST;
|
|
|
|
modem demodQAM;
|
|
|
|
modem demodQPSK;
|
2015-01-01 03:48:32 -05:00
|
|
|
|
2015-01-03 17:07:39 -05:00
|
|
|
agc_crcf iqAutoGain;
|
2014-12-16 18:27:32 -05:00
|
|
|
|
2015-01-03 17:07:39 -05:00
|
|
|
float amOutputCeil;
|
|
|
|
float amOutputCeilMA;
|
|
|
|
float amOutputCeilMAA;
|
2015-01-01 03:48:32 -05:00
|
|
|
|
2014-12-26 20:58:42 -05:00
|
|
|
std::atomic<bool> stereo;
|
2014-12-16 21:30:03 -05:00
|
|
|
std::atomic<bool> terminated;
|
2015-01-01 18:08:54 -05:00
|
|
|
std::atomic<int> demodulatorType;
|
2015-06-10 04:50:14 -04:00
|
|
|
std::atomic<int> demodulatorCons;
|
2015-03-15 21:02:26 -04:00
|
|
|
int audioSampleRate;
|
2014-12-16 18:27:32 -05:00
|
|
|
|
2014-12-16 21:30:03 -05:00
|
|
|
DemodulatorThreadCommandQueue* threadQueueNotify;
|
2014-12-21 16:08:32 -05:00
|
|
|
DemodulatorThreadControlCommandQueue *threadQueueControl;
|
2015-01-03 17:07:39 -05:00
|
|
|
std::atomic<float> squelchLevel;
|
|
|
|
std::atomic<float> signalLevel;
|
|
|
|
bool squelchEnabled;
|
2015-06-05 03:51:46 -04:00
|
|
|
|
2015-06-09 11:00:05 -04:00
|
|
|
bool currentDemodLock;
|
|
|
|
void updateDemodulatorLock(modem demod, float sensitivity);
|
2014-12-16 18:27:32 -05:00
|
|
|
};
|