Finished sink module system + new icons

This commit is contained in:
Ryzerth 2020-11-30 16:05:51 +01:00
parent 618d4ac4cc
commit e5dbac4345
11 changed files with 42 additions and 20 deletions

View File

@ -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");
}
}

View File

@ -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();

View File

@ -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();

View File

@ -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) {

View File

@ -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<dsp::stereo_t>* bindStream(std::string name);
void unbindStream(std::string name, dsp::stream<dsp::stereo_t>* stream);

View File

@ -106,6 +106,7 @@ void SigPath::setDemodulator(int demId, float bandWidth) {
demod.setDeviation(bandwidth / 2.0f);
audioResamp.setInput(&demod.out);
audioBw = std::min<float>(bandwidth, outputSampleRate / 2.0f);
audioBw = std::min<float>(audioBw, 16000.0f);
audioResamp.setInSampleRate(200000);
audioWin.setSampleRate(200000 * audioResamp.getInterpolation());

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB