mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-23 04:08:36 -05:00
tuning tweaks, zoomed view following fix
This commit is contained in:
parent
d95925a3c4
commit
efa2cd75c9
@ -38,7 +38,7 @@ EVT_IDLE(AppFrame::OnIdle)
|
||||
wxEND_EVENT_TABLE()
|
||||
|
||||
AppFrame::AppFrame() :
|
||||
wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL) {
|
||||
wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL) {
|
||||
|
||||
#ifdef __linux__
|
||||
SetIcon(wxICON(cubicsdr));
|
||||
@ -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,31 +225,30 @@ wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL) {
|
||||
menuBar->Append(menu, wxT("Input &Device"));
|
||||
}
|
||||
|
||||
|
||||
menu = new wxMenu;
|
||||
|
||||
|
||||
#define NUM_RATES_DEFAULT 4
|
||||
#define NUM_RATES_DEFAULT 4
|
||||
int desired_rates[NUM_RATES_DEFAULT] = { 48000, 44100, 96000, 192000 };
|
||||
|
||||
for (mdevices_i = outputDevices.begin(); mdevices_i != outputDevices.end(); mdevices_i++) {
|
||||
int desired_rate = 0;
|
||||
int desired_rank = NUM_RATES_DEFAULT+1;
|
||||
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 (i = 0; i < NUM_RATES_DEFAULT; i++) {
|
||||
if (desired_rates[i] == (*srate)) {
|
||||
if (desired_rank > i) {
|
||||
desired_rank = i;
|
||||
desired_rate = (*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) {
|
||||
desired_rank = i;
|
||||
desired_rate = (*srate);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (desired_rank > NUM_RATES_DEFAULT) {
|
||||
desired_rate = mdevices_i->second.sampleRates.back();
|
||||
}
|
||||
if (desired_rank > NUM_RATES_DEFAULT) {
|
||||
desired_rate = mdevices_i->second.sampleRates.back();
|
||||
}
|
||||
AudioThread::deviceSampleRate[mdevices_i->first] = desired_rate;
|
||||
}
|
||||
|
||||
@ -264,18 +256,19 @@ wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL) {
|
||||
new wxMenu;
|
||||
int menu_id = wxID_AUDIO_BANDWIDTH_BASE + wxID_AUDIO_DEVICE_MULTIPLIER * mdevices_i->first;
|
||||
wxMenu *subMenu = new wxMenu;
|
||||
menu->AppendSubMenu(subMenu,mdevices_i->second.name, wxT("Description?"));
|
||||
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?"));
|
||||
srateName << ((float) (*srate) / 1000.0f) << "kHz";
|
||||
wxMenuItem *itm = subMenu->AppendRadioItem(menu_id + j, srateName.str(), wxT("Description?"));
|
||||
|
||||
if ((*srate) == AudioThread::deviceSampleRate[mdevices_i->first]) {
|
||||
itm->Check(true);
|
||||
}
|
||||
audioSampleRateMenuItems[menu_id+j] = itm;
|
||||
audioSampleRateMenuItems[menu_id + j] = itm;
|
||||
|
||||
j++;
|
||||
}
|
||||
@ -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;
|
||||
@ -406,21 +396,22 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
|
||||
|
||||
int i = 0;
|
||||
for (mdevices_i = outputDevices.begin(); mdevices_i != outputDevices.end(); mdevices_i++) {
|
||||
int menu_id = wxID_AUDIO_BANDWIDTH_BASE + wxID_AUDIO_DEVICE_MULTIPLIER * mdevices_i->first;
|
||||
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++) {
|
||||
int j = 0;
|
||||
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];
|
||||
//std::cout << "Would set audio sample rate on device " << mdevices_i->second.name << " (" << mdevices_i->first << ") to " << (*srate) << "Hz" << std::endl;
|
||||
AudioThread::setDeviceSampleRate(mdevices_i->first, *srate);
|
||||
}
|
||||
if (evId == menu_id + j) {
|
||||
//audioSampleRateMenuItems[menu_id+j];
|
||||
//std::cout << "Would set audio sample rate on device " << mdevices_i->second.name << " (" << mdevices_i->first << ") to " << (*srate) << "Hz" << std::endl;
|
||||
AudioThread::setDeviceSampleRate(mdevices_i->first, *srate);
|
||||
}
|
||||
|
||||
j++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -463,12 +454,12 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
|
||||
|
||||
if (demod->getDemodulatorType() == DEMOD_TYPE_USB) {
|
||||
demodBw /= 2;
|
||||
centerFreq += demod->getBandwidth()/4;
|
||||
centerFreq += demod->getBandwidth() / 4;
|
||||
}
|
||||
|
||||
if (demod->getDemodulatorType() == DEMOD_TYPE_LSB) {
|
||||
demodBw /= 2;
|
||||
centerFreq -= demod->getBandwidth()/4;
|
||||
centerFreq -= demod->getBandwidth() / 4;
|
||||
}
|
||||
|
||||
if (demodBw > wxGetApp().getSampleRate() / 2) {
|
||||
@ -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());
|
||||
}
|
||||
waterfallCanvas->setCenterFrequency(wxGetApp().getFrequency());
|
||||
demodWaterfallCanvas->setCenterFrequency(wxGetApp().getFrequency());
|
||||
demodSpectrumCanvas->setCenterFrequency(wxGetApp().getFrequency());
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -223,25 +223,42 @@ void TuningCanvas::OnMouseMoved(wxMouseEvent& event) {
|
||||
if (index > 0) {
|
||||
hoverIndex = index;
|
||||
hoverState = TUNING_HOVER_FREQ;
|
||||
return;
|
||||
}
|
||||
|
||||
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(), 7, bwDP, bwW); // bw
|
||||
if (index > 0) {
|
||||
hoverIndex = index;
|
||||
hoverState = TUNING_HOVER_BW;
|
||||
}
|
||||
}
|
||||
|
||||
index = glContext->GetTunerDigitIndex(mouseTracker.getMouseX(), 11, centerDP, centerW); // center
|
||||
if (index > 0) {
|
||||
hoverIndex = index;
|
||||
hoverState = TUNING_HOVER_CENTER;
|
||||
return;
|
||||
if (!index) {
|
||||
index = glContext->GetTunerDigitIndex(mouseTracker.getMouseX(), 11, centerDP, centerW); // center
|
||||
if (index > 0) {
|
||||
hoverIndex = index;
|
||||
hoverState = TUNING_HOVER_CENTER;
|
||||
}
|
||||
}
|
||||
|
||||
hoverIndex = 0;
|
||||
hoverState = TUNING_HOVER_NONE;
|
||||
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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user