center tuning and more

This commit is contained in:
Ryzerth 2020-12-08 16:27:52 +01:00
parent 7ba6081cb3
commit 16d8a31c12
9 changed files with 49 additions and 7 deletions

View File

@ -13,6 +13,8 @@ namespace icons {
ImTextureID MENU; ImTextureID MENU;
ImTextureID MUTED; ImTextureID MUTED;
ImTextureID UNMUTED; ImTextureID UNMUTED;
ImTextureID NORMAL_TUNING;
ImTextureID CENTER_TUNING;
GLuint loadTexture(std::string path) { GLuint loadTexture(std::string path) {
int w,h,n; int w,h,n;
@ -35,5 +37,7 @@ namespace icons {
MENU = (ImTextureID)(uintptr_t)loadTexture(ROOT_DIR "/res/icons/menu.png"); MENU = (ImTextureID)(uintptr_t)loadTexture(ROOT_DIR "/res/icons/menu.png");
MUTED = (ImTextureID)(uintptr_t)loadTexture(ROOT_DIR "/res/icons/muted.png"); MUTED = (ImTextureID)(uintptr_t)loadTexture(ROOT_DIR "/res/icons/muted.png");
UNMUTED = (ImTextureID)(uintptr_t)loadTexture(ROOT_DIR "/res/icons/unmuted.png"); UNMUTED = (ImTextureID)(uintptr_t)loadTexture(ROOT_DIR "/res/icons/unmuted.png");
NORMAL_TUNING = (ImTextureID)(uintptr_t)loadTexture(ROOT_DIR "/res/icons/normal_tuning.png");
CENTER_TUNING = (ImTextureID)(uintptr_t)loadTexture(ROOT_DIR "/res/icons/center_tuning.png");
} }
} }

View File

@ -10,6 +10,8 @@ namespace icons {
extern ImTextureID MENU; extern ImTextureID MENU;
extern ImTextureID MUTED; extern ImTextureID MUTED;
extern ImTextureID UNMUTED; extern ImTextureID UNMUTED;
extern ImTextureID NORMAL_TUNING;
extern ImTextureID CENTER_TUNING;
GLuint loadTexture(std::string path); GLuint loadTexture(std::string path);
void load(); void load();

View File

@ -163,6 +163,8 @@ void windowInit() {
// Add default main config to avoid having to ship one // Add default main config to avoid having to ship one
// Have a good directory system on both linux and windows (should fix occassional underruns) // Have a good directory system on both linux and windows (should fix occassional underruns)
// Switch to double buffering // Switch to double buffering
// Fix gain not updated on startup, soapysdr
// Fix memory leak when enabling and disabling repeatedly
// TODO for 0.2.6 // TODO for 0.2.6
// Add a module add/remove/change order menu // Add a module add/remove/change order menu
@ -232,6 +234,7 @@ void setVFO(double freq) {
if (centerTuning) { if (centerTuning) {
gui::waterfall.setViewOffset((BW / 2.0) - (viewBW / 2.0)); gui::waterfall.setViewOffset((BW / 2.0) - (viewBW / 2.0));
gui::waterfall.setCenterFrequency(freq); gui::waterfall.setCenterFrequency(freq);
gui::waterfall.setViewOffset(0);
sigpath::vfoManager.setCenterOffset(gui::waterfall.selectedVFO, 0); sigpath::vfoManager.setCenterOffset(gui::waterfall.selectedVFO, 0);
sigpath::sourceManager.tune(freq); sigpath::sourceManager.tune(freq);
return; return;
@ -310,6 +313,9 @@ void drawWindow() {
if (vfo != NULL) { if (vfo != NULL) {
if (vfo->centerOffsetChanged) { if (vfo->centerOffsetChanged) {
if (centerTuning) {
setVFO(gui::waterfall.getCenterFrequency() + vfo->generalOffset);
}
gui::freqSelect.setFrequency(gui::waterfall.getCenterFrequency() + vfo->generalOffset); gui::freqSelect.setFrequency(gui::waterfall.getCenterFrequency() + vfo->generalOffset);
gui::freqSelect.frequencyChanged = false; gui::freqSelect.frequencyChanged = false;
core::configManager.aquire(); core::configManager.aquire();
@ -401,12 +407,37 @@ void drawWindow() {
ImGui::SameLine(); ImGui::SameLine();
//ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 8); //ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 8);
sigpath::sinkManager.showVolumeSlider(gui::waterfall.selectedVFO, "##_sdrpp_main_volume_", 248, 30, 5); sigpath::sinkManager.showVolumeSlider(gui::waterfall.selectedVFO, "##_sdrpp_main_volume_", 248, 30, 5, true);
ImGui::SameLine(); ImGui::SameLine();
gui::freqSelect.draw(); gui::freqSelect.draw();
//ImGui::SameLine();
ImGui::SetCursorPosY(ImGui::GetCursorPosY() - 9);
if (centerTuning) {
ImGui::PushID(ImGui::GetID("sdrpp_ena_st_btn"));
if (ImGui::ImageButton(icons::CENTER_TUNING, ImVec2(30, 30), ImVec2(0, 0), ImVec2(1, 1), 5)) {
centerTuning = false;
core::configManager.aquire();
core::configManager.conf["centerTuning"] = centerTuning;
core::configManager.release(true);
}
ImGui::PopID();
}
else { // TODO: Might need to check if there even is a device
ImGui::PushID(ImGui::GetID("sdrpp_dis_st_btn"));
if (ImGui::ImageButton(icons::NORMAL_TUNING, ImVec2(30, 30), ImVec2(0, 0), ImVec2(1, 1), 5)) {
centerTuning = true;
setVFO(gui::freqSelect.frequency);
core::configManager.aquire();
core::configManager.conf["centerTuning"] = centerTuning;
core::configManager.release(true);
}
ImGui::PopID();
}
ImGui::SameLine(); ImGui::SameLine();
// Logo button // Logo button

View File

@ -151,7 +151,10 @@ void FrequencySelect::draw() {
frequency = freq; frequency = freq;
ImGui::PopFont(); ImGui::PopFont();
ImGui::NewLine();
ImGui::SetCursorPosX(digitBottomMaxs[11].x + 17);
//ImGui::NewLine();
} }
void FrequencySelect::setFrequency(uint64_t freq) { void FrequencySelect::setFrequency(uint64_t freq) {

View File

@ -164,7 +164,7 @@ void SinkManager::setStreamSink(std::string name, std::string providerName) {
spdlog::warn("setStreamSink is NOT implemented!!!"); spdlog::warn("setStreamSink is NOT implemented!!!");
} }
void SinkManager::showVolumeSlider(std::string name, std::string prefix, float width, float btnHeight, int btwBorder) { void SinkManager::showVolumeSlider(std::string name, std::string prefix, float width, float btnHeight, int btwBorder, bool sameLine) {
// TODO: Replace map with some hashmap for it to be faster // TODO: Replace map with some hashmap for it to be faster
float height = ImGui::GetTextLineHeightWithSpacing() + 2; float height = ImGui::GetTextLineHeightWithSpacing() + 2;
float sliderHeight = height; float sliderHeight = height;
@ -185,6 +185,7 @@ void SinkManager::showVolumeSlider(std::string name, std::string prefix, float w
ImGui::SetCursorPosY(ypos + ((height - sliderHeight) / 2.0f) + btwBorder); ImGui::SetCursorPosY(ypos + ((height - sliderHeight) / 2.0f) + btwBorder);
ImGui::SliderFloat((prefix + name).c_str(), &dummy, 0.0f, 1.0f, ""); ImGui::SliderFloat((prefix + name).c_str(), &dummy, 0.0f, 1.0f, "");
style::endDisabled(); style::endDisabled();
if (sameLine) { ImGui::SetCursorPosY(ypos); }
return; return;
} }
@ -221,6 +222,7 @@ void SinkManager::showVolumeSlider(std::string name, std::string prefix, float w
saveStreamConfig(name); saveStreamConfig(name);
core::configManager.release(true); core::configManager.release(true);
} }
if (sameLine) { ImGui::SetCursorPosY(ypos); }
//ImGui::SetCursorPosY(ypos); //ImGui::SetCursorPosY(ypos);
} }

View File

@ -99,7 +99,7 @@ public:
void setStreamSink(std::string name, std::string providerName); void setStreamSink(std::string name, std::string providerName);
void showVolumeSlider(std::string name, std::string prefix, float width, float btnHeight = -1.0f, int btwBorder = 0); void showVolumeSlider(std::string name, std::string prefix, float width, float btnHeight = -1.0f, int btwBorder = 0, bool sameLine = false);
dsp::stream<dsp::stereo_t>* bindStream(std::string name); dsp::stream<dsp::stereo_t>* bindStream(std::string name);
void unbindStream(std::string name, dsp::stream<dsp::stereo_t>* stream); void unbindStream(std::string name, dsp::stream<dsp::stereo_t>* stream);

View File

@ -1,9 +1,9 @@
{ {
"bandPlan": "General", "bandPlan": "General",
"bandPlanEnabled": true, "bandPlanEnabled": true,
"centerTuning": false, "centerTuning": true,
"fftHeight": 300, "fftHeight": 300,
"frequency": 100100000, "frequency": 99000000,
"max": 0.0, "max": 0.0,
"maximized": false, "maximized": false,
"menuOrder": [ "menuOrder": [
@ -41,7 +41,7 @@
"Radio": { "Radio": {
"muted": false, "muted": false,
"sink": "Audio", "sink": "Audio",
"volume": 0.29591837525367737 "volume": 0.47959184646606445
}, },
"Radio 1": { "Radio 1": {
"muted": false, "muted": false,

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB