Fix frequency related data types for >2Ghz

This commit is contained in:
Charles J. Cliffe
2015-01-04 17:11:20 -05:00
parent 44bee1f553
commit 9f945026b8
29 changed files with 393 additions and 144 deletions
+7 -7
View File
@@ -27,18 +27,18 @@ public:
};
DemodulatorThreadCommand() :
cmd(DEMOD_THREAD_CMD_NULL), context(NULL), int_value(0) {
cmd(DEMOD_THREAD_CMD_NULL), context(NULL), llong_value(0) {
}
DemodulatorThreadCommand(DemodulatorThreadCommandEnum cmd) :
cmd(cmd), context(NULL), int_value(0) {
cmd(cmd), context(NULL), llong_value(0) {
}
DemodulatorThreadCommandEnum cmd;
void *context;
int int_value;
long long llong_value;
};
class DemodulatorThreadControlCommand {
@@ -57,7 +57,7 @@ public:
class DemodulatorThreadIQData: public ReferenceCounter {
public:
unsigned int frequency;
long long frequency;
unsigned int bandwidth;
std::vector<liquid_float_complex> data;
@@ -91,7 +91,7 @@ public:
class DemodulatorThreadAudioData: public ReferenceCounter {
public:
unsigned int frequency;
long long frequency;
unsigned int sampleRate;
unsigned char channels;
@@ -102,7 +102,7 @@ public:
}
DemodulatorThreadAudioData(unsigned int frequency, unsigned int sampleRate, std::vector<float> *data) :
DemodulatorThreadAudioData(long long frequency, unsigned int sampleRate, std::vector<float> *data) :
frequency(frequency), sampleRate(sampleRate), channels(1), data(data) {
}
@@ -119,7 +119,7 @@ typedef ThreadQueue<DemodulatorThreadControlCommand> DemodulatorThreadControlCom
class DemodulatorThreadParameters {
public:
unsigned int frequency;
long long frequency;
unsigned int inputRate;
unsigned int bandwidth; // set equal to disable second stage re-sampling?
unsigned int audioSampleRate;
+10 -8
View File
@@ -2,7 +2,7 @@
DemodulatorInstance::DemodulatorInstance() :
t_Demod(NULL), t_PreDemod(NULL), t_Audio(NULL), threadQueueDemod(NULL), demodulatorThread(NULL), terminated(false), audioTerminated(false), demodTerminated(
false), preDemodTerminated(false), active(false), squelch(false), stereo(false), currentBandwidth(0), currentFrequency(0) {
false), preDemodTerminated(false), active(false), squelch(false), stereo(false), currentFrequency(0), currentBandwidth(0) {
label = new std::string("Unnamed");
threadQueueDemod = new DemodulatorThreadInputQueue;
@@ -36,6 +36,8 @@ void DemodulatorInstance::setVisualOutputQueue(DemodulatorThreadOutputQueue *tQu
}
void DemodulatorInstance::run() {
currentFrequency = demodulatorPreThread->getParams().frequency;
t_Audio = new std::thread(&AudioThread::threadMain, audioThread);
#ifdef __APPLE__ // Already using pthreads, might as well do some custom init..
@@ -63,10 +65,10 @@ void DemodulatorInstance::run() {
active = true;
}
void DemodulatorInstance::updateLabel(int freq) {
void DemodulatorInstance::updateLabel(long long freq) {
std::stringstream newLabel;
newLabel.precision(3);
newLabel << std::fixed << ((float) freq / 1000000.0);
newLabel << std::fixed << ((long double) freq / 1000000.0);
setLabel(newLabel.str());
}
@@ -234,7 +236,7 @@ void DemodulatorInstance::setBandwidth(int bw) {
command.cmd = DemodulatorThreadCommand::DEMOD_THREAD_CMD_SET_BANDWIDTH;
currentBandwidth = bw;
checkBandwidth();
command.int_value = currentBandwidth;
command.llong_value = currentBandwidth;
threadQueueCommand->push(command);
}
demodulatorPreThread->getParams().bandwidth;
@@ -247,21 +249,21 @@ int DemodulatorInstance::getBandwidth() {
return currentBandwidth;
}
void DemodulatorInstance::setFrequency(unsigned int freq) {
if (((long)freq - getBandwidth()/2) < SRATE/2) {
void DemodulatorInstance::setFrequency(long long freq) {
if ((freq - getBandwidth()/2) < SRATE/2) {
freq = SRATE/2 - getBandwidth()/2;
}
if (demodulatorPreThread && threadQueueCommand) {
DemodulatorThreadCommand command;
command.cmd = DemodulatorThreadCommand::DEMOD_THREAD_CMD_SET_FREQUENCY;
currentFrequency = freq;
command.int_value = freq;
command.llong_value = freq;
threadQueueCommand->push(command);
}
demodulatorPreThread->getParams().bandwidth;
}
int DemodulatorInstance::getFrequency() {
long long DemodulatorInstance::getFrequency() {
if (!currentFrequency) {
currentFrequency = demodulatorPreThread->getParams().frequency;
}
+5 -5
View File
@@ -44,7 +44,7 @@ public:
void setLabel(std::string labelStr);
bool isTerminated();
void updateLabel(int freq);
void updateLabel(long long freq);
bool isActive();
void setActive(bool state);
@@ -69,8 +69,8 @@ public:
void setBandwidth(int bw);
int getBandwidth();
void setFrequency(unsigned int freq);
int getFrequency();
void setFrequency(long long freq);
long long getFrequency();
private:
void checkBandwidth();
@@ -84,7 +84,7 @@ private:
std::atomic<bool> squelch;
std::atomic<bool> stereo;
int currentDemodType;
long long currentFrequency;
int currentBandwidth;
int currentFrequency;
int currentDemodType;
};
+5 -5
View File
@@ -62,17 +62,17 @@ void DemodulatorMgr::deleteThread(DemodulatorInstance *demod) {
garbageCollect();
}
std::vector<DemodulatorInstance *> *DemodulatorMgr::getDemodulatorsAt(int freq, int bandwidth) {
std::vector<DemodulatorInstance *> *DemodulatorMgr::getDemodulatorsAt(long long freq, int bandwidth) {
std::vector<DemodulatorInstance *> *foundDemods = new std::vector<DemodulatorInstance *>();
for (int i = 0, iMax = demods.size(); i < iMax; i++) {
DemodulatorInstance *testDemod = demods[i];
int freqTest = testDemod->getParams().frequency;
int bandwidthTest = testDemod->getParams().bandwidth;
int halfBandwidthTest = bandwidthTest / 2;
long long freqTest = testDemod->getParams().frequency;
long long bandwidthTest = testDemod->getParams().bandwidth;
long long halfBandwidthTest = bandwidthTest / 2;
int halfBuffer = bandwidth / 2;
long long halfBuffer = bandwidth / 2;
if ((freq <= (freqTest + halfBandwidthTest + halfBuffer)) && (freq >= (freqTest - halfBandwidthTest - halfBuffer))) {
foundDemods->push_back(testDemod);
+1 -1
View File
@@ -13,7 +13,7 @@ public:
DemodulatorInstance *newThread();
std::vector<DemodulatorInstance *> &getDemodulators();
std::vector<DemodulatorInstance *> *getDemodulatorsAt(int freq, int bandwidth);
std::vector<DemodulatorInstance *> *getDemodulatorsAt(long long freq, int bandwidth);
void deleteThread(DemodulatorInstance *);
void terminateAll();
+6 -6
View File
@@ -84,17 +84,17 @@ void DemodulatorPreThread::threadMain() {
commandQueue->pop(command);
switch (command.cmd) {
case DemodulatorThreadCommand::DEMOD_THREAD_CMD_SET_BANDWIDTH:
if (command.int_value < 1500) {
command.int_value = 1500;
if (command.llong_value < 1500) {
command.llong_value = 1500;
}
if (command.int_value > SRATE) {
command.int_value = SRATE;
if (command.llong_value > SRATE) {
command.llong_value = SRATE;
}
bandwidthParams.bandwidth = command.int_value;
bandwidthParams.bandwidth = command.llong_value;
bandwidthChanged = true;
break;
case DemodulatorThreadCommand::DEMOD_THREAD_CMD_SET_FREQUENCY:
params.frequency = command.int_value;
params.frequency = command.llong_value;
break;
}
}
+1 -1
View File
@@ -65,7 +65,7 @@ public:
DemodulatorThreadCommandEnum cmd;
unsigned int frequency;
long long frequency;
unsigned int inputRate;
unsigned int bandwidth;
unsigned int audioSampleRate;