mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2025-07-31 12:52:25 -04:00
Fix frequency related data types for >2Ghz
This commit is contained in:
parent
44bee1f553
commit
9f945026b8
@ -139,6 +139,8 @@ SET (cubicsdr_sources
|
|||||||
src/visual/InteractiveCanvas.cpp
|
src/visual/InteractiveCanvas.cpp
|
||||||
src/visual/MeterCanvas.cpp
|
src/visual/MeterCanvas.cpp
|
||||||
src/visual/MeterContext.cpp
|
src/visual/MeterContext.cpp
|
||||||
|
src/visual/TuningCanvas.cpp
|
||||||
|
src/visual/TuningContext.cpp
|
||||||
src/visual/ScopeCanvas.cpp
|
src/visual/ScopeCanvas.cpp
|
||||||
src/visual/ScopeContext.cpp
|
src/visual/ScopeContext.cpp
|
||||||
src/visual/SpectrumCanvas.cpp
|
src/visual/SpectrumCanvas.cpp
|
||||||
@ -171,6 +173,8 @@ SET (cubicsdr_headers
|
|||||||
src/visual/InteractiveCanvas.h
|
src/visual/InteractiveCanvas.h
|
||||||
src/visual/MeterCanvas.h
|
src/visual/MeterCanvas.h
|
||||||
src/visual/MeterContext.h
|
src/visual/MeterContext.h
|
||||||
|
src/visual/TuningCanvas.h
|
||||||
|
src/visual/TuningContext.h
|
||||||
src/visual/ScopeCanvas.h
|
src/visual/ScopeCanvas.h
|
||||||
src/visual/ScopeContext.h
|
src/visual/ScopeContext.h
|
||||||
src/visual/SpectrumCanvas.h
|
src/visual/SpectrumCanvas.h
|
||||||
|
@ -36,6 +36,7 @@ AppFrame::AppFrame() :
|
|||||||
wxBoxSizer *demodOpts = new wxBoxSizer(wxVERTICAL);
|
wxBoxSizer *demodOpts = new wxBoxSizer(wxVERTICAL);
|
||||||
wxBoxSizer *demodVisuals = new wxBoxSizer(wxVERTICAL);
|
wxBoxSizer *demodVisuals = new wxBoxSizer(wxVERTICAL);
|
||||||
wxBoxSizer *demodTray = new wxBoxSizer(wxHORIZONTAL);
|
wxBoxSizer *demodTray = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
wxBoxSizer *demodScopeTray = new wxBoxSizer(wxVERTICAL);
|
||||||
|
|
||||||
demodSpectrumCanvas = new SpectrumCanvas(this, NULL);
|
demodSpectrumCanvas = new SpectrumCanvas(this, NULL);
|
||||||
demodSpectrumCanvas->setup(1024);
|
demodSpectrumCanvas->setup(1024);
|
||||||
@ -63,7 +64,15 @@ AppFrame::AppFrame() :
|
|||||||
demodTray->AddSpacer(2);
|
demodTray->AddSpacer(2);
|
||||||
|
|
||||||
scopeCanvas = new ScopeCanvas(this, NULL);
|
scopeCanvas = new ScopeCanvas(this, NULL);
|
||||||
demodTray->Add(scopeCanvas, 30, wxEXPAND | wxALL, 0);
|
demodScopeTray->Add(scopeCanvas, 8, wxEXPAND | wxALL, 0);
|
||||||
|
|
||||||
|
demodScopeTray->AddSpacer(2);
|
||||||
|
|
||||||
|
demodTuner = new TuningCanvas(this, NULL);
|
||||||
|
demodTuner->setHelpTip("Testing tuner");
|
||||||
|
demodScopeTray->Add(demodTuner, 1, wxEXPAND | wxALL, 0);
|
||||||
|
|
||||||
|
demodTray->Add(demodScopeTray, 30, wxEXPAND | wxALL, 0);
|
||||||
|
|
||||||
vbox->Add(demodTray, 2, wxEXPAND | wxALL, 0);
|
vbox->Add(demodTray, 2, wxEXPAND | wxALL, 0);
|
||||||
vbox->AddSpacer(2);
|
vbox->AddSpacer(2);
|
||||||
@ -208,8 +217,8 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
|
|||||||
}
|
}
|
||||||
if (demodWaterfallCanvas->getDragState() == WaterfallCanvas::WF_DRAG_NONE) {
|
if (demodWaterfallCanvas->getDragState() == WaterfallCanvas::WF_DRAG_NONE) {
|
||||||
if (demod->getParams().frequency != demodWaterfallCanvas->getCenterFrequency()) {
|
if (demod->getParams().frequency != demodWaterfallCanvas->getCenterFrequency()) {
|
||||||
demodWaterfallCanvas->setCenterFrequency(demod->getParams().frequency);
|
demodWaterfallCanvas->setCenterFrequency(demod->getFrequency());
|
||||||
demodSpectrumCanvas->setCenterFrequency(demod->getParams().frequency);
|
demodSpectrumCanvas->setCenterFrequency(demod->getFrequency());
|
||||||
}
|
}
|
||||||
unsigned int demodBw = (unsigned int) ceil((float) demod->getParams().bandwidth * 2.5);
|
unsigned int demodBw = (unsigned int) ceil((float) demod->getParams().bandwidth * 2.5);
|
||||||
if (demodBw > SRATE / 2) {
|
if (demodBw > SRATE / 2) {
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "SpectrumCanvas.h"
|
#include "SpectrumCanvas.h"
|
||||||
#include "WaterfallCanvas.h"
|
#include "WaterfallCanvas.h"
|
||||||
#include "MeterCanvas.h"
|
#include "MeterCanvas.h"
|
||||||
|
#include "TuningCanvas.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
@ -36,6 +37,7 @@ private:
|
|||||||
SpectrumCanvas *demodSpectrumCanvas;
|
SpectrumCanvas *demodSpectrumCanvas;
|
||||||
WaterfallCanvas *demodWaterfallCanvas;
|
WaterfallCanvas *demodWaterfallCanvas;
|
||||||
MeterCanvas *demodSignalMeter;
|
MeterCanvas *demodSignalMeter;
|
||||||
|
TuningCanvas *demodTuner;
|
||||||
// event table
|
// event table
|
||||||
|
|
||||||
DemodulatorInstance *activeDemodulator;
|
DemodulatorInstance *activeDemodulator;
|
||||||
|
@ -100,17 +100,17 @@ PrimaryGLContext& CubicSDR::GetContext(wxGLCanvas *canvas) {
|
|||||||
return *glContext;
|
return *glContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CubicSDR::setFrequency(unsigned int freq) {
|
void CubicSDR::setFrequency(long long freq) {
|
||||||
if (freq < SRATE/2) {
|
if (freq < SRATE/2) {
|
||||||
freq = SRATE/2;
|
freq = SRATE/2;
|
||||||
}
|
}
|
||||||
frequency = freq;
|
frequency = freq;
|
||||||
SDRThreadCommand command(SDRThreadCommand::SDR_THREAD_CMD_TUNE);
|
SDRThreadCommand command(SDRThreadCommand::SDR_THREAD_CMD_TUNE);
|
||||||
command.int_value = freq;
|
command.llong_value = freq;
|
||||||
threadCmdQueueSDR->push(command);
|
threadCmdQueueSDR->push(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CubicSDR::getFrequency() {
|
long long CubicSDR::getFrequency() {
|
||||||
return frequency;
|
return frequency;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,8 +29,8 @@ public:
|
|||||||
virtual bool OnInit();
|
virtual bool OnInit();
|
||||||
virtual int OnExit();
|
virtual int OnExit();
|
||||||
|
|
||||||
void setFrequency(unsigned int freq);
|
void setFrequency(long long freq);
|
||||||
int getFrequency();
|
long long getFrequency();
|
||||||
|
|
||||||
DemodulatorThreadOutputQueue* getAudioVisualQueue();
|
DemodulatorThreadOutputQueue* getAudioVisualQueue();
|
||||||
DemodulatorThreadInputQueue* getIQVisualQueue();
|
DemodulatorThreadInputQueue* getIQVisualQueue();
|
||||||
@ -44,7 +44,7 @@ private:
|
|||||||
|
|
||||||
DemodulatorMgr demodMgr;
|
DemodulatorMgr demodMgr;
|
||||||
|
|
||||||
unsigned int frequency;
|
long long frequency;
|
||||||
|
|
||||||
SDRThread *sdrThread;
|
SDRThread *sdrThread;
|
||||||
SDRPostThread *sdrPostThread;
|
SDRPostThread *sdrPostThread;
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
class AudioThreadInput: public ReferenceCounter {
|
class AudioThreadInput: public ReferenceCounter {
|
||||||
public:
|
public:
|
||||||
int frequency;
|
long long frequency;
|
||||||
int sampleRate;
|
int sampleRate;
|
||||||
int channels;
|
int channels;
|
||||||
std::vector<float> data;
|
std::vector<float> data;
|
||||||
|
@ -27,18 +27,18 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
DemodulatorThreadCommand() :
|
DemodulatorThreadCommand() :
|
||||||
cmd(DEMOD_THREAD_CMD_NULL), context(NULL), int_value(0) {
|
cmd(DEMOD_THREAD_CMD_NULL), context(NULL), llong_value(0) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DemodulatorThreadCommand(DemodulatorThreadCommandEnum cmd) :
|
DemodulatorThreadCommand(DemodulatorThreadCommandEnum cmd) :
|
||||||
cmd(cmd), context(NULL), int_value(0) {
|
cmd(cmd), context(NULL), llong_value(0) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DemodulatorThreadCommandEnum cmd;
|
DemodulatorThreadCommandEnum cmd;
|
||||||
void *context;
|
void *context;
|
||||||
int int_value;
|
long long llong_value;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DemodulatorThreadControlCommand {
|
class DemodulatorThreadControlCommand {
|
||||||
@ -57,7 +57,7 @@ public:
|
|||||||
|
|
||||||
class DemodulatorThreadIQData: public ReferenceCounter {
|
class DemodulatorThreadIQData: public ReferenceCounter {
|
||||||
public:
|
public:
|
||||||
unsigned int frequency;
|
long long frequency;
|
||||||
unsigned int bandwidth;
|
unsigned int bandwidth;
|
||||||
std::vector<liquid_float_complex> data;
|
std::vector<liquid_float_complex> data;
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ public:
|
|||||||
|
|
||||||
class DemodulatorThreadAudioData: public ReferenceCounter {
|
class DemodulatorThreadAudioData: public ReferenceCounter {
|
||||||
public:
|
public:
|
||||||
unsigned int frequency;
|
long long frequency;
|
||||||
unsigned int sampleRate;
|
unsigned int sampleRate;
|
||||||
unsigned char channels;
|
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) {
|
frequency(frequency), sampleRate(sampleRate), channels(1), data(data) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -119,7 +119,7 @@ typedef ThreadQueue<DemodulatorThreadControlCommand> DemodulatorThreadControlCom
|
|||||||
|
|
||||||
class DemodulatorThreadParameters {
|
class DemodulatorThreadParameters {
|
||||||
public:
|
public:
|
||||||
unsigned int frequency;
|
long long frequency;
|
||||||
unsigned int inputRate;
|
unsigned int inputRate;
|
||||||
unsigned int bandwidth; // set equal to disable second stage re-sampling?
|
unsigned int bandwidth; // set equal to disable second stage re-sampling?
|
||||||
unsigned int audioSampleRate;
|
unsigned int audioSampleRate;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
DemodulatorInstance::DemodulatorInstance() :
|
DemodulatorInstance::DemodulatorInstance() :
|
||||||
t_Demod(NULL), t_PreDemod(NULL), t_Audio(NULL), threadQueueDemod(NULL), demodulatorThread(NULL), terminated(false), audioTerminated(false), demodTerminated(
|
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");
|
label = new std::string("Unnamed");
|
||||||
threadQueueDemod = new DemodulatorThreadInputQueue;
|
threadQueueDemod = new DemodulatorThreadInputQueue;
|
||||||
@ -36,6 +36,8 @@ void DemodulatorInstance::setVisualOutputQueue(DemodulatorThreadOutputQueue *tQu
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DemodulatorInstance::run() {
|
void DemodulatorInstance::run() {
|
||||||
|
currentFrequency = demodulatorPreThread->getParams().frequency;
|
||||||
|
|
||||||
t_Audio = new std::thread(&AudioThread::threadMain, audioThread);
|
t_Audio = new std::thread(&AudioThread::threadMain, audioThread);
|
||||||
|
|
||||||
#ifdef __APPLE__ // Already using pthreads, might as well do some custom init..
|
#ifdef __APPLE__ // Already using pthreads, might as well do some custom init..
|
||||||
@ -63,10 +65,10 @@ void DemodulatorInstance::run() {
|
|||||||
active = true;
|
active = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DemodulatorInstance::updateLabel(int freq) {
|
void DemodulatorInstance::updateLabel(long long freq) {
|
||||||
std::stringstream newLabel;
|
std::stringstream newLabel;
|
||||||
newLabel.precision(3);
|
newLabel.precision(3);
|
||||||
newLabel << std::fixed << ((float) freq / 1000000.0);
|
newLabel << std::fixed << ((long double) freq / 1000000.0);
|
||||||
setLabel(newLabel.str());
|
setLabel(newLabel.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,7 +236,7 @@ void DemodulatorInstance::setBandwidth(int bw) {
|
|||||||
command.cmd = DemodulatorThreadCommand::DEMOD_THREAD_CMD_SET_BANDWIDTH;
|
command.cmd = DemodulatorThreadCommand::DEMOD_THREAD_CMD_SET_BANDWIDTH;
|
||||||
currentBandwidth = bw;
|
currentBandwidth = bw;
|
||||||
checkBandwidth();
|
checkBandwidth();
|
||||||
command.int_value = currentBandwidth;
|
command.llong_value = currentBandwidth;
|
||||||
threadQueueCommand->push(command);
|
threadQueueCommand->push(command);
|
||||||
}
|
}
|
||||||
demodulatorPreThread->getParams().bandwidth;
|
demodulatorPreThread->getParams().bandwidth;
|
||||||
@ -247,21 +249,21 @@ int DemodulatorInstance::getBandwidth() {
|
|||||||
return currentBandwidth;
|
return currentBandwidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DemodulatorInstance::setFrequency(unsigned int freq) {
|
void DemodulatorInstance::setFrequency(long long freq) {
|
||||||
if (((long)freq - getBandwidth()/2) < SRATE/2) {
|
if ((freq - getBandwidth()/2) < SRATE/2) {
|
||||||
freq = SRATE/2 - getBandwidth()/2;
|
freq = SRATE/2 - getBandwidth()/2;
|
||||||
}
|
}
|
||||||
if (demodulatorPreThread && threadQueueCommand) {
|
if (demodulatorPreThread && threadQueueCommand) {
|
||||||
DemodulatorThreadCommand command;
|
DemodulatorThreadCommand command;
|
||||||
command.cmd = DemodulatorThreadCommand::DEMOD_THREAD_CMD_SET_FREQUENCY;
|
command.cmd = DemodulatorThreadCommand::DEMOD_THREAD_CMD_SET_FREQUENCY;
|
||||||
currentFrequency = freq;
|
currentFrequency = freq;
|
||||||
command.int_value = freq;
|
command.llong_value = freq;
|
||||||
threadQueueCommand->push(command);
|
threadQueueCommand->push(command);
|
||||||
}
|
}
|
||||||
demodulatorPreThread->getParams().bandwidth;
|
demodulatorPreThread->getParams().bandwidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DemodulatorInstance::getFrequency() {
|
long long DemodulatorInstance::getFrequency() {
|
||||||
if (!currentFrequency) {
|
if (!currentFrequency) {
|
||||||
currentFrequency = demodulatorPreThread->getParams().frequency;
|
currentFrequency = demodulatorPreThread->getParams().frequency;
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ public:
|
|||||||
void setLabel(std::string labelStr);
|
void setLabel(std::string labelStr);
|
||||||
|
|
||||||
bool isTerminated();
|
bool isTerminated();
|
||||||
void updateLabel(int freq);
|
void updateLabel(long long freq);
|
||||||
|
|
||||||
bool isActive();
|
bool isActive();
|
||||||
void setActive(bool state);
|
void setActive(bool state);
|
||||||
@ -69,8 +69,8 @@ public:
|
|||||||
void setBandwidth(int bw);
|
void setBandwidth(int bw);
|
||||||
int getBandwidth();
|
int getBandwidth();
|
||||||
|
|
||||||
void setFrequency(unsigned int freq);
|
void setFrequency(long long freq);
|
||||||
int getFrequency();
|
long long getFrequency();
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void checkBandwidth();
|
void checkBandwidth();
|
||||||
@ -84,7 +84,7 @@ private:
|
|||||||
std::atomic<bool> squelch;
|
std::atomic<bool> squelch;
|
||||||
std::atomic<bool> stereo;
|
std::atomic<bool> stereo;
|
||||||
|
|
||||||
int currentDemodType;
|
long long currentFrequency;
|
||||||
int currentBandwidth;
|
int currentBandwidth;
|
||||||
int currentFrequency;
|
int currentDemodType;
|
||||||
};
|
};
|
||||||
|
@ -62,17 +62,17 @@ void DemodulatorMgr::deleteThread(DemodulatorInstance *demod) {
|
|||||||
garbageCollect();
|
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 *>();
|
std::vector<DemodulatorInstance *> *foundDemods = new std::vector<DemodulatorInstance *>();
|
||||||
|
|
||||||
for (int i = 0, iMax = demods.size(); i < iMax; i++) {
|
for (int i = 0, iMax = demods.size(); i < iMax; i++) {
|
||||||
DemodulatorInstance *testDemod = demods[i];
|
DemodulatorInstance *testDemod = demods[i];
|
||||||
|
|
||||||
int freqTest = testDemod->getParams().frequency;
|
long long freqTest = testDemod->getParams().frequency;
|
||||||
int bandwidthTest = testDemod->getParams().bandwidth;
|
long long bandwidthTest = testDemod->getParams().bandwidth;
|
||||||
int halfBandwidthTest = bandwidthTest / 2;
|
long long halfBandwidthTest = bandwidthTest / 2;
|
||||||
|
|
||||||
int halfBuffer = bandwidth / 2;
|
long long halfBuffer = bandwidth / 2;
|
||||||
|
|
||||||
if ((freq <= (freqTest + halfBandwidthTest + halfBuffer)) && (freq >= (freqTest - halfBandwidthTest - halfBuffer))) {
|
if ((freq <= (freqTest + halfBandwidthTest + halfBuffer)) && (freq >= (freqTest - halfBandwidthTest - halfBuffer))) {
|
||||||
foundDemods->push_back(testDemod);
|
foundDemods->push_back(testDemod);
|
||||||
|
@ -13,7 +13,7 @@ public:
|
|||||||
|
|
||||||
DemodulatorInstance *newThread();
|
DemodulatorInstance *newThread();
|
||||||
std::vector<DemodulatorInstance *> &getDemodulators();
|
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 deleteThread(DemodulatorInstance *);
|
||||||
|
|
||||||
void terminateAll();
|
void terminateAll();
|
||||||
|
@ -84,17 +84,17 @@ void DemodulatorPreThread::threadMain() {
|
|||||||
commandQueue->pop(command);
|
commandQueue->pop(command);
|
||||||
switch (command.cmd) {
|
switch (command.cmd) {
|
||||||
case DemodulatorThreadCommand::DEMOD_THREAD_CMD_SET_BANDWIDTH:
|
case DemodulatorThreadCommand::DEMOD_THREAD_CMD_SET_BANDWIDTH:
|
||||||
if (command.int_value < 1500) {
|
if (command.llong_value < 1500) {
|
||||||
command.int_value = 1500;
|
command.llong_value = 1500;
|
||||||
}
|
}
|
||||||
if (command.int_value > SRATE) {
|
if (command.llong_value > SRATE) {
|
||||||
command.int_value = SRATE;
|
command.llong_value = SRATE;
|
||||||
}
|
}
|
||||||
bandwidthParams.bandwidth = command.int_value;
|
bandwidthParams.bandwidth = command.llong_value;
|
||||||
bandwidthChanged = true;
|
bandwidthChanged = true;
|
||||||
break;
|
break;
|
||||||
case DemodulatorThreadCommand::DEMOD_THREAD_CMD_SET_FREQUENCY:
|
case DemodulatorThreadCommand::DEMOD_THREAD_CMD_SET_FREQUENCY:
|
||||||
params.frequency = command.int_value;
|
params.frequency = command.llong_value;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ public:
|
|||||||
|
|
||||||
DemodulatorThreadCommandEnum cmd;
|
DemodulatorThreadCommandEnum cmd;
|
||||||
|
|
||||||
unsigned int frequency;
|
long long frequency;
|
||||||
unsigned int inputRate;
|
unsigned int inputRate;
|
||||||
unsigned int bandwidth;
|
unsigned int bandwidth;
|
||||||
unsigned int audioSampleRate;
|
unsigned int audioSampleRate;
|
||||||
|
@ -132,7 +132,7 @@ void SDRPostThread::threadMain() {
|
|||||||
DemodulatorInstance *demod = *i;
|
DemodulatorInstance *demod = *i;
|
||||||
|
|
||||||
if (demod->getParams().frequency != data_in->frequency
|
if (demod->getParams().frequency != data_in->frequency
|
||||||
&& abs(data_in->frequency - demod->getParams().frequency) > (int) ((double) ((double) SRATE / 2.0))) {
|
&& abs(data_in->frequency - demod->getParams().frequency) > (SRATE / 2)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
activeDemods++;
|
activeDemods++;
|
||||||
@ -166,7 +166,7 @@ void SDRPostThread::threadMain() {
|
|||||||
DemodulatorThreadInputQueue *demodQueue = demod->threadQueueDemod;
|
DemodulatorThreadInputQueue *demodQueue = demod->threadQueueDemod;
|
||||||
|
|
||||||
if (demod->getParams().frequency != data_in->frequency
|
if (demod->getParams().frequency != data_in->frequency
|
||||||
&& abs(data_in->frequency - demod->getParams().frequency) > (int) ((double) ((double) SRATE / 2.0))) {
|
&& abs(data_in->frequency - demod->getParams().frequency) > (SRATE / 2)) {
|
||||||
if (demod->isActive()) {
|
if (demod->isActive()) {
|
||||||
demod->setActive(false);
|
demod->setActive(false);
|
||||||
DemodulatorThreadIQData *dummyDataOut = new DemodulatorThreadIQData;
|
DemodulatorThreadIQData *dummyDataOut = new DemodulatorThreadIQData;
|
||||||
|
@ -110,7 +110,7 @@ void SDRThread::threadMain() {
|
|||||||
|
|
||||||
signed char buf[BUF_SIZE];
|
signed char buf[BUF_SIZE];
|
||||||
|
|
||||||
unsigned int frequency = DEFAULT_FREQ;
|
long long frequency = DEFAULT_FREQ;
|
||||||
unsigned int bandwidth = SRATE;
|
unsigned int bandwidth = SRATE;
|
||||||
|
|
||||||
rtlsdr_open(&dev, firstDevAvailable);
|
rtlsdr_open(&dev, firstDevAvailable);
|
||||||
@ -137,7 +137,7 @@ void SDRThread::threadMain() {
|
|||||||
|
|
||||||
if (!cmdQueue->empty()) {
|
if (!cmdQueue->empty()) {
|
||||||
bool freq_changed = false;
|
bool freq_changed = false;
|
||||||
float new_freq;
|
long long new_freq;
|
||||||
|
|
||||||
while (!cmdQueue->empty()) {
|
while (!cmdQueue->empty()) {
|
||||||
SDRThreadCommand command;
|
SDRThreadCommand command;
|
||||||
@ -146,7 +146,7 @@ void SDRThread::threadMain() {
|
|||||||
switch (command.cmd) {
|
switch (command.cmd) {
|
||||||
case SDRThreadCommand::SDR_THREAD_CMD_TUNE:
|
case SDRThreadCommand::SDR_THREAD_CMD_TUNE:
|
||||||
freq_changed = true;
|
freq_changed = true;
|
||||||
new_freq = command.int_value;
|
new_freq = command.llong_value;
|
||||||
if (new_freq < SRATE / 2) {
|
if (new_freq < SRATE / 2) {
|
||||||
new_freq = SRATE / 2;
|
new_freq = SRATE / 2;
|
||||||
}
|
}
|
||||||
|
@ -21,22 +21,22 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
SDRThreadCommand() :
|
SDRThreadCommand() :
|
||||||
cmd(SDR_THREAD_CMD_NULL), int_value(0) {
|
cmd(SDR_THREAD_CMD_NULL), llong_value(0) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SDRThreadCommand(SDRThreadCommandEnum cmd) :
|
SDRThreadCommand(SDRThreadCommandEnum cmd) :
|
||||||
cmd(cmd), int_value(0) {
|
cmd(cmd), llong_value(0) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SDRThreadCommandEnum cmd;
|
SDRThreadCommandEnum cmd;
|
||||||
int int_value;
|
long long llong_value;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SDRThreadIQData: public ReferenceCounter {
|
class SDRThreadIQData: public ReferenceCounter {
|
||||||
public:
|
public:
|
||||||
unsigned int frequency;
|
long long frequency;
|
||||||
unsigned int bandwidth;
|
unsigned int bandwidth;
|
||||||
std::vector<signed char> data;
|
std::vector<signed char> data;
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SDRThreadIQData(unsigned int bandwidth, unsigned int frequency, std::vector<signed char> *data) :
|
SDRThreadIQData(unsigned int bandwidth, long long frequency, std::vector<signed char> *data) :
|
||||||
frequency(frequency), bandwidth(bandwidth) {
|
frequency(frequency), bandwidth(bandwidth) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ InteractiveCanvas::InteractiveCanvas(wxWindow *parent, int *attribList) :
|
|||||||
InteractiveCanvas::~InteractiveCanvas() {
|
InteractiveCanvas::~InteractiveCanvas() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void InteractiveCanvas::setView(int center_freq_in, int bandwidth_in) {
|
void InteractiveCanvas::setView(long long center_freq_in, int bandwidth_in) {
|
||||||
isView = true;
|
isView = true;
|
||||||
centerFreq = center_freq_in;
|
centerFreq = center_freq_in;
|
||||||
bandwidth = bandwidth_in;
|
bandwidth = bandwidth_in;
|
||||||
@ -41,23 +41,23 @@ void InteractiveCanvas::disableView() {
|
|||||||
lastBandwidth = 0;
|
lastBandwidth = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int InteractiveCanvas::getFrequencyAt(float x) {
|
long long InteractiveCanvas::getFrequencyAt(float x) {
|
||||||
int iqCenterFreq = getCenterFrequency();
|
long long iqCenterFreq = getCenterFrequency();
|
||||||
int iqBandwidth = getBandwidth();
|
long long iqBandwidth = getBandwidth();
|
||||||
int freq = iqCenterFreq - (int) (0.5 * (float) iqBandwidth) + (int) ((float) x * (float) iqBandwidth);
|
long long freq = iqCenterFreq - (long long)(0.5 * (long double) iqBandwidth) + ((long double) x * (long double) iqBandwidth);
|
||||||
|
|
||||||
return freq;
|
return freq;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InteractiveCanvas::setCenterFrequency(unsigned int center_freq_in) {
|
void InteractiveCanvas::setCenterFrequency(long long center_freq_in) {
|
||||||
centerFreq = center_freq_in;
|
centerFreq = center_freq_in;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int InteractiveCanvas::getCenterFrequency() {
|
long long InteractiveCanvas::getCenterFrequency() {
|
||||||
if (isView) {
|
if (isView) {
|
||||||
return centerFreq;
|
return centerFreq;
|
||||||
} else {
|
} else {
|
||||||
return (unsigned int) wxGetApp().getFrequency();
|
return wxGetApp().getFrequency();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,13 +11,13 @@ public:
|
|||||||
InteractiveCanvas(wxWindow *parent, int *attribList = NULL);
|
InteractiveCanvas(wxWindow *parent, int *attribList = NULL);
|
||||||
~InteractiveCanvas();
|
~InteractiveCanvas();
|
||||||
|
|
||||||
int getFrequencyAt(float x);
|
long long getFrequencyAt(float x);
|
||||||
|
|
||||||
void setView(int center_freq_in, int bandwidth_in);
|
void setView(long long center_freq_in, int bandwidth_in);
|
||||||
void disableView();
|
void disableView();
|
||||||
|
|
||||||
void setCenterFrequency(unsigned int center_freq_in);
|
void setCenterFrequency(long long center_freq_in);
|
||||||
unsigned int getCenterFrequency();
|
long long getCenterFrequency();
|
||||||
|
|
||||||
void setBandwidth(unsigned int bandwidth_in);
|
void setBandwidth(unsigned int bandwidth_in);
|
||||||
unsigned int getBandwidth();
|
unsigned int getBandwidth();
|
||||||
@ -45,7 +45,7 @@ protected:
|
|||||||
bool altDown;
|
bool altDown;
|
||||||
bool ctrlDown;
|
bool ctrlDown;
|
||||||
|
|
||||||
unsigned int centerFreq;
|
long long centerFreq;
|
||||||
unsigned int bandwidth;
|
unsigned int bandwidth;
|
||||||
unsigned int lastBandwidth;
|
unsigned int lastBandwidth;
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ GLFont &PrimaryGLContext::getFont(GLFontSize esize) {
|
|||||||
return fonts[esize];
|
return fonts[esize];
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrimaryGLContext::DrawDemodInfo(DemodulatorInstance *demod, float r, float g, float b, int center_freq, int srate) {
|
void PrimaryGLContext::DrawDemodInfo(DemodulatorInstance *demod, float r, float g, float b, long long center_freq, long long srate) {
|
||||||
if (!demod) {
|
if (!demod) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -153,7 +153,7 @@ void PrimaryGLContext::DrawDemodInfo(DemodulatorInstance *demod, float r, float
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrimaryGLContext::DrawDemod(DemodulatorInstance *demod, float r, float g, float b, int center_freq, int srate) {
|
void PrimaryGLContext::DrawDemod(DemodulatorInstance *demod, float r, float g, float b, long long center_freq, long long srate) {
|
||||||
if (!demod) {
|
if (!demod) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -246,10 +246,10 @@ void PrimaryGLContext::DrawDemod(DemodulatorInstance *demod, float r, float g, f
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrimaryGLContext::DrawFreqSelector(float uxPos, float r, float g, float b, float w, int center_freq, int srate) {
|
void PrimaryGLContext::DrawFreqSelector(float uxPos, float r, float g, float b, float w, long long center_freq, long long srate) {
|
||||||
DemodulatorInstance *demod = wxGetApp().getDemodMgr().getLastActiveDemodulator();
|
DemodulatorInstance *demod = wxGetApp().getDemodMgr().getLastActiveDemodulator();
|
||||||
|
|
||||||
int bw = 0;
|
long long bw = 0;
|
||||||
|
|
||||||
if (!demod) {
|
if (!demod) {
|
||||||
bw = defaultDemodParams.bandwidth;
|
bw = defaultDemodParams.bandwidth;
|
||||||
|
@ -23,9 +23,9 @@ public:
|
|||||||
void BeginDraw();
|
void BeginDraw();
|
||||||
void EndDraw();
|
void EndDraw();
|
||||||
|
|
||||||
void DrawFreqSelector(float uxPos, float r = 1, float g = 1, float b = 1, float w = 0, int center_freq = -1, int srate = SRATE);
|
void DrawFreqSelector(float uxPos, float r = 1, float g = 1, float b = 1, float w = 0, long long center_freq = -1, long long srate = SRATE);
|
||||||
void DrawDemod(DemodulatorInstance *demod, float r = 1, float g = 1, float b = 1, int center_freq = -1, int srate = SRATE);
|
void DrawDemod(DemodulatorInstance *demod, float r = 1, float g = 1, float b = 1, long long center_freq = -1, long long srate = SRATE);
|
||||||
void DrawDemodInfo(DemodulatorInstance *demod, float r = 1, float g = 1, float b = 1, int center_freq = -1, int srate = SRATE);
|
void DrawDemodInfo(DemodulatorInstance *demod, float r = 1, float g = 1, float b = 1, long long center_freq = -1, long long srate = SRATE);
|
||||||
|
|
||||||
static GLFont &getFont(GLFontSize esize);
|
static GLFont &getFont(GLFontSize esize);
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ void SpectrumCanvas::OnMouseMoved(wxMouseEvent& event) {
|
|||||||
int freqChange = mouseTracker.getDeltaMouseX() * getBandwidth();
|
int freqChange = mouseTracker.getDeltaMouseX() * getBandwidth();
|
||||||
|
|
||||||
if (freqChange != 0) {
|
if (freqChange != 0) {
|
||||||
unsigned int freq = wxGetApp().getFrequency();
|
long long freq = wxGetApp().getFrequency();
|
||||||
|
|
||||||
if (isView) {
|
if (isView) {
|
||||||
centerFreq = centerFreq - freqChange;
|
centerFreq = centerFreq - freqChange;
|
||||||
@ -187,19 +187,18 @@ void SpectrumCanvas::OnMouseMoved(wxMouseEvent& event) {
|
|||||||
waterfallCanvas->setCenterFrequency(centerFreq);
|
waterfallCanvas->setCenterFrequency(centerFreq);
|
||||||
}
|
}
|
||||||
|
|
||||||
long bw = (long) bandwidth;
|
long long bwOfs = (centerFreq > freq) ? ((long long) bandwidth / 2) : (-(long long) bandwidth / 2);
|
||||||
long bwOfs = (centerFreq > freq) ? ((long) bandwidth / 2) : (-(long) bandwidth / 2);
|
long long freqEdge = centerFreq + bwOfs;
|
||||||
long freqEdge = ((long) centerFreq + bwOfs);
|
|
||||||
|
|
||||||
if (abs((long) freq - freqEdge) > (SRATE / 2)) {
|
if (abs(freq - freqEdge) > (SRATE / 2)) {
|
||||||
freqChange = -((centerFreq > freq) ? (freqEdge - (long)freq - (SRATE / 2)) : (freqEdge - (long)freq + (SRATE / 2)));
|
freqChange = -((centerFreq > freq) ? (freqEdge - freq - (SRATE / 2)) : (freqEdge - freq + (SRATE / 2)));
|
||||||
} else {
|
} else {
|
||||||
freqChange = 0;
|
freqChange = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (freqChange) {
|
if (freqChange) {
|
||||||
if ((long)freq - freqChange < SRATE/2) {
|
if (freq - freqChange < SRATE/2) {
|
||||||
freq = SRATE/2;
|
freq = SRATE/2;
|
||||||
} else {
|
} else {
|
||||||
freq -= freqChange;
|
freq -= freqChange;
|
||||||
|
@ -15,7 +15,7 @@ SpectrumContext::SpectrumContext(SpectrumCanvas *canvas, wxGLContext *sharedCont
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpectrumContext::Draw(std::vector<float> &points, int freq, int bandwidth) {
|
void SpectrumContext::Draw(std::vector<float> &points, long long freq, int bandwidth) {
|
||||||
|
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
glColor3f(1.0, 1.0, 1.0);
|
glColor3f(1.0, 1.0, 1.0);
|
||||||
@ -37,14 +37,14 @@ void SpectrumContext::Draw(std::vector<float> &points, int freq, int bandwidth)
|
|||||||
float viewHeight = (float) vp[3];
|
float viewHeight = (float) vp[3];
|
||||||
float viewWidth = (float) vp[2];
|
float viewWidth = (float) vp[2];
|
||||||
|
|
||||||
float leftFreq = (float) freq - ((float) bandwidth / 2.0);
|
long long leftFreq = (float) freq - ((float) bandwidth / 2.0);
|
||||||
float rightFreq = leftFreq + (float) bandwidth;
|
long long rightFreq = leftFreq + (float) bandwidth;
|
||||||
|
|
||||||
float firstMhz = floor(leftFreq / 1000000.0) * 1000000.0;
|
long long firstMhz = (leftFreq / 1000000) * 1000000;
|
||||||
float mhzStart = ((firstMhz - leftFreq) / (rightFreq - leftFreq)) * 2.0;
|
long double mhzStart = ((long double)(firstMhz - leftFreq) / (long double)(rightFreq - leftFreq)) * 2.0;
|
||||||
float mhzStep = (100000.0 / (rightFreq - leftFreq)) * 2.0;
|
long double mhzStep = (100000.0 / (long double)(rightFreq - leftFreq)) * 2.0;
|
||||||
|
|
||||||
double currentMhz = trunc(floor(firstMhz / 1000000.0));
|
long double currentMhz = trunc(floor(firstMhz / 1000000.0));
|
||||||
|
|
||||||
std::stringstream label;
|
std::stringstream label;
|
||||||
label.precision(2);
|
label.precision(2);
|
||||||
|
@ -11,7 +11,7 @@ class SpectrumContext: public PrimaryGLContext {
|
|||||||
public:
|
public:
|
||||||
SpectrumContext(SpectrumCanvas *canvas, wxGLContext *sharedContext);
|
SpectrumContext(SpectrumCanvas *canvas, wxGLContext *sharedContext);
|
||||||
|
|
||||||
void Draw(std::vector<float> &points, int freq, int bandwidth);
|
void Draw(std::vector<float> &points, long long freq, int bandwidth);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int fft_size;
|
int fft_size;
|
||||||
|
91
src/visual/TuningCanvas.cpp
Normal file
91
src/visual/TuningCanvas.cpp
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
#include "TuningCanvas.h"
|
||||||
|
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include "wx/wx.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !wxUSE_GLCANVAS
|
||||||
|
#error "OpenGL required: set wxUSE_GLCANVAS to 1 and rebuild the library"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "CubicSDR.h"
|
||||||
|
#include "CubicSDRDefs.h"
|
||||||
|
#include "AppFrame.h"
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
wxBEGIN_EVENT_TABLE(TuningCanvas, wxGLCanvas) EVT_PAINT(TuningCanvas::OnPaint)
|
||||||
|
EVT_IDLE(TuningCanvas::OnIdle)
|
||||||
|
EVT_MOTION(TuningCanvas::OnMouseMoved)
|
||||||
|
EVT_LEFT_DOWN(TuningCanvas::OnMouseDown)
|
||||||
|
EVT_LEFT_UP(TuningCanvas::OnMouseReleased)
|
||||||
|
EVT_LEAVE_WINDOW(TuningCanvas::OnMouseLeftWindow)
|
||||||
|
EVT_ENTER_WINDOW(TuningCanvas::OnMouseEnterWindow)
|
||||||
|
wxEND_EVENT_TABLE()
|
||||||
|
|
||||||
|
TuningCanvas::TuningCanvas(wxWindow *parent, int *attribList) :
|
||||||
|
InteractiveCanvas(parent, attribList) {
|
||||||
|
|
||||||
|
glContext = new TuningContext(this, &wxGetApp().GetContext(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
TuningCanvas::~TuningCanvas() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void TuningCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
|
||||||
|
wxPaintDC dc(this);
|
||||||
|
const wxSize ClientSize = GetClientSize();
|
||||||
|
|
||||||
|
glContext->SetCurrent(*this);
|
||||||
|
glViewport(0, 0, ClientSize.x, ClientSize.y);
|
||||||
|
|
||||||
|
glContext->DrawBegin();
|
||||||
|
|
||||||
|
DemodulatorInstance *activeDemod = wxGetApp().getDemodMgr().getLastActiveDemodulator();
|
||||||
|
|
||||||
|
if (activeDemod != NULL) {
|
||||||
|
glContext->DrawDemodFreqBw(activeDemod->getFrequency(),activeDemod->getBandwidth(),wxGetApp().getFrequency());
|
||||||
|
}
|
||||||
|
|
||||||
|
glContext->DrawEnd();
|
||||||
|
|
||||||
|
SwapBuffers();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TuningCanvas::OnIdle(wxIdleEvent &event) {
|
||||||
|
Refresh(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TuningCanvas::OnMouseMoved(wxMouseEvent& event) {
|
||||||
|
InteractiveCanvas::OnMouseMoved(event);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void TuningCanvas::OnMouseDown(wxMouseEvent& event) {
|
||||||
|
InteractiveCanvas::OnMouseDown(event);
|
||||||
|
mouseTracker.setHorizDragLock(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TuningCanvas::OnMouseWheelMoved(wxMouseEvent& event) {
|
||||||
|
InteractiveCanvas::OnMouseWheelMoved(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TuningCanvas::OnMouseReleased(wxMouseEvent& event) {
|
||||||
|
InteractiveCanvas::OnMouseReleased(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TuningCanvas::OnMouseLeftWindow(wxMouseEvent& event) {
|
||||||
|
InteractiveCanvas::OnMouseLeftWindow(event);
|
||||||
|
SetCursor(wxCURSOR_CROSS);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TuningCanvas::OnMouseEnterWindow(wxMouseEvent& event) {
|
||||||
|
InteractiveCanvas::mouseTracker.OnMouseEnterWindow(event);
|
||||||
|
SetCursor(wxCURSOR_CROSS);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TuningCanvas::setHelpTip(std::string tip) {
|
||||||
|
helpTip = tip;
|
||||||
|
}
|
40
src/visual/TuningCanvas.h
Normal file
40
src/visual/TuningCanvas.h
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "wx/glcanvas.h"
|
||||||
|
#include "wx/timer.h"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <queue>
|
||||||
|
|
||||||
|
#include "InteractiveCanvas.h"
|
||||||
|
#include "TuningContext.h"
|
||||||
|
#include "MouseTracker.h"
|
||||||
|
|
||||||
|
#include "fftw3.h"
|
||||||
|
#include "Timer.h"
|
||||||
|
|
||||||
|
class TuningCanvas: public InteractiveCanvas {
|
||||||
|
public:
|
||||||
|
TuningCanvas(wxWindow *parent, int *attribList = NULL);
|
||||||
|
~TuningCanvas();
|
||||||
|
|
||||||
|
void setHelpTip(std::string tip);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void OnPaint(wxPaintEvent& event);
|
||||||
|
void OnIdle(wxIdleEvent &event);
|
||||||
|
|
||||||
|
void OnMouseMoved(wxMouseEvent& event);
|
||||||
|
void OnMouseDown(wxMouseEvent& event);
|
||||||
|
void OnMouseWheelMoved(wxMouseEvent& event);
|
||||||
|
void OnMouseReleased(wxMouseEvent& event);
|
||||||
|
void OnMouseEnterWindow(wxMouseEvent& event);
|
||||||
|
void OnMouseLeftWindow(wxMouseEvent& event);
|
||||||
|
|
||||||
|
TuningContext *glContext;
|
||||||
|
|
||||||
|
std::string helpTip;
|
||||||
|
//
|
||||||
|
wxDECLARE_EVENT_TABLE();
|
||||||
|
};
|
||||||
|
|
87
src/visual/TuningContext.cpp
Normal file
87
src/visual/TuningContext.cpp
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
#include "TuningContext.h"
|
||||||
|
#include "TuningCanvas.h"
|
||||||
|
|
||||||
|
// http://stackoverflow.com/questions/7276826/c-format-number-with-commas
|
||||||
|
class comma_numpunct: public std::numpunct<char> {
|
||||||
|
protected:
|
||||||
|
virtual char do_thousands_sep() const {
|
||||||
|
return ',';
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual std::string do_grouping() const {
|
||||||
|
return "\03";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TuningContext::TuningContext(TuningCanvas *canvas, wxGLContext *sharedContext) :
|
||||||
|
PrimaryGLContext(canvas, sharedContext) {
|
||||||
|
glDisable(GL_CULL_FACE);
|
||||||
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
|
||||||
|
comma_locale = std::locale(std::locale(), new comma_numpunct());
|
||||||
|
freqStr.imbue(comma_locale);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TuningContext::DrawBegin() {
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glLoadIdentity();
|
||||||
|
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TuningContext::Draw(float r, float g, float b, float a, float level) {
|
||||||
|
glEnable(GL_BLEND);
|
||||||
|
glBlendFunc(GL_ONE, GL_ONE);
|
||||||
|
glColor4f(r, g, b, a);
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
glVertex2f(1.0, -1.0 + 2.0 * level);
|
||||||
|
glVertex2f(-1.0, -1.0 + 2.0 * level);
|
||||||
|
glVertex2f(-1.0, -1.0);
|
||||||
|
glVertex2f(1.0, -1.0);
|
||||||
|
glEnd();
|
||||||
|
glDisable(GL_BLEND);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TuningContext::DrawEnd() {
|
||||||
|
glFlush();
|
||||||
|
|
||||||
|
CheckGLError();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TuningContext::DrawDemodFreqBw(long long freq, unsigned int bw, long long center) {
|
||||||
|
GLint vp[4];
|
||||||
|
glGetIntegerv( GL_VIEWPORT, vp);
|
||||||
|
|
||||||
|
float viewHeight = (float) vp[3];
|
||||||
|
float viewWidth = (float) vp[2];
|
||||||
|
|
||||||
|
PrimaryGLContext::GLFontSize fontSize = GLFONT_SIZE16;
|
||||||
|
|
||||||
|
int fontHeight = 16;
|
||||||
|
|
||||||
|
if (viewWidth < 400) {
|
||||||
|
fontSize = GLFONT_SIZE12;
|
||||||
|
fontHeight = 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
getFont(fontSize).drawString("Freq: ", -0.75, 0, fontHeight, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER);
|
||||||
|
freqStr.str("");
|
||||||
|
freqStr << std::fixed << freq << "Hz";
|
||||||
|
getFont(fontSize).drawString(freqStr.str(), -0.75, 0, fontHeight, GLFont::GLFONT_ALIGN_LEFT, GLFont::GLFONT_ALIGN_CENTER);
|
||||||
|
|
||||||
|
getFont(fontSize).drawString("BW: ", -0.10, 0, fontHeight, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER);
|
||||||
|
freqStr.str("");
|
||||||
|
freqStr << std::fixed << bw << "Hz";
|
||||||
|
getFont(fontSize).drawString(freqStr.str(), -0.10, 0, fontHeight, GLFont::GLFONT_ALIGN_LEFT, GLFont::GLFONT_ALIGN_CENTER);
|
||||||
|
|
||||||
|
getFont(fontSize).drawString("CTR: ", 0.50, 0, fontHeight, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER);
|
||||||
|
freqStr.str("");
|
||||||
|
freqStr << std::fixed << center << "Hz";
|
||||||
|
getFont(fontSize).drawString(freqStr.str(), 0.50, 0, fontHeight, GLFont::GLFONT_ALIGN_LEFT, GLFont::GLFONT_ALIGN_CENTER);
|
||||||
|
}
|
||||||
|
|
22
src/visual/TuningContext.h
Normal file
22
src/visual/TuningContext.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "PrimaryGLContext.h"
|
||||||
|
#include "Gradient.h"
|
||||||
|
|
||||||
|
#define NUM_WATERFALL_LINES 512
|
||||||
|
|
||||||
|
class TuningCanvas;
|
||||||
|
|
||||||
|
class TuningContext: public PrimaryGLContext {
|
||||||
|
public:
|
||||||
|
TuningContext(TuningCanvas *canvas, wxGLContext *sharedContext);
|
||||||
|
|
||||||
|
void DrawBegin();
|
||||||
|
void Draw(float r, float g, float b, float a, float level);
|
||||||
|
void DrawDemodFreqBw(long long freq, unsigned int bw, long long center);
|
||||||
|
void DrawEnd();
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::locale comma_locale;
|
||||||
|
std::stringstream freqStr;
|
||||||
|
};
|
@ -33,8 +33,8 @@ EVT_ENTER_WINDOW(WaterfallCanvas::OnMouseEnterWindow)
|
|||||||
wxEND_EVENT_TABLE()
|
wxEND_EVENT_TABLE()
|
||||||
|
|
||||||
WaterfallCanvas::WaterfallCanvas(wxWindow *parent, int *attribList) :
|
WaterfallCanvas::WaterfallCanvas(wxWindow *parent, int *attribList) :
|
||||||
InteractiveCanvas(parent, attribList), spectrumCanvas(NULL), dragState(
|
InteractiveCanvas(parent, attribList), spectrumCanvas(NULL), dragState(WF_DRAG_NONE), nextDragState(WF_DRAG_NONE), fft_size(0), waterfall_lines(
|
||||||
WF_DRAG_NONE), nextDragState(WF_DRAG_NONE), fft_size(0), waterfall_lines(0), plan(
|
0), plan(
|
||||||
NULL), in(NULL), out(NULL), resampler(NULL), resamplerRatio(0), lastInputBandwidth(0), zoom(1), mouseZoom(1) {
|
NULL), in(NULL), out(NULL), resampler(NULL), resamplerRatio(0), lastInputBandwidth(0), zoom(1), mouseZoom(1) {
|
||||||
|
|
||||||
glContext = new WaterfallContext(this, &wxGetApp().GetContext(this));
|
glContext = new WaterfallContext(this, &wxGetApp().GetContext(this));
|
||||||
@ -106,7 +106,7 @@ void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
|
|||||||
|| (wxGetApp().getDemodMgr().getLastActiveDemodulator() && !wxGetApp().getDemodMgr().getLastActiveDemodulator()->isActive());
|
|| (wxGetApp().getDemodMgr().getLastActiveDemodulator() && !wxGetApp().getDemodMgr().getLastActiveDemodulator()->isActive());
|
||||||
|
|
||||||
int currentBandwidth = getBandwidth();
|
int currentBandwidth = getBandwidth();
|
||||||
int currentCenterFreq = getCenterFrequency();
|
long long currentCenterFreq = getCenterFrequency();
|
||||||
|
|
||||||
if (mouseTracker.mouseInView()) {
|
if (mouseTracker.mouseInView()) {
|
||||||
if (nextDragState == WF_DRAG_RANGE) {
|
if (nextDragState == WF_DRAG_RANGE) {
|
||||||
@ -194,7 +194,7 @@ void WaterfallCanvas::OnKeyDown(wxKeyEvent& event) {
|
|||||||
|
|
||||||
DemodulatorInstance *activeDemod = wxGetApp().getDemodMgr().getActiveDemodulator();
|
DemodulatorInstance *activeDemod = wxGetApp().getDemodMgr().getActiveDemodulator();
|
||||||
|
|
||||||
unsigned int freq;
|
long long freq;
|
||||||
unsigned int bw;
|
unsigned int bw;
|
||||||
switch (event.GetKeyCode()) {
|
switch (event.GetKeyCode()) {
|
||||||
case 'A':
|
case 'A':
|
||||||
@ -228,7 +228,7 @@ void WaterfallCanvas::OnKeyDown(wxKeyEvent& event) {
|
|||||||
case WXK_LEFT:
|
case WXK_LEFT:
|
||||||
freq = wxGetApp().getFrequency();
|
freq = wxGetApp().getFrequency();
|
||||||
if (shiftDown) {
|
if (shiftDown) {
|
||||||
if (((long) freq - SRATE * 10) < SRATE / 2) {
|
if ((freq - SRATE * 10) < SRATE / 2) {
|
||||||
freq = SRATE / 2;
|
freq = SRATE / 2;
|
||||||
} else {
|
} else {
|
||||||
freq -= SRATE * 10;
|
freq -= SRATE * 10;
|
||||||
@ -240,7 +240,7 @@ void WaterfallCanvas::OnKeyDown(wxKeyEvent& event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (((long) freq - SRATE / 2) < SRATE / 2) {
|
if ((freq - SRATE / 2) < SRATE / 2) {
|
||||||
freq = SRATE / 2;
|
freq = SRATE / 2;
|
||||||
} else {
|
} else {
|
||||||
freq -= SRATE / 2;
|
freq -= SRATE / 2;
|
||||||
@ -294,28 +294,28 @@ void WaterfallCanvas::setData(DemodulatorThreadIQData *input) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
float currentZoom = zoom;
|
long double currentZoom = zoom;
|
||||||
|
|
||||||
if (mouseZoom != 1) {
|
if (mouseZoom != 1) {
|
||||||
currentZoom = mouseZoom;
|
currentZoom = mouseZoom;
|
||||||
mouseZoom = mouseZoom + (1.0 - mouseZoom) * 0.2;
|
mouseZoom = mouseZoom + (1.0 - mouseZoom) * 0.2;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int bw;
|
long long bw;
|
||||||
if (currentZoom != 1) {
|
if (currentZoom != 1) {
|
||||||
int freq = wxGetApp().getFrequency();
|
long long freq = wxGetApp().getFrequency();
|
||||||
|
|
||||||
if (currentZoom < 1) {
|
if (currentZoom < 1) {
|
||||||
centerFreq = getCenterFrequency();
|
centerFreq = getCenterFrequency();
|
||||||
bw = getBandwidth();
|
bw = getBandwidth();
|
||||||
bw = (unsigned int) ceil((float) bw * currentZoom);
|
bw = (long long) ceil((long double) bw * currentZoom);
|
||||||
if (bw < 80000) {
|
if (bw < 80000) {
|
||||||
bw = 80000;
|
bw = 80000;
|
||||||
}
|
}
|
||||||
if (mouseTracker.mouseInView()) {
|
if (mouseTracker.mouseInView()) {
|
||||||
int mfreqA = getFrequencyAt(mouseTracker.getMouseX());
|
long long mfreqA = getFrequencyAt(mouseTracker.getMouseX());
|
||||||
setBandwidth(bw);
|
setBandwidth(bw);
|
||||||
int mfreqB = getFrequencyAt(mouseTracker.getMouseX());
|
long long mfreqB = getFrequencyAt(mouseTracker.getMouseX());
|
||||||
centerFreq += mfreqA - mfreqB;
|
centerFreq += mfreqA - mfreqB;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,19 +326,19 @@ void WaterfallCanvas::setData(DemodulatorThreadIQData *input) {
|
|||||||
} else {
|
} else {
|
||||||
if (isView) {
|
if (isView) {
|
||||||
bw = getBandwidth();
|
bw = getBandwidth();
|
||||||
bw = (unsigned int) ceil((float) bw * currentZoom);
|
bw = (long long) ceil((long double) bw * currentZoom);
|
||||||
if ((int) bw >= SRATE) {
|
if (bw >= SRATE) {
|
||||||
bw = (unsigned int) SRATE;
|
bw = SRATE;
|
||||||
disableView();
|
disableView();
|
||||||
if (spectrumCanvas) {
|
if (spectrumCanvas) {
|
||||||
spectrumCanvas->disableView();
|
spectrumCanvas->disableView();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (mouseTracker.mouseInView()) {
|
if (mouseTracker.mouseInView()) {
|
||||||
int freq = wxGetApp().getFrequency();
|
long long freq = wxGetApp().getFrequency();
|
||||||
int mfreqA = getFrequencyAt(mouseTracker.getMouseX());
|
long long mfreqA = getFrequencyAt(mouseTracker.getMouseX());
|
||||||
setBandwidth(bw);
|
setBandwidth(bw);
|
||||||
int mfreqB = getFrequencyAt(mouseTracker.getMouseX());
|
long long mfreqB = getFrequencyAt(mouseTracker.getMouseX());
|
||||||
centerFreq += mfreqA - mfreqB;
|
centerFreq += mfreqA - mfreqB;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,11 +378,11 @@ void WaterfallCanvas::setData(DemodulatorThreadIQData *input) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (centerFreq != input->frequency) {
|
if (centerFreq != input->frequency) {
|
||||||
if (((int) centerFreq - (int) input->frequency) != shiftFrequency || lastInputBandwidth != input->bandwidth) {
|
if ((centerFreq - input->frequency) != shiftFrequency || lastInputBandwidth != input->bandwidth) {
|
||||||
if ((int) input->frequency - abs((int) centerFreq) < (int) ((float) ((float) SRATE / 2.0))) {
|
if (abs(input->frequency - centerFreq) < (SRATE / 2)) {
|
||||||
shiftFrequency = (int) centerFreq - (int) input->frequency;
|
shiftFrequency = centerFreq - input->frequency;
|
||||||
nco_crcf_reset(freqShifter);
|
nco_crcf_reset(freqShifter);
|
||||||
nco_crcf_set_frequency(freqShifter, (2.0 * M_PI) * (((float) abs(shiftFrequency)) / ((float) input->bandwidth)));
|
nco_crcf_set_frequency(freqShifter, (2.0 * M_PI) * (((double) abs(shiftFrequency)) / ((double) input->bandwidth)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -562,13 +562,11 @@ void WaterfallCanvas::OnMouseMoved(wxMouseEvent& event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dragState == WF_DRAG_FREQUENCY) {
|
if (dragState == WF_DRAG_FREQUENCY) {
|
||||||
int bwDiff = (int) (mouseTracker.getDeltaMouseX() * (float) getBandwidth());
|
long long bwDiff = (long long) (mouseTracker.getDeltaMouseX() * (float) getBandwidth());
|
||||||
|
long long currentFreq = demod->getFrequency();
|
||||||
|
|
||||||
unsigned int currentFreq = demod->getFrequency();
|
demod->setFrequency(currentFreq + bwDiff);
|
||||||
|
currentFreq = demod->getFrequency();
|
||||||
currentFreq = (unsigned int)((int)currentFreq + bwDiff);
|
|
||||||
|
|
||||||
demod->setFrequency(currentFreq);
|
|
||||||
demod->updateLabel(currentFreq);
|
demod->updateLabel(currentFreq);
|
||||||
|
|
||||||
setStatusText("Set demodulator frequency: %s", demod->getFrequency());
|
setStatusText("Set demodulator frequency: %s", demod->getFrequency());
|
||||||
@ -576,7 +574,7 @@ void WaterfallCanvas::OnMouseMoved(wxMouseEvent& event) {
|
|||||||
} else if (mouseTracker.mouseRightDown()) {
|
} else if (mouseTracker.mouseRightDown()) {
|
||||||
mouseZoom = mouseZoom + ((1.0 - (mouseTracker.getDeltaMouseY() * 4.0)) - mouseZoom) * 0.1;
|
mouseZoom = mouseZoom + ((1.0 - (mouseTracker.getDeltaMouseY() * 4.0)) - mouseZoom) * 0.1;
|
||||||
} else {
|
} else {
|
||||||
int freqPos = getFrequencyAt(mouseTracker.getMouseX());
|
long long freqPos = getFrequencyAt(mouseTracker.getMouseX());
|
||||||
|
|
||||||
std::vector<DemodulatorInstance *> *demodsHover = wxGetApp().getDemodMgr().getDemodulatorsAt(freqPos, 15000);
|
std::vector<DemodulatorInstance *> *demodsHover = wxGetApp().getDemodMgr().getDemodulatorsAt(freqPos, 15000);
|
||||||
|
|
||||||
@ -593,16 +591,16 @@ void WaterfallCanvas::OnMouseMoved(wxMouseEvent& event) {
|
|||||||
}
|
}
|
||||||
} else if (demodsHover->size()) {
|
} else if (demodsHover->size()) {
|
||||||
int hovered = -1;
|
int hovered = -1;
|
||||||
int near_dist = getBandwidth();
|
long near_dist = getBandwidth();
|
||||||
|
|
||||||
DemodulatorInstance *activeDemodulator = NULL;
|
DemodulatorInstance *activeDemodulator = NULL;
|
||||||
|
|
||||||
for (int i = 0, iMax = demodsHover->size(); i < iMax; i++) {
|
for (int i = 0, iMax = demodsHover->size(); i < iMax; i++) {
|
||||||
DemodulatorInstance *demod = (*demodsHover)[i];
|
DemodulatorInstance *demod = (*demodsHover)[i];
|
||||||
int freqDiff = (int) demod->getParams().frequency - freqPos;
|
long long freqDiff = demod->getFrequency() - freqPos;
|
||||||
int halfBw = (demod->getParams().bandwidth / 2);
|
long halfBw = (demod->getBandwidth() / 2);
|
||||||
|
|
||||||
int dist = abs(freqDiff);
|
long dist = abs(freqDiff);
|
||||||
|
|
||||||
if (dist < near_dist) {
|
if (dist < near_dist) {
|
||||||
activeDemodulator = demod;
|
activeDemodulator = demod;
|
||||||
@ -610,7 +608,7 @@ void WaterfallCanvas::OnMouseMoved(wxMouseEvent& event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dist <= halfBw && dist >= (int) ((float) halfBw / (float) 1.5)) {
|
if (dist <= halfBw && dist >= (int) ((float) halfBw / (float) 1.5)) {
|
||||||
int edge_dist = abs(halfBw - dist);
|
long edge_dist = abs(halfBw - dist);
|
||||||
if (edge_dist < near_dist) {
|
if (edge_dist < near_dist) {
|
||||||
activeDemodulator = demod;
|
activeDemodulator = demod;
|
||||||
near_dist = edge_dist;
|
near_dist = edge_dist;
|
||||||
@ -624,9 +622,9 @@ void WaterfallCanvas::OnMouseMoved(wxMouseEvent& event) {
|
|||||||
|
|
||||||
wxGetApp().getDemodMgr().setActiveDemodulator(activeDemodulator);
|
wxGetApp().getDemodMgr().setActiveDemodulator(activeDemodulator);
|
||||||
|
|
||||||
int freqDiff = ((int) activeDemodulator->getParams().frequency - freqPos);
|
long long freqDiff = activeDemodulator->getFrequency() - freqPos;
|
||||||
|
|
||||||
if (abs(freqDiff) > (activeDemodulator->getParams().bandwidth / 3)) {
|
if (abs(freqDiff) > (activeDemodulator->getBandwidth() / 3)) {
|
||||||
SetCursor(wxCURSOR_SIZEWE);
|
SetCursor(wxCURSOR_SIZEWE);
|
||||||
|
|
||||||
if (freqDiff > 0) {
|
if (freqDiff > 0) {
|
||||||
@ -688,18 +686,19 @@ void WaterfallCanvas::OnMouseReleased(wxMouseEvent& event) {
|
|||||||
|
|
||||||
if (mouseTracker.getOriginDeltaMouseX() == 0 && mouseTracker.getOriginDeltaMouseY() == 0) {
|
if (mouseTracker.getOriginDeltaMouseX() == 0 && mouseTracker.getOriginDeltaMouseY() == 0) {
|
||||||
float pos = mouseTracker.getMouseX();
|
float pos = mouseTracker.getMouseX();
|
||||||
int input_center_freq = getCenterFrequency();
|
long long input_center_freq = getCenterFrequency();
|
||||||
int freq = input_center_freq - (int) (0.5 * (float) getBandwidth()) + (int) ((float) pos * (float) getBandwidth());
|
long long freq = input_center_freq - (long long) (0.5 * (float) getBandwidth()) + (long long) ((float) pos * (float) getBandwidth());
|
||||||
|
|
||||||
if (dragState == WF_DRAG_NONE) {
|
if (dragState == WF_DRAG_NONE) {
|
||||||
if (!isNew && wxGetApp().getDemodMgr().getDemodulators().size()) {
|
if (!isNew && wxGetApp().getDemodMgr().getDemodulators().size()) {
|
||||||
demod = wxGetApp().getDemodMgr().getLastActiveDemodulator();
|
demod = wxGetApp().getDemodMgr().getLastActiveDemodulator();
|
||||||
} else {
|
} else {
|
||||||
|
isNew = true;
|
||||||
demod = wxGetApp().getDemodMgr().newThread();
|
demod = wxGetApp().getDemodMgr().newThread();
|
||||||
demod->getParams().frequency = freq;
|
demod->getParams().frequency = freq;
|
||||||
|
|
||||||
if (DemodulatorInstance *last = wxGetApp().getDemodMgr().getLastActiveDemodulator()) {
|
if (DemodulatorInstance *last = wxGetApp().getDemodMgr().getLastActiveDemodulator()) {
|
||||||
demod->getParams().bandwidth = last->getParams().bandwidth;
|
demod->getParams().bandwidth = last->getBandwidth();
|
||||||
demod->setDemodulatorType(last->getDemodulatorType());
|
demod->setDemodulatorType(last->getDemodulatorType());
|
||||||
demod->setSquelchLevel(last->getSquelchLevel());
|
demod->setSquelchLevel(last->getSquelchLevel());
|
||||||
demod->setSquelchEnabled(last->isSquelchEnabled());
|
demod->setSquelchEnabled(last->isSquelchEnabled());
|
||||||
@ -718,13 +717,13 @@ void WaterfallCanvas::OnMouseReleased(wxMouseEvent& event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
demod->updateLabel(freq);
|
demod->updateLabel(freq);
|
||||||
|
demod->setFrequency(freq);
|
||||||
|
|
||||||
DemodulatorThreadCommand command;
|
if (isNew) {
|
||||||
command.cmd = DemodulatorThreadCommand::DEMOD_THREAD_CMD_SET_FREQUENCY;
|
setStatusText("New demodulator at frequency: %s", freq);
|
||||||
command.int_value = freq;
|
} else {
|
||||||
demod->getCommandQueue()->push(command);
|
setStatusText("Moved demodulator to frequency: %s", freq);
|
||||||
|
}
|
||||||
setStatusText("New demodulator at frequency: %s", freq);
|
|
||||||
|
|
||||||
wxGetApp().getDemodMgr().setActiveDemodulator(wxGetApp().getDemodMgr().getLastActiveDemodulator(), false);
|
wxGetApp().getDemodMgr().setActiveDemodulator(wxGetApp().getDemodMgr().getLastActiveDemodulator(), false);
|
||||||
SetCursor(wxCURSOR_SIZING);
|
SetCursor(wxCURSOR_SIZING);
|
||||||
@ -739,8 +738,8 @@ void WaterfallCanvas::OnMouseReleased(wxMouseEvent& event) {
|
|||||||
float width = mouseTracker.getOriginDeltaMouseX();
|
float width = mouseTracker.getOriginDeltaMouseX();
|
||||||
float pos = mouseTracker.getOriginMouseX() + width / 2.0;
|
float pos = mouseTracker.getOriginMouseX() + width / 2.0;
|
||||||
|
|
||||||
int input_center_freq = getCenterFrequency();
|
long long input_center_freq = getCenterFrequency();
|
||||||
unsigned int freq = input_center_freq - (int) (0.5 * (float) getBandwidth()) + (int) ((float) pos * (float) getBandwidth());
|
long long freq = input_center_freq - (long long) (0.5 * (float) getBandwidth()) + (long long) ((float) pos * (float) getBandwidth());
|
||||||
unsigned int bw = (unsigned int) (fabs(width) * (float) getBandwidth());
|
unsigned int bw = (unsigned int) (fabs(width) * (float) getBandwidth());
|
||||||
|
|
||||||
if (bw < MIN_BANDWIDTH) {
|
if (bw < MIN_BANDWIDTH) {
|
||||||
@ -779,14 +778,8 @@ void WaterfallCanvas::OnMouseReleased(wxMouseEvent& event) {
|
|||||||
|
|
||||||
wxGetApp().getDemodMgr().setActiveDemodulator(wxGetApp().getDemodMgr().getLastActiveDemodulator(), false);
|
wxGetApp().getDemodMgr().setActiveDemodulator(wxGetApp().getDemodMgr().getLastActiveDemodulator(), false);
|
||||||
demod->updateLabel(freq);
|
demod->updateLabel(freq);
|
||||||
|
demod->setFrequency(freq);
|
||||||
DemodulatorThreadCommand command;
|
demod->setBandwidth(bw);
|
||||||
command.cmd = DemodulatorThreadCommand::DEMOD_THREAD_CMD_SET_FREQUENCY;
|
|
||||||
command.int_value = freq;
|
|
||||||
demod->getCommandQueue()->push(command);
|
|
||||||
command.cmd = DemodulatorThreadCommand::DEMOD_THREAD_CMD_SET_BANDWIDTH;
|
|
||||||
command.int_value = bw;
|
|
||||||
demod->getCommandQueue()->push(command);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dragState = WF_DRAG_NONE;
|
dragState = WF_DRAG_NONE;
|
||||||
|
@ -70,7 +70,7 @@ private:
|
|||||||
msresamp_crcf resampler;
|
msresamp_crcf resampler;
|
||||||
double resamplerRatio;
|
double resamplerRatio;
|
||||||
nco_crcf freqShifter;
|
nco_crcf freqShifter;
|
||||||
int shiftFrequency;
|
long shiftFrequency;
|
||||||
|
|
||||||
int lastInputBandwidth;
|
int lastInputBandwidth;
|
||||||
float mouseZoom, zoom;
|
float mouseZoom, zoom;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user