2014-12-11 23:35:06 -05:00
|
|
|
#include "DemodulatorInstance.h"
|
|
|
|
|
|
|
|
DemodulatorInstance::DemodulatorInstance() :
|
2015-07-30 00:28:53 -04:00
|
|
|
threadQueueDemod(NULL), demodulatorThread(NULL), t_PreDemod(NULL), t_Demod(NULL), t_Audio(NULL), currentAudioGain(1.0) {
|
2015-07-21 00:59:18 -04:00
|
|
|
|
|
|
|
terminated.store(true);
|
|
|
|
audioTerminated.store(true);
|
|
|
|
demodTerminated.store(true);
|
|
|
|
preDemodTerminated.store(true);
|
|
|
|
active.store(false);
|
|
|
|
squelch.store(false);
|
|
|
|
stereo.store(false);
|
|
|
|
tracking.store(false);
|
|
|
|
follow.store(false);
|
|
|
|
currentAudioSampleRate.store(0);
|
|
|
|
currentFrequency.store(0);
|
|
|
|
currentBandwidth.store(0);
|
|
|
|
currentOutputDevice.store(-1);
|
|
|
|
|
2014-12-16 18:27:02 -05:00
|
|
|
|
2014-12-16 21:30:03 -05:00
|
|
|
label = new std::string("Unnamed");
|
|
|
|
threadQueueDemod = new DemodulatorThreadInputQueue;
|
|
|
|
threadQueuePostDemod = new DemodulatorThreadPostInputQueue;
|
|
|
|
threadQueueCommand = new DemodulatorThreadCommandQueue;
|
|
|
|
threadQueueNotify = new DemodulatorThreadCommandQueue;
|
2014-12-21 16:08:32 -05:00
|
|
|
threadQueueControl = new DemodulatorThreadControlCommandQueue;
|
2015-07-30 00:28:53 -04:00
|
|
|
|
2015-07-29 22:52:54 -04:00
|
|
|
demodulatorPreThread = new DemodulatorPreThread();
|
|
|
|
demodulatorPreThread->setInputQueue("IQDataInput",threadQueueDemod);
|
|
|
|
demodulatorPreThread->setOutputQueue("IQDataOut",threadQueuePostDemod);
|
|
|
|
demodulatorPreThread->setInputQueue("ControlQueue",threadQueueControl);
|
|
|
|
demodulatorPreThread->setOutputQueue("NotifyQueue",threadQueueNotify);
|
|
|
|
demodulatorPreThread->setInputQueue("CommandQueue",threadQueueCommand);
|
|
|
|
|
2014-12-16 21:30:03 -05:00
|
|
|
audioInputQueue = new AudioThreadInputQueue;
|
2014-12-16 18:27:02 -05:00
|
|
|
|
2015-07-30 00:28:53 -04:00
|
|
|
demodulatorThread = new DemodulatorThread();
|
|
|
|
demodulatorThread->setInputQueue("IQDataInput",threadQueuePostDemod);
|
|
|
|
demodulatorThread->setInputQueue("ControlQueue",threadQueueControl);
|
|
|
|
demodulatorThread->setOutputQueue("NotifyQueue",threadQueueNotify);
|
|
|
|
demodulatorThread->setOutputQueue("AudioDataOut", audioInputQueue);
|
2015-01-01 18:08:54 -05:00
|
|
|
|
2015-07-30 00:28:53 -04:00
|
|
|
audioThread = new AudioThread(audioInputQueue, threadQueueNotify);
|
2015-01-01 18:08:54 -05:00
|
|
|
currentDemodType = demodulatorThread->getDemodulatorType();
|
2014-12-11 23:35:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
DemodulatorInstance::~DemodulatorInstance() {
|
2014-12-16 21:30:03 -05:00
|
|
|
delete audioThread;
|
|
|
|
delete demodulatorThread;
|
2015-01-08 21:12:49 -05:00
|
|
|
delete demodulatorPreThread;
|
2014-12-16 21:30:03 -05:00
|
|
|
delete threadQueueDemod;
|
2015-01-08 21:12:49 -05:00
|
|
|
delete threadQueuePostDemod;
|
|
|
|
delete threadQueueCommand;
|
|
|
|
delete threadQueueNotify;
|
|
|
|
delete threadQueueControl;
|
|
|
|
delete audioInputQueue;
|
2014-12-11 23:35:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void DemodulatorInstance::setVisualOutputQueue(DemodulatorThreadOutputQueue *tQueue) {
|
2014-12-16 21:30:03 -05:00
|
|
|
demodulatorThread->setVisualOutputQueue(tQueue);
|
2014-12-11 23:35:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void DemodulatorInstance::run() {
|
2015-01-08 21:12:49 -05:00
|
|
|
if (active) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// while (!isTerminated()) {
|
|
|
|
// std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
|
|
|
// }
|
|
|
|
|
2015-01-04 17:11:20 -05:00
|
|
|
currentFrequency = demodulatorPreThread->getParams().frequency;
|
2015-01-08 21:12:49 -05:00
|
|
|
currentDemodType = demodulatorThread->getDemodulatorType();
|
2015-03-15 21:02:26 -04:00
|
|
|
currentAudioSampleRate = AudioThread::deviceSampleRate[getOutputDevice()];
|
|
|
|
demodulatorPreThread->getParams().audioSampleRate = currentAudioSampleRate;
|
2015-01-04 17:11:20 -05:00
|
|
|
|
2014-12-16 21:30:03 -05:00
|
|
|
t_Audio = new std::thread(&AudioThread::threadMain, audioThread);
|
2014-12-11 23:35:06 -05:00
|
|
|
|
|
|
|
#ifdef __APPLE__ // Already using pthreads, might as well do some custom init..
|
2014-12-16 21:30:03 -05:00
|
|
|
pthread_attr_t attr;
|
|
|
|
size_t size;
|
2014-12-11 23:35:06 -05:00
|
|
|
|
2014-12-16 21:30:03 -05:00
|
|
|
pthread_attr_init(&attr);
|
|
|
|
pthread_attr_setstacksize(&attr, 2048000);
|
|
|
|
pthread_attr_getstacksize(&attr, &size);
|
|
|
|
pthread_create(&t_PreDemod, &attr, &DemodulatorPreThread::pthread_helper, demodulatorPreThread);
|
|
|
|
pthread_attr_destroy(&attr);
|
2014-12-11 23:35:06 -05:00
|
|
|
|
2014-12-16 21:30:03 -05:00
|
|
|
pthread_attr_init(&attr);
|
|
|
|
pthread_attr_setstacksize(&attr, 2048000);
|
|
|
|
pthread_attr_getstacksize(&attr, &size);
|
|
|
|
pthread_create(&t_Demod, &attr, &DemodulatorThread::pthread_helper, demodulatorThread);
|
|
|
|
pthread_attr_destroy(&attr);
|
2014-12-16 18:27:02 -05:00
|
|
|
|
2014-12-16 21:30:03 -05:00
|
|
|
std::cout << "Initialized demodulator stack size of " << size << std::endl;
|
2014-12-11 23:35:06 -05:00
|
|
|
|
|
|
|
#else
|
2014-12-16 21:30:03 -05:00
|
|
|
t_PreDemod = new std::thread(&DemodulatorPreThread::threadMain, demodulatorPreThread);
|
|
|
|
t_Demod = new std::thread(&DemodulatorThread::threadMain, demodulatorThread);
|
2014-12-11 23:35:06 -05:00
|
|
|
#endif
|
2014-12-18 20:11:25 -05:00
|
|
|
active = true;
|
2015-01-08 21:12:49 -05:00
|
|
|
audioTerminated = demodTerminated = preDemodTerminated = terminated = false;
|
|
|
|
|
2014-12-11 23:35:06 -05:00
|
|
|
}
|
|
|
|
|
2015-01-04 17:11:20 -05:00
|
|
|
void DemodulatorInstance::updateLabel(long long freq) {
|
2014-12-16 21:30:03 -05:00
|
|
|
std::stringstream newLabel;
|
|
|
|
newLabel.precision(3);
|
2015-01-04 17:11:20 -05:00
|
|
|
newLabel << std::fixed << ((long double) freq / 1000000.0);
|
2014-12-16 21:30:03 -05:00
|
|
|
setLabel(newLabel.str());
|
2014-12-11 23:35:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
DemodulatorThreadCommandQueue *DemodulatorInstance::getCommandQueue() {
|
2014-12-16 21:30:03 -05:00
|
|
|
return threadQueueCommand;
|
2014-12-11 23:35:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void DemodulatorInstance::terminate() {
|
2014-12-16 21:30:03 -05:00
|
|
|
std::cout << "Terminating demodulator audio thread.." << std::endl;
|
|
|
|
audioThread->terminate();
|
2014-12-24 01:28:33 -05:00
|
|
|
std::cout << "Terminating demodulator thread.." << std::endl;
|
|
|
|
demodulatorThread->terminate();
|
|
|
|
std::cout << "Terminating demodulator preprocessor thread.." << std::endl;
|
|
|
|
demodulatorPreThread->terminate();
|
2014-12-11 23:35:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string DemodulatorInstance::getLabel() {
|
2014-12-16 21:30:03 -05:00
|
|
|
return *(label.load());
|
2014-12-11 23:35:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void DemodulatorInstance::setLabel(std::string labelStr) {
|
2014-12-16 21:30:03 -05:00
|
|
|
std::string *newLabel = new std::string;
|
|
|
|
newLabel->append(labelStr);
|
|
|
|
std::string *oldLabel;
|
|
|
|
oldLabel = label;
|
|
|
|
label = newLabel;
|
|
|
|
delete oldLabel;
|
2014-12-16 18:27:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool DemodulatorInstance::isTerminated() {
|
2014-12-16 21:30:03 -05:00
|
|
|
while (!threadQueueNotify->empty()) {
|
|
|
|
DemodulatorThreadCommand cmd;
|
|
|
|
threadQueueNotify->pop(cmd);
|
|
|
|
|
|
|
|
switch (cmd.cmd) {
|
|
|
|
case DemodulatorThreadCommand::DEMOD_THREAD_CMD_AUDIO_TERMINATED:
|
|
|
|
t_Audio->join();
|
|
|
|
audioTerminated = true;
|
2015-01-22 23:41:33 -05:00
|
|
|
delete t_Audio;
|
2014-12-16 21:30:03 -05:00
|
|
|
break;
|
|
|
|
case DemodulatorThreadCommand::DEMOD_THREAD_CMD_DEMOD_TERMINATED:
|
2014-12-16 18:27:02 -05:00
|
|
|
#ifdef __APPLE__
|
2014-12-16 21:30:03 -05:00
|
|
|
pthread_join(t_Demod, NULL);
|
2014-12-16 18:27:02 -05:00
|
|
|
#else
|
2014-12-16 21:30:03 -05:00
|
|
|
t_Demod->join();
|
2015-01-22 23:41:33 -05:00
|
|
|
delete t_Demod;
|
2014-12-16 18:27:02 -05:00
|
|
|
#endif
|
2014-12-16 21:30:03 -05:00
|
|
|
demodTerminated = true;
|
|
|
|
break;
|
|
|
|
case DemodulatorThreadCommand::DEMOD_THREAD_CMD_DEMOD_PREPROCESS_TERMINATED:
|
2014-12-16 18:27:02 -05:00
|
|
|
#ifdef __APPLE__
|
2014-12-16 21:30:03 -05:00
|
|
|
pthread_join(t_PreDemod, NULL);
|
2014-12-16 18:27:02 -05:00
|
|
|
#else
|
2014-12-16 21:30:03 -05:00
|
|
|
t_PreDemod->join();
|
2015-01-22 23:41:33 -05:00
|
|
|
delete t_PreDemod;
|
2014-12-16 18:27:02 -05:00
|
|
|
#endif
|
2014-12-16 21:30:03 -05:00
|
|
|
preDemodTerminated = true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-12-16 18:27:02 -05:00
|
|
|
|
2014-12-16 21:30:03 -05:00
|
|
|
terminated = audioTerminated && demodTerminated && preDemodTerminated;
|
2014-12-16 18:27:02 -05:00
|
|
|
|
2014-12-16 21:30:03 -05:00
|
|
|
return terminated;
|
2014-12-11 23:35:06 -05:00
|
|
|
}
|
2014-12-16 18:27:02 -05:00
|
|
|
|
2014-12-18 20:11:25 -05:00
|
|
|
bool DemodulatorInstance::isActive() {
|
|
|
|
return active;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DemodulatorInstance::setActive(bool state) {
|
2015-01-08 21:12:49 -05:00
|
|
|
if (active && !state) {
|
|
|
|
audioThread->setActive(state);
|
|
|
|
} else if (!active && state) {
|
|
|
|
audioThread->setActive(state);
|
|
|
|
}
|
2015-04-23 19:38:44 -04:00
|
|
|
if (!state) {
|
|
|
|
tracking = false;
|
|
|
|
}
|
2014-12-18 20:11:25 -05:00
|
|
|
active = state;
|
|
|
|
}
|
2014-12-21 16:08:32 -05:00
|
|
|
|
2014-12-26 20:58:42 -05:00
|
|
|
bool DemodulatorInstance::isStereo() {
|
|
|
|
return stereo;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DemodulatorInstance::setStereo(bool state) {
|
|
|
|
stereo = state;
|
|
|
|
demodulatorThread->setStereo(state);
|
|
|
|
}
|
|
|
|
|
2014-12-21 16:08:32 -05:00
|
|
|
void DemodulatorInstance::squelchAuto() {
|
|
|
|
DemodulatorThreadControlCommand command;
|
2015-01-03 17:07:39 -05:00
|
|
|
command.cmd = DemodulatorThreadControlCommand::DEMOD_THREAD_CMD_CTL_SQUELCH_ON;
|
2014-12-21 16:08:32 -05:00
|
|
|
threadQueueControl->push(command);
|
|
|
|
squelch = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DemodulatorInstance::isSquelchEnabled() {
|
2015-01-11 03:09:59 -05:00
|
|
|
return (demodulatorThread->getSquelchLevel() != 0.0);
|
2014-12-21 16:08:32 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void DemodulatorInstance::setSquelchEnabled(bool state) {
|
|
|
|
if (!state && squelch) {
|
|
|
|
DemodulatorThreadControlCommand command;
|
|
|
|
command.cmd = DemodulatorThreadControlCommand::DEMOD_THREAD_CMD_CTL_SQUELCH_OFF;
|
|
|
|
threadQueueControl->push(command);
|
|
|
|
} else if (state && !squelch) {
|
|
|
|
DemodulatorThreadControlCommand command;
|
2015-01-03 17:07:39 -05:00
|
|
|
command.cmd = DemodulatorThreadControlCommand::DEMOD_THREAD_CMD_CTL_SQUELCH_ON;
|
2014-12-21 16:08:32 -05:00
|
|
|
threadQueueControl->push(command);
|
|
|
|
}
|
|
|
|
|
|
|
|
squelch = state;
|
|
|
|
}
|
|
|
|
|
2014-12-31 19:45:01 -05:00
|
|
|
float DemodulatorInstance::getSignalLevel() {
|
|
|
|
return demodulatorThread->getSignalLevel();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DemodulatorInstance::setSquelchLevel(float signal_level_in) {
|
|
|
|
demodulatorThread->setSquelchLevel(signal_level_in);
|
|
|
|
}
|
|
|
|
|
|
|
|
float DemodulatorInstance::getSquelchLevel() {
|
|
|
|
return demodulatorThread->getSquelchLevel();
|
|
|
|
}
|
|
|
|
|
2014-12-31 21:31:37 -05:00
|
|
|
void DemodulatorInstance::setOutputDevice(int device_id) {
|
2015-01-10 12:27:03 -05:00
|
|
|
if (!active) {
|
|
|
|
audioThread->setInitOutputDevice(device_id);
|
|
|
|
} else if (audioThread) {
|
2014-12-31 21:31:37 -05:00
|
|
|
AudioThreadCommand command;
|
|
|
|
command.cmd = AudioThreadCommand::AUDIO_THREAD_CMD_SET_DEVICE;
|
|
|
|
command.int_value = device_id;
|
|
|
|
audioThread->getCommandQueue()->push(command);
|
|
|
|
}
|
2015-06-27 23:23:43 -04:00
|
|
|
setAudioSampleRate(AudioThread::deviceSampleRate[device_id]);
|
2015-01-25 21:03:17 -05:00
|
|
|
currentOutputDevice = device_id;
|
2014-12-31 21:31:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int DemodulatorInstance::getOutputDevice() {
|
2015-01-25 21:03:17 -05:00
|
|
|
if (currentOutputDevice == -1) {
|
2015-03-15 21:02:26 -04:00
|
|
|
currentOutputDevice = audioThread->getOutputDevice();
|
2015-01-25 21:03:17 -05:00
|
|
|
}
|
2015-03-15 21:02:26 -04:00
|
|
|
|
|
|
|
return currentOutputDevice;
|
2014-12-31 21:31:37 -05:00
|
|
|
}
|
2015-01-01 03:48:32 -05:00
|
|
|
|
2015-01-04 13:20:31 -05:00
|
|
|
void DemodulatorInstance::checkBandwidth() {
|
2015-03-29 20:24:00 -04:00
|
|
|
// if ((currentDemodType == DEMOD_TYPE_USB || currentDemodType == DEMOD_TYPE_LSB) && (getBandwidth() % 2)) {
|
|
|
|
// setBandwidth(getBandwidth()+1);
|
|
|
|
// }
|
2015-01-04 13:20:31 -05:00
|
|
|
}
|
|
|
|
|
2015-01-01 18:08:54 -05:00
|
|
|
void DemodulatorInstance::setDemodulatorType(int demod_type_in) {
|
2015-07-19 15:34:06 -04:00
|
|
|
currentDemodType = demod_type_in;
|
|
|
|
|
|
|
|
if (currentDemodType == DEMOD_TYPE_RAW) {
|
|
|
|
if (currentAudioSampleRate) {
|
|
|
|
setBandwidth(currentAudioSampleRate);
|
|
|
|
} else {
|
|
|
|
setBandwidth(AudioThread::deviceSampleRate[getOutputDevice()]);
|
|
|
|
}
|
|
|
|
} else if (currentDemodType == DEMOD_TYPE_USB || currentDemodType == DEMOD_TYPE_LSB || currentDemodType == DEMOD_TYPE_DSB || currentDemodType == DEMOD_TYPE_AM) {
|
|
|
|
demodulatorThread->setAGC(false);
|
|
|
|
} else {
|
|
|
|
demodulatorThread->setAGC(true);
|
|
|
|
}
|
|
|
|
setGain(getGain());
|
|
|
|
|
2015-01-10 12:27:03 -05:00
|
|
|
if (!active) {
|
|
|
|
checkBandwidth();
|
|
|
|
demodulatorPreThread->getParams().demodType = currentDemodType;
|
|
|
|
demodulatorThread->setDemodulatorType(currentDemodType);
|
|
|
|
} else if (demodulatorThread && threadQueueControl) {
|
2015-01-01 18:08:54 -05:00
|
|
|
DemodulatorThreadControlCommand command;
|
2015-01-04 13:20:31 -05:00
|
|
|
command.cmd = DemodulatorThreadControlCommand::DEMOD_THREAD_CMD_CTL_TYPE;
|
|
|
|
command.demodType = demod_type_in;
|
|
|
|
checkBandwidth();
|
|
|
|
threadQueueControl->push(command);
|
|
|
|
}
|
2015-01-01 03:48:32 -05:00
|
|
|
}
|
|
|
|
|
2015-01-01 18:08:54 -05:00
|
|
|
int DemodulatorInstance::getDemodulatorType() {
|
|
|
|
return currentDemodType;
|
2015-01-01 03:48:32 -05:00
|
|
|
}
|
|
|
|
|
2015-01-04 13:20:31 -05:00
|
|
|
void DemodulatorInstance::setBandwidth(int bw) {
|
2015-06-27 23:23:43 -04:00
|
|
|
if (currentDemodType == DEMOD_TYPE_RAW) {
|
|
|
|
if (currentAudioSampleRate) {
|
|
|
|
bw = currentAudioSampleRate;
|
|
|
|
} else {
|
|
|
|
bw = AudioThread::deviceSampleRate[getOutputDevice()];
|
|
|
|
}
|
|
|
|
}
|
2015-01-10 12:27:03 -05:00
|
|
|
if (!active) {
|
|
|
|
currentBandwidth = bw;
|
|
|
|
checkBandwidth();
|
|
|
|
demodulatorPreThread->getParams().bandwidth = currentBandwidth;
|
|
|
|
} else if (demodulatorPreThread && threadQueueCommand) {
|
2015-01-04 13:20:31 -05:00
|
|
|
DemodulatorThreadCommand command;
|
|
|
|
command.cmd = DemodulatorThreadCommand::DEMOD_THREAD_CMD_SET_BANDWIDTH;
|
|
|
|
currentBandwidth = bw;
|
|
|
|
checkBandwidth();
|
2015-01-04 17:11:20 -05:00
|
|
|
command.llong_value = currentBandwidth;
|
2015-01-04 13:20:31 -05:00
|
|
|
threadQueueCommand->push(command);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int DemodulatorInstance::getBandwidth() {
|
|
|
|
if (!currentBandwidth) {
|
|
|
|
currentBandwidth = demodulatorPreThread->getParams().bandwidth;
|
|
|
|
}
|
|
|
|
return currentBandwidth;
|
|
|
|
}
|
|
|
|
|
2015-01-04 17:11:20 -05:00
|
|
|
void DemodulatorInstance::setFrequency(long long freq) {
|
2015-01-10 12:27:03 -05:00
|
|
|
if ((freq - getBandwidth() / 2) <= 0) {
|
|
|
|
freq = getBandwidth() / 2;
|
2015-01-04 13:20:31 -05:00
|
|
|
}
|
2015-01-10 12:27:03 -05:00
|
|
|
if (!active) {
|
|
|
|
currentFrequency = freq;
|
|
|
|
demodulatorPreThread->getParams().frequency = currentFrequency;
|
|
|
|
} else if (demodulatorPreThread && threadQueueCommand) {
|
|
|
|
DemodulatorThreadCommand command;
|
|
|
|
command.cmd = DemodulatorThreadCommand::DEMOD_THREAD_CMD_SET_FREQUENCY;
|
|
|
|
currentFrequency = freq;
|
|
|
|
command.llong_value = freq;
|
|
|
|
threadQueueCommand->push(command);
|
|
|
|
}
|
2015-01-04 13:20:31 -05:00
|
|
|
}
|
|
|
|
|
2015-01-04 17:11:20 -05:00
|
|
|
long long DemodulatorInstance::getFrequency() {
|
2015-01-04 13:20:31 -05:00
|
|
|
if (!currentFrequency) {
|
|
|
|
currentFrequency = demodulatorPreThread->getParams().frequency;
|
|
|
|
}
|
|
|
|
return currentFrequency;
|
|
|
|
}
|
2015-01-10 20:33:30 -05:00
|
|
|
|
2015-03-15 21:02:26 -04:00
|
|
|
|
|
|
|
void DemodulatorInstance::setAudioSampleRate(int sampleRate) {
|
|
|
|
if (terminated) {
|
|
|
|
currentAudioSampleRate = sampleRate;
|
|
|
|
demodulatorPreThread->getParams().audioSampleRate = sampleRate;
|
|
|
|
} else if (demodulatorPreThread && threadQueueCommand) {
|
|
|
|
DemodulatorThreadCommand command;
|
|
|
|
command.cmd = DemodulatorThreadCommand::DEMOD_THREAD_CMD_SET_AUDIO_RATE;
|
|
|
|
currentAudioSampleRate = sampleRate;
|
|
|
|
command.llong_value = sampleRate;
|
|
|
|
threadQueueCommand->push(command);
|
|
|
|
}
|
2015-06-27 23:23:43 -04:00
|
|
|
if (currentDemodType == DEMOD_TYPE_RAW) {
|
|
|
|
setBandwidth(currentAudioSampleRate);
|
|
|
|
}
|
2015-03-15 21:02:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
int DemodulatorInstance::getAudioSampleRate() {
|
|
|
|
if (!currentAudioSampleRate) {
|
|
|
|
currentAudioSampleRate = audioThread->getSampleRate();
|
|
|
|
}
|
|
|
|
return currentAudioSampleRate;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-10 20:33:30 -05:00
|
|
|
void DemodulatorInstance::setGain(float gain_in) {
|
2015-07-19 15:34:06 -04:00
|
|
|
currentAudioGain = gain_in;
|
|
|
|
|
|
|
|
if (currentDemodType == DEMOD_TYPE_RAW) {
|
|
|
|
if (gain_in < 0.25) {
|
|
|
|
audioThread->setGain(1.0);
|
|
|
|
demodulatorThread->setAGC(false);
|
|
|
|
} else {
|
|
|
|
audioThread->setGain(gain_in);
|
|
|
|
demodulatorThread->setAGC(true);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
audioThread->setGain(gain_in);
|
|
|
|
}
|
2015-01-10 20:33:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
float DemodulatorInstance::getGain() {
|
2015-07-19 15:34:06 -04:00
|
|
|
return currentAudioGain;
|
2015-01-10 20:33:30 -05:00
|
|
|
}
|
2015-03-26 22:45:52 -04:00
|
|
|
|
|
|
|
bool DemodulatorInstance::isFollow() {
|
|
|
|
return follow;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DemodulatorInstance::setFollow(bool follow) {
|
|
|
|
this->follow = follow;
|
|
|
|
}
|
2015-04-23 19:38:44 -04:00
|
|
|
|
|
|
|
bool DemodulatorInstance::isTracking() {
|
|
|
|
return tracking;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DemodulatorInstance::setTracking(bool tracking) {
|
|
|
|
this->tracking = tracking;
|
|
|
|
}
|