diff --git a/core/src/gui/icons.cpp b/core/src/gui/icons.cpp index 84b98f91..bf0c6e5f 100644 --- a/core/src/gui/icons.cpp +++ b/core/src/gui/icons.cpp @@ -11,6 +11,8 @@ namespace icons { ImTextureID PLAY; ImTextureID STOP; ImTextureID MENU; + ImTextureID MUTED; + ImTextureID UNMUTED; GLuint loadTexture(std::string path) { int w,h,n; @@ -31,5 +33,7 @@ namespace icons { PLAY = (ImTextureID)(uintptr_t)loadTexture(ROOT_DIR "/res/icons/play.png"); STOP = (ImTextureID)(uintptr_t)loadTexture(ROOT_DIR "/res/icons/stop.png"); MENU = (ImTextureID)(uintptr_t)loadTexture(ROOT_DIR "/res/icons/menu.png"); + MUTED = (ImTextureID)(uintptr_t)loadTexture(ROOT_DIR "/res/icons/muted.png"); + UNMUTED = (ImTextureID)(uintptr_t)loadTexture(ROOT_DIR "/res/icons/unmuted.png"); } } \ No newline at end of file diff --git a/core/src/gui/icons.h b/core/src/gui/icons.h index 748be74c..e71ca59a 100644 --- a/core/src/gui/icons.h +++ b/core/src/gui/icons.h @@ -8,6 +8,8 @@ namespace icons { extern ImTextureID PLAY; extern ImTextureID STOP; extern ImTextureID MENU; + extern ImTextureID MUTED; + extern ImTextureID UNMUTED; GLuint loadTexture(std::string path); void load(); diff --git a/core/src/gui/main_window.cpp b/core/src/gui/main_window.cpp index 8633ab5c..7d300efd 100644 --- a/core/src/gui/main_window.cpp +++ b/core/src/gui/main_window.cpp @@ -305,20 +305,23 @@ void drawWindow() { int height = vMax.y - vMin.y; // To Bar - if (ImGui::ImageButton(icons::MENU, ImVec2(40, 40), ImVec2(0, 0), ImVec2(1, 1), 0)) { + ImGui::PushID(ImGui::GetID("sdrpp_menu_btn")); + if (ImGui::ImageButton(icons::MENU, ImVec2(30, 30), ImVec2(0, 0), ImVec2(1, 1), 5)) { showMenu = !showMenu; } ImGui::SameLine(); if (playing) { - if (ImGui::ImageButton(icons::STOP, ImVec2(40, 40), ImVec2(0, 0), ImVec2(1, 1), 0)) { + ImGui::PushID(ImGui::GetID("sdrpp_stop_btn")); + if (ImGui::ImageButton(icons::STOP, ImVec2(30, 30), ImVec2(0, 0), ImVec2(1, 1), 5)) { sigpath::sourceManager.stop(); playing = false; } } else { // TODO: Might need to check if there even is a device - if (ImGui::ImageButton(icons::PLAY, ImVec2(40, 40), ImVec2(0, 0), ImVec2(1, 1), 0)) { + ImGui::PushID(ImGui::GetID("sdrpp_play_btn")); + if (ImGui::ImageButton(icons::PLAY, ImVec2(30, 30), ImVec2(0, 0), ImVec2(1, 1), 5)) { sigpath::sourceManager.start(); // TODO: tune in module instead sigpath::sourceManager.tune(gui::waterfall.getCenterFrequency()); @@ -328,8 +331,8 @@ void drawWindow() { ImGui::SameLine(); - ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 8); - sigpath::sinkManager.showVolumeSlider(gui::waterfall.selectedVFO, "##_sdrpp_main_volume_", 200); + //ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 8); + sigpath::sinkManager.showVolumeSlider(gui::waterfall.selectedVFO, "##_sdrpp_main_volume_", 248, 30, 5); ImGui::SameLine(); diff --git a/core/src/signal_path/sink.cpp b/core/src/signal_path/sink.cpp index 1922d61a..27222d3b 100644 --- a/core/src/signal_path/sink.cpp +++ b/core/src/signal_path/sink.cpp @@ -164,35 +164,35 @@ void SinkManager::setStreamSink(std::string name, std::string providerName) { spdlog::warn("setStreamSink is NOT implemented!!!"); } -void SinkManager::showVolumeSlider(std::string name, std::string prefix, float width) { +void SinkManager::showVolumeSlider(std::string name, std::string prefix, float width, float btnHeight, int btwBorder) { // TODO: Replace map with some hashmap for it to be faster float height = ImGui::GetTextLineHeightWithSpacing() + 2; + float sliderHeight = height; + if (btnHeight > 0) { + height = btnHeight; + } + + float ypos = ImGui::GetCursorPosY(); if (streams.find(name) == streams.end()) { float dummy = 0.0f; style::beginDisabled(); ImGui::SetNextItemWidth(width - height); - ImGui::SliderFloat((prefix + name).c_str(), &dummy, 0.0f, 1.0f, ""); - ImGui::SameLine(); ImGui::PushID(ImGui::GetID(("sdrpp_dummy_mute_btn_" + name).c_str())); - ImGui::ImageButton(icons::STOP, ImVec2(height, height), ImVec2(0, 0), ImVec2(1, 1), 0); + ImGui::ImageButton(icons::MUTED, ImVec2(height, height), ImVec2(0, 0), ImVec2(1, 1), btwBorder); ImGui::PopID(); + ImGui::SameLine(); + ImGui::SetCursorPosY(ypos - ((height - sliderHeight) / 2.0f)); + ImGui::SliderFloat((prefix + name).c_str(), &dummy, 0.0f, 1.0f, ""); + ImGui::SetCursorPosY(ypos); style::endDisabled(); } SinkManager::Stream* stream = streams[name]; - ImGui::SetNextItemWidth(width - height - 10); - if (ImGui::SliderFloat((prefix + name).c_str(), &stream->guiVolume, 0.0f, 1.0f, "")) { - stream->setVolume(stream->guiVolume); - core::configManager.aquire(); - saveStreamConfig(name); - core::configManager.release(true); - } - ImGui::SameLine(); if (stream->volumeAjust.getMuted()) { ImGui::PushID(ImGui::GetID(("sdrpp_unmute_btn_" + name).c_str())); - if (ImGui::ImageButton(icons::PLAY, ImVec2(height, height), ImVec2(0, 0), ImVec2(1, 1), 0)) { + if (ImGui::ImageButton(icons::MUTED, ImVec2(height, height), ImVec2(0, 0), ImVec2(1, 1), btwBorder)) { stream->volumeAjust.setMuted(false); core::configManager.aquire(); saveStreamConfig(name); @@ -202,7 +202,7 @@ void SinkManager::showVolumeSlider(std::string name, std::string prefix, float w } else { ImGui::PushID(ImGui::GetID(("sdrpp_mute_btn_" + name).c_str())); - if (ImGui::ImageButton(icons::STOP, ImVec2(height, height), ImVec2(0, 0), ImVec2(1, 1), 0)) { + if (ImGui::ImageButton(icons::UNMUTED, ImVec2(height, height), ImVec2(0, 0), ImVec2(1, 1), btwBorder)) { stream->volumeAjust.setMuted(true); core::configManager.aquire(); saveStreamConfig(name); @@ -210,6 +210,18 @@ void SinkManager::showVolumeSlider(std::string name, std::string prefix, float w } ImGui::PopID(); } + + ImGui::SameLine(); + + ImGui::SetNextItemWidth(width - height - 8); + ImGui::SetCursorPosY(ypos + ((height - sliderHeight) / 2.0f) + btwBorder); + if (ImGui::SliderFloat((prefix + name).c_str(), &stream->guiVolume, 0.0f, 1.0f, "")) { + stream->setVolume(stream->guiVolume); + core::configManager.aquire(); + saveStreamConfig(name); + core::configManager.release(true); + } + //ImGui::SetCursorPosY(ypos); } void SinkManager::loadStreamConfig(std::string name) { diff --git a/core/src/signal_path/sink.h b/core/src/signal_path/sink.h index d9840290..26e8ec43 100644 --- a/core/src/signal_path/sink.h +++ b/core/src/signal_path/sink.h @@ -99,7 +99,7 @@ public: void setStreamSink(std::string name, std::string providerName); - void showVolumeSlider(std::string name, std::string prefix, float width); + void showVolumeSlider(std::string name, std::string prefix, float width, float btnHeight = -1.0f, int btwBorder = 0); dsp::stream* bindStream(std::string name); void unbindStream(std::string name, dsp::stream* stream); diff --git a/radio/src/path.cpp b/radio/src/path.cpp index b87e4a6d..9ba59724 100644 --- a/radio/src/path.cpp +++ b/radio/src/path.cpp @@ -106,6 +106,7 @@ void SigPath::setDemodulator(int demId, float bandWidth) { demod.setDeviation(bandwidth / 2.0f); audioResamp.setInput(&demod.out); audioBw = std::min(bandwidth, outputSampleRate / 2.0f); + audioBw = std::min(audioBw, 16000.0f); audioResamp.setInSampleRate(200000); audioWin.setSampleRate(200000 * audioResamp.getInterpolation()); diff --git a/root_dev/res/icons/menu.png b/root_dev/res/icons/menu.png index 317cfdee..b830b5b5 100644 Binary files a/root_dev/res/icons/menu.png and b/root_dev/res/icons/menu.png differ diff --git a/root_dev/res/icons/muted.png b/root_dev/res/icons/muted.png new file mode 100644 index 00000000..e7a1ad55 Binary files /dev/null and b/root_dev/res/icons/muted.png differ diff --git a/root_dev/res/icons/play.png b/root_dev/res/icons/play.png index 93684dd2..a5bc44df 100644 Binary files a/root_dev/res/icons/play.png and b/root_dev/res/icons/play.png differ diff --git a/root_dev/res/icons/stop.png b/root_dev/res/icons/stop.png index 366651bf..6fac0cbc 100644 Binary files a/root_dev/res/icons/stop.png and b/root_dev/res/icons/stop.png differ diff --git a/root_dev/res/icons/unmuted.png b/root_dev/res/icons/unmuted.png new file mode 100644 index 00000000..64fcb987 Binary files /dev/null and b/root_dev/res/icons/unmuted.png differ