tuning tweaks, zoomed view following fix

This commit is contained in:
Charles J. Cliffe 2015-03-29 20:24:00 -04:00
parent d95925a3c4
commit efa2cd75c9
5 changed files with 81 additions and 68 deletions

View File

@ -50,13 +50,7 @@ wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL) {
wxBoxSizer *demodTray = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer *demodScopeTray = new wxBoxSizer(wxVERTICAL);
int attribList[] = {
WX_GL_RGBA,
WX_GL_STENCIL_SIZE, 8,
WX_GL_BUFFER_SIZE, 24,
WX_GL_DOUBLEBUFFER,
0
};
int attribList[] = { WX_GL_RGBA, WX_GL_STENCIL_SIZE, 8, WX_GL_BUFFER_SIZE, 24, WX_GL_DOUBLEBUFFER, 0 };
demodModeSelector = new ModeSelectorCanvas(this, attribList);
demodModeSelector->addChoice(DEMOD_TYPE_FM, "FM");
@ -164,7 +158,6 @@ wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL) {
i++;
}
for (mdevices_i = outputDevices.begin(); mdevices_i != outputDevices.end(); mdevices_i++) {
wxMenuItem *itm = menu->AppendRadioItem(wxID_RT_AUDIO_DEVICE + mdevices_i->first, mdevices_i->second.name, wxT("Description?"));
itm->SetId(wxID_RT_AUDIO_DEVICE + mdevices_i->first);
@ -232,10 +225,8 @@ wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL) {
menuBar->Append(menu, wxT("Input &Device"));
}
menu = new wxMenu;
#define NUM_RATES_DEFAULT 4
int desired_rates[NUM_RATES_DEFAULT] = { 48000, 44100, 96000, 192000 };
@ -243,7 +234,8 @@ wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL) {
int desired_rate = 0;
int desired_rank = NUM_RATES_DEFAULT + 1;
for (std::vector<unsigned int>::iterator srate = mdevices_i->second.sampleRates.begin(); srate != mdevices_i->second.sampleRates.end(); srate++) {
for (std::vector<unsigned int>::iterator srate = mdevices_i->second.sampleRates.begin(); srate != mdevices_i->second.sampleRates.end();
srate++) {
for (i = 0; i < NUM_RATES_DEFAULT; i++) {
if (desired_rates[i] == (*srate)) {
if (desired_rank > i) {
@ -267,7 +259,8 @@ wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL) {
menu->AppendSubMenu(subMenu, mdevices_i->second.name, wxT("Description?"));
int j = 0;
for (std::vector<unsigned int>::iterator srate = mdevices_i->second.sampleRates.begin(); srate != mdevices_i->second.sampleRates.end(); srate++) {
for (std::vector<unsigned int>::iterator srate = mdevices_i->second.sampleRates.begin(); srate != mdevices_i->second.sampleRates.end();
srate++) {
std::stringstream srateName;
srateName << ((float) (*srate) / 1000.0f) << "kHz";
wxMenuItem *itm = subMenu->AppendRadioItem(menu_id + j, srateName.str(), wxT("Description?"));
@ -283,7 +276,6 @@ wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL) {
menuBar->Append(menu, wxT("Audio &Bandwidth"));
SetMenuBar(menuBar);
CreateStatusBar();
@ -291,7 +283,6 @@ wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL) {
Centre();
Show();
#ifdef _WIN32
SetIcon(wxICON(frame_icon));
#endif
@ -398,7 +389,6 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
wxGetApp().setDevice(event.GetId() - wxID_DEVICE_ID);
}
if (event.GetId() >= wxID_AUDIO_BANDWIDTH_BASE) {
int evId = event.GetId();
std::vector<RtAudio::DeviceInfo>::iterator devices_i;
@ -409,7 +399,8 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
int menu_id = wxID_AUDIO_BANDWIDTH_BASE + wxID_AUDIO_DEVICE_MULTIPLIER * mdevices_i->first;
int j = 0;
for (std::vector<unsigned int>::iterator srate = mdevices_i->second.sampleRates.begin(); srate != mdevices_i->second.sampleRates.end(); srate++) {
for (std::vector<unsigned int>::iterator srate = mdevices_i->second.sampleRates.begin(); srate != mdevices_i->second.sampleRates.end();
srate++) {
if (evId == menu_id + j) {
//audioSampleRateMenuItems[menu_id+j];
@ -516,11 +507,11 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
demodGainMeter->setLevel(demodGainMeter->getInputValue());
}
if (wxGetApp().getFrequency() != waterfallCanvas->getCenterFrequency()) {
if (!spectrumCanvas->getMouseTracker()->mouseDown()) {
if (wxGetApp().getFrequency() != demodWaterfallCanvas->getCenterFrequency()) {
if (spectrumCanvas->getViewState() && abs(wxGetApp().getFrequency()-spectrumCanvas->getCenterFrequency()) > (wxGetApp().getSampleRate()/2)) {
spectrumCanvas->setCenterFrequency(wxGetApp().getFrequency());
}
waterfallCanvas->setCenterFrequency(wxGetApp().getFrequency());
}
demodWaterfallCanvas->setCenterFrequency(wxGetApp().getFrequency());
demodSpectrumCanvas->setCenterFrequency(wxGetApp().getFrequency());
}

View File

@ -236,9 +236,9 @@ int DemodulatorInstance::getOutputDevice() {
}
void DemodulatorInstance::checkBandwidth() {
if ((currentDemodType == DEMOD_TYPE_USB || currentDemodType == DEMOD_TYPE_LSB) && (getBandwidth() % 2)) {
setBandwidth(getBandwidth()+1);
}
// if ((currentDemodType == DEMOD_TYPE_USB || currentDemodType == DEMOD_TYPE_LSB) && (getBandwidth() % 2)) {
// setBandwidth(getBandwidth()+1);
// }
}
void DemodulatorInstance::setDemodulatorType(int demod_type_in) {

View File

@ -41,6 +41,10 @@ void InteractiveCanvas::disableView() {
lastBandwidth = 0;
}
bool InteractiveCanvas::getViewState() {
return isView;
}
long long InteractiveCanvas::getFrequencyAt(float x) {
long long iqCenterFreq = getCenterFrequency();
long long iqBandwidth = getBandwidth();

View File

@ -15,6 +15,7 @@ public:
void setView(long long center_freq_in, int bandwidth_in);
void disableView();
bool getViewState();
void setCenterFrequency(long long center_freq_in);
long long getCenterFrequency();

View File

@ -223,25 +223,42 @@ void TuningCanvas::OnMouseMoved(wxMouseEvent& event) {
if (index > 0) {
hoverIndex = index;
hoverState = TUNING_HOVER_FREQ;
return;
}
if (!index) {
index = glContext->GetTunerDigitIndex(mouseTracker.getMouseX(), 7, bwDP, bwW); // bw
if (index > 0) {
hoverIndex = index;
hoverState = TUNING_HOVER_BW;
return;
}
}
if (!index) {
index = glContext->GetTunerDigitIndex(mouseTracker.getMouseX(), 11, centerDP, centerW); // center
if (index > 0) {
hoverIndex = index;
hoverState = TUNING_HOVER_CENTER;
return;
}
}
if (!index) {
hoverIndex = 0;
hoverState = TUNING_HOVER_NONE;
} else {
switch (hoverState) {
case TUNING_HOVER_FREQ:
setStatusText("Click or drag a digit to change frequency. Hold shift to disable carry.");
break;
case TUNING_HOVER_BW:
setStatusText("Click or drag a digit to change bandwidth. Hold shift to disable carry.");
break;
case TUNING_HOVER_CENTER:
setStatusText("Click or drag a digit to change center frequency. Hold shift to disable carry.");
break;
}
}
}
void TuningCanvas::OnMouseDown(wxMouseEvent& event) {
@ -270,7 +287,7 @@ void TuningCanvas::OnMouseReleased(wxMouseEvent& event) {
int hExponent = hoverIndex - 1;
if (hoverState != TUNING_HOVER_NONE && !dragging) {
if (hoverState != TUNING_HOVER_NONE && !dragging && (downState == hoverState) && (downIndex == hoverIndex)) {
StepTuner(hoverState, hExponent, top);
}