CubicSDR/src/demod/DemodulatorThread.h

85 lines
1.9 KiB
C
Raw Normal View History

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
2015-07-29 20:57:02 -04:00
class DemodulatorThread : public IOThread {
2014-12-16 18:27:32 -05:00
public:
DemodulatorThread();
2014-12-16 21:30:03 -05:00
~DemodulatorThread();
2014-12-16 18:27:32 -05: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();
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
2015-07-19 15:34:06 -04:00
void setAGC(bool state);
bool getAGC();
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-01-01 18:08:54 -05:00
void setDemodulatorType(int demod_type_in);
int getDemodulatorType();
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:
ReBuffer<AudioThreadInput> outputBuffers;
2015-01-01 03:48:32 -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
freqdem demodFM;
ampmodem demodAM;
ampmodem demodAM_DSB_CSP;
ampmodem demodAM_DSB;
ampmodem demodAM_LSB;
ampmodem demodAM_USB;
2015-01-01 03:48:32 -05:00
agc_crcf iqAutoGain;
2014-12-16 18:27:32 -05:00
float amOutputCeil;
float amOutputCeilMA;
float amOutputCeilMAA;
2015-01-01 03:48:32 -05:00
2015-07-19 15:34:06 -04:00
std::atomic_bool stereo;
std::atomic_bool muted;
2015-07-19 15:34:06 -04:00
std::atomic_bool agcEnabled;
std::atomic_int demodulatorType;
int audioSampleRate;
2014-12-16 18:27:32 -05:00
std::atomic<float> squelchLevel;
std::atomic<float> signalLevel;
bool squelchEnabled;
DemodulatorThreadPostInputQueue* iqInputQueue;
AudioThreadInputQueue *audioOutputQueue;
DemodulatorThreadOutputQueue* audioVisOutputQueue;
DemodulatorThreadControlCommandQueue *threadQueueControl;
DemodulatorThreadCommandQueue* threadQueueNotify;
2014-12-16 18:27:32 -05:00
};