mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2025-09-07 15:47:49 -04:00
Zoom follows and pins mouse frequency
This commit is contained in:
parent
6a03aae303
commit
ef5462d13c
@ -119,7 +119,7 @@ void DemodulatorThread::threadMain() {
|
||||
freqdem_reset(fdem);
|
||||
}
|
||||
|
||||
int out_size = ceil((double) (bufSize) * inp->resample_ratio) + 32;
|
||||
int out_size = ceil((double) (bufSize) * inp->resample_ratio) + 512;
|
||||
|
||||
if (agc_data.size() != out_size) {
|
||||
if (agc_data.capacity() < out_size) {
|
||||
@ -144,7 +144,7 @@ void DemodulatorThread::threadMain() {
|
||||
demod_output.resize(num_written);
|
||||
}
|
||||
|
||||
int audio_out_size = ceil((double) (num_written) * audio_resample_ratio) + 32;
|
||||
int audio_out_size = ceil((double) (num_written) * audio_resample_ratio) + 512;
|
||||
|
||||
agc_crcf_execute_block(agc, &resampled_data[0], num_written, &agc_data[0]);
|
||||
|
||||
|
@ -232,7 +232,6 @@ void SpectrumCanvas::mouseMoved(wxMouseEvent& event) {
|
||||
|
||||
if (abs(freq-freqEdge) > (SRATE/2)) {
|
||||
freqChange = -(((int)center_freq>freq)?(freqEdge-freq-(SRATE/2)):(freqEdge-freq+(SRATE/2)));
|
||||
std::cout << "change: " << freqChange;
|
||||
} else {
|
||||
freqChange = 0;
|
||||
}
|
||||
|
@ -313,6 +313,8 @@ void WaterfallCanvas::setData(DemodulatorThreadIQData *input) {
|
||||
|
||||
unsigned int bw;
|
||||
if (zoom) {
|
||||
int freq = wxGetApp().getFrequency();
|
||||
|
||||
if (zoom > 0) {
|
||||
center_freq = GetCenterFrequency();
|
||||
bw = GetBandwidth();
|
||||
@ -320,6 +322,13 @@ void WaterfallCanvas::setData(DemodulatorThreadIQData *input) {
|
||||
if (bw < 80000) {
|
||||
bw = 80000;
|
||||
}
|
||||
if (mTracker.mouseInView()) {
|
||||
int mfreqA = GetFrequencyAt(mTracker.getMouseX());
|
||||
SetBandwidth(bw);
|
||||
int mfreqB = GetFrequencyAt(mTracker.getMouseX());
|
||||
center_freq += mfreqA - mfreqB;
|
||||
}
|
||||
|
||||
SetView(center_freq, bw);
|
||||
if (spectrumCanvas) {
|
||||
spectrumCanvas->SetView(center_freq, bw);
|
||||
@ -335,6 +344,14 @@ void WaterfallCanvas::setData(DemodulatorThreadIQData *input) {
|
||||
spectrumCanvas->DisableView();
|
||||
}
|
||||
} else {
|
||||
if (mTracker.mouseInView()) {
|
||||
int freq = wxGetApp().getFrequency();
|
||||
int mfreqA = GetFrequencyAt(mTracker.getMouseX());
|
||||
SetBandwidth(bw);
|
||||
int mfreqB = GetFrequencyAt(mTracker.getMouseX());
|
||||
center_freq += mfreqA - mfreqB;
|
||||
}
|
||||
|
||||
SetView(GetCenterFrequency(), bw);
|
||||
if (spectrumCanvas) {
|
||||
spectrumCanvas->SetView(center_freq, bw);
|
||||
@ -342,6 +359,12 @@ void WaterfallCanvas::setData(DemodulatorThreadIQData *input) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (center_freq < freq && (center_freq - bandwidth / 2) < (freq - SRATE / 2)) {
|
||||
center_freq = (freq - SRATE / 2) + bandwidth / 2;
|
||||
}
|
||||
if (center_freq > freq && (center_freq + bandwidth / 2) > (freq + SRATE / 2)) {
|
||||
center_freq = (freq + SRATE / 2) - bandwidth / 2;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<liquid_float_complex> *data = &input->data;
|
||||
@ -695,6 +718,10 @@ void WaterfallCanvas::mouseReleased(wxMouseEvent& event) {
|
||||
|
||||
if (DemodulatorInstance *last = wxGetApp().getDemodMgr().getLastActiveDemodulator()) {
|
||||
demod->getParams().bandwidth = last->getParams().bandwidth;
|
||||
demod->setDemodulatorType(last->getDemodulatorType());
|
||||
demod->setSquelchLevel(last->getSquelchLevel());
|
||||
demod->setSquelchEnabled(last->isSquelchEnabled());
|
||||
demod->setStereo(last->isStereo());
|
||||
}
|
||||
|
||||
demod->run();
|
||||
@ -755,7 +782,12 @@ void WaterfallCanvas::mouseReleased(wxMouseEvent& event) {
|
||||
demod = wxGetApp().getDemodMgr().newThread();
|
||||
demod->getParams().frequency = freq;
|
||||
demod->getParams().bandwidth = bw;
|
||||
|
||||
if (DemodulatorInstance *last = wxGetApp().getDemodMgr().getLastActiveDemodulator()) {
|
||||
demod->setDemodulatorType(last->getDemodulatorType());
|
||||
demod->setSquelchLevel(last->getSquelchLevel());
|
||||
demod->setSquelchEnabled(last->isSquelchEnabled());
|
||||
demod->setStereo(last->isStereo());
|
||||
}
|
||||
demod->run();
|
||||
|
||||
wxGetApp().bindDemodulator(demod);
|
||||
|
Loading…
x
Reference in New Issue
Block a user