mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-27 06:08:37 -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()
|
wxEND_EVENT_TABLE()
|
||||||
|
|
||||||
AppFrame::AppFrame() :
|
AppFrame::AppFrame() :
|
||||||
wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL) {
|
wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL) {
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
SetIcon(wxICON(cubicsdr));
|
SetIcon(wxICON(cubicsdr));
|
||||||
@ -50,13 +50,7 @@ wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL) {
|
|||||||
wxBoxSizer *demodTray = new wxBoxSizer(wxHORIZONTAL);
|
wxBoxSizer *demodTray = new wxBoxSizer(wxHORIZONTAL);
|
||||||
wxBoxSizer *demodScopeTray = new wxBoxSizer(wxVERTICAL);
|
wxBoxSizer *demodScopeTray = new wxBoxSizer(wxVERTICAL);
|
||||||
|
|
||||||
int attribList[] = {
|
int attribList[] = { WX_GL_RGBA, WX_GL_STENCIL_SIZE, 8, WX_GL_BUFFER_SIZE, 24, WX_GL_DOUBLEBUFFER, 0 };
|
||||||
WX_GL_RGBA,
|
|
||||||
WX_GL_STENCIL_SIZE, 8,
|
|
||||||
WX_GL_BUFFER_SIZE, 24,
|
|
||||||
WX_GL_DOUBLEBUFFER,
|
|
||||||
0
|
|
||||||
};
|
|
||||||
|
|
||||||
demodModeSelector = new ModeSelectorCanvas(this, attribList);
|
demodModeSelector = new ModeSelectorCanvas(this, attribList);
|
||||||
demodModeSelector->addChoice(DEMOD_TYPE_FM, "FM");
|
demodModeSelector->addChoice(DEMOD_TYPE_FM, "FM");
|
||||||
@ -164,7 +158,6 @@ wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL) {
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (mdevices_i = outputDevices.begin(); mdevices_i != outputDevices.end(); mdevices_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?"));
|
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);
|
itm->SetId(wxID_RT_AUDIO_DEVICE + mdevices_i->first);
|
||||||
@ -232,18 +225,17 @@ wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL) {
|
|||||||
menuBar->Append(menu, wxT("Input &Device"));
|
menuBar->Append(menu, wxT("Input &Device"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
menu = new wxMenu;
|
menu = new wxMenu;
|
||||||
|
|
||||||
|
#define NUM_RATES_DEFAULT 4
|
||||||
#define NUM_RATES_DEFAULT 4
|
|
||||||
int desired_rates[NUM_RATES_DEFAULT] = { 48000, 44100, 96000, 192000 };
|
int desired_rates[NUM_RATES_DEFAULT] = { 48000, 44100, 96000, 192000 };
|
||||||
|
|
||||||
for (mdevices_i = outputDevices.begin(); mdevices_i != outputDevices.end(); mdevices_i++) {
|
for (mdevices_i = outputDevices.begin(); mdevices_i != outputDevices.end(); mdevices_i++) {
|
||||||
int desired_rate = 0;
|
int desired_rate = 0;
|
||||||
int desired_rank = NUM_RATES_DEFAULT+1;
|
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++) {
|
for (i = 0; i < NUM_RATES_DEFAULT; i++) {
|
||||||
if (desired_rates[i] == (*srate)) {
|
if (desired_rates[i] == (*srate)) {
|
||||||
if (desired_rank > i) {
|
if (desired_rank > i) {
|
||||||
@ -264,18 +256,19 @@ wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL) {
|
|||||||
new wxMenu;
|
new wxMenu;
|
||||||
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;
|
||||||
wxMenu *subMenu = new wxMenu;
|
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;
|
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;
|
std::stringstream srateName;
|
||||||
srateName << ((float)(*srate)/1000.0f) << "kHz";
|
srateName << ((float) (*srate) / 1000.0f) << "kHz";
|
||||||
wxMenuItem *itm = subMenu->AppendRadioItem(menu_id+j, srateName.str(), wxT("Description?"));
|
wxMenuItem *itm = subMenu->AppendRadioItem(menu_id + j, srateName.str(), wxT("Description?"));
|
||||||
|
|
||||||
if ((*srate) == AudioThread::deviceSampleRate[mdevices_i->first]) {
|
if ((*srate) == AudioThread::deviceSampleRate[mdevices_i->first]) {
|
||||||
itm->Check(true);
|
itm->Check(true);
|
||||||
}
|
}
|
||||||
audioSampleRateMenuItems[menu_id+j] = itm;
|
audioSampleRateMenuItems[menu_id + j] = itm;
|
||||||
|
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
@ -283,7 +276,6 @@ wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL) {
|
|||||||
|
|
||||||
menuBar->Append(menu, wxT("Audio &Bandwidth"));
|
menuBar->Append(menu, wxT("Audio &Bandwidth"));
|
||||||
|
|
||||||
|
|
||||||
SetMenuBar(menuBar);
|
SetMenuBar(menuBar);
|
||||||
|
|
||||||
CreateStatusBar();
|
CreateStatusBar();
|
||||||
@ -291,7 +283,6 @@ wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL) {
|
|||||||
Centre();
|
Centre();
|
||||||
Show();
|
Show();
|
||||||
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
SetIcon(wxICON(frame_icon));
|
SetIcon(wxICON(frame_icon));
|
||||||
#endif
|
#endif
|
||||||
@ -398,7 +389,6 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
|
|||||||
wxGetApp().setDevice(event.GetId() - wxID_DEVICE_ID);
|
wxGetApp().setDevice(event.GetId() - wxID_DEVICE_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (event.GetId() >= wxID_AUDIO_BANDWIDTH_BASE) {
|
if (event.GetId() >= wxID_AUDIO_BANDWIDTH_BASE) {
|
||||||
int evId = event.GetId();
|
int evId = event.GetId();
|
||||||
std::vector<RtAudio::DeviceInfo>::iterator devices_i;
|
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 menu_id = wxID_AUDIO_BANDWIDTH_BASE + wxID_AUDIO_DEVICE_MULTIPLIER * mdevices_i->first;
|
||||||
|
|
||||||
int j = 0;
|
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) {
|
if (evId == menu_id + j) {
|
||||||
//audioSampleRateMenuItems[menu_id+j];
|
//audioSampleRateMenuItems[menu_id+j];
|
||||||
@ -463,12 +454,12 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
|
|||||||
|
|
||||||
if (demod->getDemodulatorType() == DEMOD_TYPE_USB) {
|
if (demod->getDemodulatorType() == DEMOD_TYPE_USB) {
|
||||||
demodBw /= 2;
|
demodBw /= 2;
|
||||||
centerFreq += demod->getBandwidth()/4;
|
centerFreq += demod->getBandwidth() / 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (demod->getDemodulatorType() == DEMOD_TYPE_LSB) {
|
if (demod->getDemodulatorType() == DEMOD_TYPE_LSB) {
|
||||||
demodBw /= 2;
|
demodBw /= 2;
|
||||||
centerFreq -= demod->getBandwidth()/4;
|
centerFreq -= demod->getBandwidth() / 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (demodBw > wxGetApp().getSampleRate() / 2) {
|
if (demodBw > wxGetApp().getSampleRate() / 2) {
|
||||||
@ -516,11 +507,11 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
|
|||||||
demodGainMeter->setLevel(demodGainMeter->getInputValue());
|
demodGainMeter->setLevel(demodGainMeter->getInputValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wxGetApp().getFrequency() != waterfallCanvas->getCenterFrequency()) {
|
if (wxGetApp().getFrequency() != demodWaterfallCanvas->getCenterFrequency()) {
|
||||||
if (!spectrumCanvas->getMouseTracker()->mouseDown()) {
|
if (spectrumCanvas->getViewState() && abs(wxGetApp().getFrequency()-spectrumCanvas->getCenterFrequency()) > (wxGetApp().getSampleRate()/2)) {
|
||||||
spectrumCanvas->setCenterFrequency(wxGetApp().getFrequency());
|
spectrumCanvas->setCenterFrequency(wxGetApp().getFrequency());
|
||||||
}
|
|
||||||
waterfallCanvas->setCenterFrequency(wxGetApp().getFrequency());
|
waterfallCanvas->setCenterFrequency(wxGetApp().getFrequency());
|
||||||
|
}
|
||||||
demodWaterfallCanvas->setCenterFrequency(wxGetApp().getFrequency());
|
demodWaterfallCanvas->setCenterFrequency(wxGetApp().getFrequency());
|
||||||
demodSpectrumCanvas->setCenterFrequency(wxGetApp().getFrequency());
|
demodSpectrumCanvas->setCenterFrequency(wxGetApp().getFrequency());
|
||||||
}
|
}
|
||||||
|
@ -236,9 +236,9 @@ int DemodulatorInstance::getOutputDevice() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DemodulatorInstance::checkBandwidth() {
|
void DemodulatorInstance::checkBandwidth() {
|
||||||
if ((currentDemodType == DEMOD_TYPE_USB || currentDemodType == DEMOD_TYPE_LSB) && (getBandwidth() % 2)) {
|
// if ((currentDemodType == DEMOD_TYPE_USB || currentDemodType == DEMOD_TYPE_LSB) && (getBandwidth() % 2)) {
|
||||||
setBandwidth(getBandwidth()+1);
|
// setBandwidth(getBandwidth()+1);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void DemodulatorInstance::setDemodulatorType(int demod_type_in) {
|
void DemodulatorInstance::setDemodulatorType(int demod_type_in) {
|
||||||
|
@ -41,6 +41,10 @@ void InteractiveCanvas::disableView() {
|
|||||||
lastBandwidth = 0;
|
lastBandwidth = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool InteractiveCanvas::getViewState() {
|
||||||
|
return isView;
|
||||||
|
}
|
||||||
|
|
||||||
long long InteractiveCanvas::getFrequencyAt(float x) {
|
long long InteractiveCanvas::getFrequencyAt(float x) {
|
||||||
long long iqCenterFreq = getCenterFrequency();
|
long long iqCenterFreq = getCenterFrequency();
|
||||||
long long iqBandwidth = getBandwidth();
|
long long iqBandwidth = getBandwidth();
|
||||||
|
@ -15,6 +15,7 @@ public:
|
|||||||
|
|
||||||
void setView(long long center_freq_in, int bandwidth_in);
|
void setView(long long center_freq_in, int bandwidth_in);
|
||||||
void disableView();
|
void disableView();
|
||||||
|
bool getViewState();
|
||||||
|
|
||||||
void setCenterFrequency(long long center_freq_in);
|
void setCenterFrequency(long long center_freq_in);
|
||||||
long long getCenterFrequency();
|
long long getCenterFrequency();
|
||||||
|
@ -223,25 +223,42 @@ void TuningCanvas::OnMouseMoved(wxMouseEvent& event) {
|
|||||||
if (index > 0) {
|
if (index > 0) {
|
||||||
hoverIndex = index;
|
hoverIndex = index;
|
||||||
hoverState = TUNING_HOVER_FREQ;
|
hoverState = TUNING_HOVER_FREQ;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!index) {
|
||||||
index = glContext->GetTunerDigitIndex(mouseTracker.getMouseX(), 7, bwDP, bwW); // bw
|
index = glContext->GetTunerDigitIndex(mouseTracker.getMouseX(), 7, bwDP, bwW); // bw
|
||||||
if (index > 0) {
|
if (index > 0) {
|
||||||
hoverIndex = index;
|
hoverIndex = index;
|
||||||
hoverState = TUNING_HOVER_BW;
|
hoverState = TUNING_HOVER_BW;
|
||||||
return;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!index) {
|
||||||
index = glContext->GetTunerDigitIndex(mouseTracker.getMouseX(), 11, centerDP, centerW); // center
|
index = glContext->GetTunerDigitIndex(mouseTracker.getMouseX(), 11, centerDP, centerW); // center
|
||||||
if (index > 0) {
|
if (index > 0) {
|
||||||
hoverIndex = index;
|
hoverIndex = index;
|
||||||
hoverState = TUNING_HOVER_CENTER;
|
hoverState = TUNING_HOVER_CENTER;
|
||||||
return;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!index) {
|
||||||
hoverIndex = 0;
|
hoverIndex = 0;
|
||||||
hoverState = TUNING_HOVER_NONE;
|
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) {
|
void TuningCanvas::OnMouseDown(wxMouseEvent& event) {
|
||||||
@ -270,7 +287,7 @@ void TuningCanvas::OnMouseReleased(wxMouseEvent& event) {
|
|||||||
|
|
||||||
int hExponent = hoverIndex - 1;
|
int hExponent = hoverIndex - 1;
|
||||||
|
|
||||||
if (hoverState != TUNING_HOVER_NONE && !dragging) {
|
if (hoverState != TUNING_HOVER_NONE && !dragging && (downState == hoverState) && (downIndex == hoverIndex)) {
|
||||||
StepTuner(hoverState, hExponent, top);
|
StepTuner(hoverState, hExponent, top);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user