mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2026-06-02 14:04:47 -04:00
Can now change input device bandwidth
This commit is contained in:
@@ -37,7 +37,7 @@ void InteractiveCanvas::setView(long long center_freq_in, int bandwidth_in) {
|
||||
void InteractiveCanvas::disableView() {
|
||||
isView = false;
|
||||
centerFreq = wxGetApp().getFrequency();
|
||||
bandwidth = SRATE;
|
||||
bandwidth = wxGetApp().getSampleRate();
|
||||
lastBandwidth = 0;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ unsigned int InteractiveCanvas::getBandwidth() {
|
||||
if (isView) {
|
||||
return bandwidth;
|
||||
} else {
|
||||
return SRATE;
|
||||
return wxGetApp().getSampleRate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -96,6 +96,9 @@ void PrimaryGLContext::DrawDemodInfo(DemodulatorInstance *demod, float r, float
|
||||
if (!demod) {
|
||||
return;
|
||||
}
|
||||
if (!srate) {
|
||||
srate = wxGetApp().getSampleRate();
|
||||
}
|
||||
|
||||
GLint vp[4];
|
||||
glGetIntegerv( GL_VIEWPORT, vp);
|
||||
@@ -171,6 +174,9 @@ void PrimaryGLContext::DrawDemod(DemodulatorInstance *demod, float r, float g, f
|
||||
if (!demod) {
|
||||
return;
|
||||
}
|
||||
if (!srate) {
|
||||
srate = wxGetApp().getSampleRate();
|
||||
}
|
||||
|
||||
if (center_freq == -1) {
|
||||
center_freq = wxGetApp().getFrequency();
|
||||
@@ -271,6 +277,10 @@ void PrimaryGLContext::DrawFreqSelector(float uxPos, float r, float g, float b,
|
||||
bw = demod->getBandwidth();
|
||||
}
|
||||
|
||||
if (!srate) {
|
||||
srate = wxGetApp().getSampleRate();
|
||||
}
|
||||
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
|
||||
@@ -23,9 +23,9 @@ public:
|
||||
void BeginDraw();
|
||||
void EndDraw();
|
||||
|
||||
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, long long center_freq = -1, long long srate = SRATE);
|
||||
void DrawDemodInfo(DemodulatorInstance *demod, float r = 1, float g = 1, float b = 1, long long center_freq = -1, long long 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 = 0);
|
||||
void DrawDemod(DemodulatorInstance *demod, float r = 1, float g = 1, float b = 1, long long center_freq = -1, long long srate = 0);
|
||||
void DrawDemodInfo(DemodulatorInstance *demod, float r = 1, float g = 1, float b = 1, long long center_freq = -1, long long srate = 0);
|
||||
|
||||
static GLFont &getFont(GLFontSize esize);
|
||||
|
||||
|
||||
@@ -196,16 +196,16 @@ void SpectrumCanvas::OnMouseMoved(wxMouseEvent& event) {
|
||||
long long bwOfs = (centerFreq > freq) ? ((long long) bandwidth / 2) : (-(long long) bandwidth / 2);
|
||||
long long freqEdge = centerFreq + bwOfs;
|
||||
|
||||
if (abs(freq - freqEdge) > (SRATE / 2)) {
|
||||
freqChange = -((centerFreq > freq) ? (freqEdge - freq - (SRATE / 2)) : (freqEdge - freq + (SRATE / 2)));
|
||||
if (abs(freq - freqEdge) > (wxGetApp().getSampleRate() / 2)) {
|
||||
freqChange = -((centerFreq > freq) ? (freqEdge - freq - (wxGetApp().getSampleRate() / 2)) : (freqEdge - freq + (wxGetApp().getSampleRate() / 2)));
|
||||
} else {
|
||||
freqChange = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (freqChange) {
|
||||
if (freq - freqChange < SRATE/2) {
|
||||
freq = SRATE/2;
|
||||
if (freq - freqChange < wxGetApp().getSampleRate()/2) {
|
||||
freq = wxGetApp().getSampleRate()/2;
|
||||
} else {
|
||||
freq -= freqChange;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ void TuningCanvas::OnIdle(wxIdleEvent &event) {
|
||||
dragAccum += mouseTracker.getMouseX() - mouseTracker.getOriginMouseX();
|
||||
|
||||
if (uxDown > 0.275) {
|
||||
wxGetApp().setFrequency(wxGetApp().getFrequency() + (int) (mouseTracker.getOriginDeltaMouseX() * SRATE * 15.0));
|
||||
wxGetApp().setFrequency(wxGetApp().getFrequency() + (int) (mouseTracker.getOriginDeltaMouseX() * (float)wxGetApp().getSampleRate() * 15.0));
|
||||
}
|
||||
|
||||
if (abs(dragAccum * 10.0) >= 1) {
|
||||
|
||||
@@ -214,7 +214,7 @@ void WaterfallCanvas::OnKeyDown(wxKeyEvent& event) {
|
||||
freq = wxGetApp().getFrequency();
|
||||
originalFreq = freq;
|
||||
if (shiftDown) {
|
||||
freq += SRATE * 10;
|
||||
freq += wxGetApp().getSampleRate() * 10;
|
||||
if (isView) {
|
||||
setView(centerFreq + (freq - originalFreq), getBandwidth());
|
||||
if (spectrumCanvas) {
|
||||
@@ -222,7 +222,7 @@ void WaterfallCanvas::OnKeyDown(wxKeyEvent& event) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
freq += SRATE / 2;
|
||||
freq += wxGetApp().getSampleRate() / 2;
|
||||
if (isView) {
|
||||
setView(centerFreq + (freq - originalFreq), getBandwidth());
|
||||
if (spectrumCanvas) {
|
||||
@@ -237,10 +237,10 @@ void WaterfallCanvas::OnKeyDown(wxKeyEvent& event) {
|
||||
freq = wxGetApp().getFrequency();
|
||||
originalFreq = freq;
|
||||
if (shiftDown) {
|
||||
if ((freq - SRATE * 10) < SRATE / 2) {
|
||||
freq = SRATE / 2;
|
||||
if ((freq - wxGetApp().getSampleRate() * 10) < wxGetApp().getSampleRate() / 2) {
|
||||
freq = wxGetApp().getSampleRate() / 2;
|
||||
} else {
|
||||
freq -= SRATE * 10;
|
||||
freq -= wxGetApp().getSampleRate() * 10;
|
||||
}
|
||||
if (isView) {
|
||||
setView(centerFreq + (freq - originalFreq), getBandwidth());
|
||||
@@ -249,10 +249,10 @@ void WaterfallCanvas::OnKeyDown(wxKeyEvent& event) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ((freq - SRATE / 2) < SRATE / 2) {
|
||||
freq = SRATE / 2;
|
||||
if ((freq - wxGetApp().getSampleRate() / 2) < wxGetApp().getSampleRate() / 2) {
|
||||
freq = wxGetApp().getSampleRate() / 2;
|
||||
} else {
|
||||
freq -= SRATE / 2;
|
||||
freq -= wxGetApp().getSampleRate() / 2;
|
||||
}
|
||||
if (isView) {
|
||||
setView(centerFreq + (freq - originalFreq), getBandwidth());
|
||||
@@ -339,8 +339,8 @@ void WaterfallCanvas::setData(DemodulatorThreadIQData *input) {
|
||||
if (isView) {
|
||||
bw = getBandwidth();
|
||||
bw = (long long) ceil((long double) bw * currentZoom);
|
||||
if (bw >= SRATE) {
|
||||
bw = SRATE;
|
||||
if (bw >= wxGetApp().getSampleRate()) {
|
||||
bw = wxGetApp().getSampleRate();
|
||||
disableView();
|
||||
if (spectrumCanvas) {
|
||||
spectrumCanvas->disableView();
|
||||
@@ -361,11 +361,11 @@ void WaterfallCanvas::setData(DemodulatorThreadIQData *input) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (centerFreq < freq && (centerFreq - bandwidth / 2) < (freq - SRATE / 2)) {
|
||||
centerFreq = (freq - SRATE / 2) + bandwidth / 2;
|
||||
if (centerFreq < freq && (centerFreq - bandwidth / 2) < (freq - wxGetApp().getSampleRate() / 2)) {
|
||||
centerFreq = (freq - wxGetApp().getSampleRate() / 2) + bandwidth / 2;
|
||||
}
|
||||
if (centerFreq > freq && (centerFreq + bandwidth / 2) > (freq + SRATE / 2)) {
|
||||
centerFreq = (freq + SRATE / 2) - bandwidth / 2;
|
||||
if (centerFreq > freq && (centerFreq + bandwidth / 2) > (freq + wxGetApp().getSampleRate() / 2)) {
|
||||
centerFreq = (freq + wxGetApp().getSampleRate() / 2) - bandwidth / 2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -385,16 +385,16 @@ void WaterfallCanvas::setData(DemodulatorThreadIQData *input) {
|
||||
}
|
||||
|
||||
if (isView) {
|
||||
if (!input->frequency || !input->bandwidth) {
|
||||
if (!input->frequency || !input->sampleRate) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (centerFreq != input->frequency) {
|
||||
if ((centerFreq - input->frequency) != shiftFrequency || lastInputBandwidth != input->bandwidth) {
|
||||
if (abs(input->frequency - centerFreq) < (SRATE / 2)) {
|
||||
if ((centerFreq - input->frequency) != shiftFrequency || lastInputBandwidth != input->sampleRate) {
|
||||
if (abs(input->frequency - centerFreq) < (wxGetApp().getSampleRate() / 2)) {
|
||||
shiftFrequency = centerFreq - input->frequency;
|
||||
nco_crcf_reset(freqShifter);
|
||||
nco_crcf_set_frequency(freqShifter, (2.0 * M_PI) * (((double) abs(shiftFrequency)) / ((double) input->bandwidth)));
|
||||
nco_crcf_set_frequency(freqShifter, (2.0 * M_PI) * (((double) abs(shiftFrequency)) / ((double) input->sampleRate)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -414,8 +414,8 @@ void WaterfallCanvas::setData(DemodulatorThreadIQData *input) {
|
||||
shiftBuffer.assign(input->data.begin(), input->data.end());
|
||||
}
|
||||
|
||||
if (!resampler || bandwidth != lastBandwidth || lastInputBandwidth != input->bandwidth) {
|
||||
resamplerRatio = (double) (bandwidth) / (double) input->bandwidth;
|
||||
if (!resampler || bandwidth != lastBandwidth || lastInputBandwidth != input->sampleRate) {
|
||||
resamplerRatio = (double) (bandwidth) / (double) input->sampleRate;
|
||||
|
||||
float As = 120.0f;
|
||||
|
||||
@@ -425,7 +425,7 @@ void WaterfallCanvas::setData(DemodulatorThreadIQData *input) {
|
||||
resampler = msresamp_crcf_create(resamplerRatio, As);
|
||||
|
||||
lastBandwidth = bandwidth;
|
||||
lastInputBandwidth = input->bandwidth;
|
||||
lastInputBandwidth = input->sampleRate;
|
||||
}
|
||||
|
||||
int out_size = ceil((double) (input->data.size()) * resamplerRatio) + 512;
|
||||
@@ -562,8 +562,8 @@ void WaterfallCanvas::OnMouseMoved(wxMouseEvent& event) {
|
||||
int currentBW = demod->getBandwidth();
|
||||
|
||||
currentBW = currentBW + bwDiff;
|
||||
if (currentBW > SRATE) {
|
||||
currentBW = SRATE;
|
||||
if (currentBW > wxGetApp().getSampleRate()) {
|
||||
currentBW = wxGetApp().getSampleRate();
|
||||
}
|
||||
if (currentBW < MIN_BANDWIDTH) {
|
||||
currentBW = MIN_BANDWIDTH;
|
||||
|
||||
Reference in New Issue
Block a user