diff --git a/rsc/osc/osc_test.sh b/rsc/osc/osc_test.sh new file mode 100644 index 0000000..38b6811 --- /dev/null +++ b/rsc/osc/osc_test.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +max=1 +if (( $# > 0 )); then + if (( $1 > 1 )); then + max=$1 + fi +fi + +sleep 2 + +while : +do + echo -n "." + for s in $(seq 0 $max); do + oscsend localhost 7000 /vimix/#$s/alpha f "0.$((RANDOM%9999))" + oscsend localhost 7000 /vimix/#$s/gamma f "0.$((RANDOM%9999))" + done + sleep 0.1 +done + diff --git a/src/ControlManager.cpp b/src/ControlManager.cpp index 8f0d03f..71ba02b 100644 --- a/src/ControlManager.cpp +++ b/src/ControlManager.cpp @@ -68,9 +68,9 @@ void Control::RequestListener::ProcessMessage( const osc::ReceivedMessage& m, remoteEndpoint.AddressAndPortAsString(sender); try{ -#ifdef CONTROL_DEBUG - Log::Info(CONTROL_OSC_MSG "received '%s' from %s", FullMessage(m).c_str(), sender); -#endif + // Log manager decides to show all OSC logs or not + Log::Osc(CONTROL_OSC_MSG "received '%s' from %s", FullMessage(m).c_str(), sender); + // Preprocessing with Translator std::string address_pattern = Control::manager().translate(m.AddressPattern()); @@ -974,21 +974,25 @@ bool Control::receiveSourceAttribute(Source *target, const std::string &attribut std::string uniform_name; float uniform_value = NAN; + // get uniform name const char *str = nullptr; arguments >> str; - uniform_name = std::string(str); + if (str) + { + uniform_name = std::string(str); - arguments >> uniform_value >> osc::EndMessage; + // get uniform value + arguments >> uniform_value >> osc::EndMessage; - - CloneSource *clonesrc = dynamic_cast(target); - if (clonesrc) { - ImageFilter *f = dynamic_cast(clonesrc->filter()); - if (f) { - f->setProgramParameter(uniform_name, uniform_value); + // apply to ImageFilter source only + CloneSource *clonesrc = dynamic_cast(target); + if (clonesrc) { + ImageFilter *f = dynamic_cast(clonesrc->filter()); + if (f) { + f->setProgramParameter(uniform_name, uniform_value); + } } } - } /// e.g. '/vimix/current/filter sf blur 0.5' else if (attribute.compare(OSC_SOURCE_FILTER) == 0) { diff --git a/src/Log.cpp b/src/Log.cpp index db42870..85bb85f 100644 --- a/src/Log.cpp +++ b/src/Log.cpp @@ -36,10 +36,12 @@ struct AppLog ImGuiTextFilter Filter; ImVector LineOffsets; bool LogInTitle; + bool LogOSC; AppLog() { Clear(); + LogOSC = false; } void Clear() @@ -100,13 +102,18 @@ struct AppLog // window ImGui::SameLine(0, 0); static bool numbering = true; - ImGuiToolkit::ButtonIconToggle(4, 12, &numbering ); + ImGuiToolkit::ButtonToggle( ICON_FA_SORT_NUMERIC_DOWN, &numbering, "Show line number" ); ImGui::SameLine(); + ImGuiToolkit::ButtonToggle( ICON_FA_NETWORK_WIRED, &LogOSC, "Log all incoming OSC messages"); + ImGui::SameLine(0.4f * ImGui::GetWindowContentRegionMax().x); bool clear = ImGui::Button( ICON_FA_BACKSPACE " Clear"); ImGui::SameLine(); bool copy = ImGui::Button( ICON_FA_COPY " Copy"); ImGui::SameLine(); - Filter.Draw("Filter", -60.0f); + Filter.Draw("Filter", IMGUI_RIGHT_ALIGN); + ImGui::SameLine(); + if (ImGuiToolkit::ButtonIcon(12, 14)) + Filter.Clear(); ImGui::Separator(); if ( !ImGui::BeginChild("scrolling", ImVec2(0,0), false, ImGuiWindowFlags_AlwaysHorizontalScrollbar) ) @@ -339,3 +346,13 @@ void Log::Error(const char* fmt, ...) Log::Info("Error - %s\n", buf.c_str()); } +void Log::Osc(const char *fmt, ...) +{ + if (logs.LogOSC) { + va_list args; + va_start(args, fmt); + logs.AddLog(fmt, args); + va_end(args); + } +} + diff --git a/src/Log.h b/src/Log.h index 5c6720d..5bc3191 100644 --- a/src/Log.h +++ b/src/Log.h @@ -5,6 +5,7 @@ namespace Log { // log void Info(const char* fmt, ...); + void Osc(const char* fmt, ...); void Notify(const char* fmt, ...); void Warning(const char* fmt, ...); void Error(const char* fmt, ...); diff --git a/src/UserInterfaceManager.cpp b/src/UserInterfaceManager.cpp index 8cfc2e0..40fd25f 100644 --- a/src/UserInterfaceManager.cpp +++ b/src/UserInterfaceManager.cpp @@ -5811,17 +5811,15 @@ void Navigator::RenderMainPannelSettings() Settings::application.stream_protocol = 0; if (VideoBroadcast::available()) { - char msg[256]; - ImFormatString(msg, IM_ARRAYSIZE(msg), "SRT Broadcast\n\n" - "vimix listens to SRT requests on Port %d. " - "Example network addresses to call:\n" - " srt//%s:%d (localhost)\n" - " srt//%s:%d (local IP)", - Settings::application.broadcast_port, - NetworkToolkit::host_ips()[0].c_str(), Settings::application.broadcast_port, - NetworkToolkit::host_ips()[1].c_str(), Settings::application.broadcast_port ); - ImGuiToolkit::Indication(msg, ICON_FA_GLOBE); + std::ostringstream msg; + msg << "SRT Broadcast" << std::endl << std::endl; + msg << "vimix listens to SRT requests on Port " << Settings::application.broadcast_port << std::endl << std::endl; + msg << "Valid network addresses :" << std::endl; + for (const auto& ips : NetworkToolkit::host_ips()){ + msg << "srt://" << ips << ":" << Settings::application.broadcast_port << std::endl; + } + ImGuiToolkit::Indication(msg.str().c_str(), ICON_FA_GLOBE); ImGui::SameLine(0); ImGui::SetCursorPosX(width_); ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN); @@ -5885,17 +5883,15 @@ void Navigator::RenderMainPannelSettings() ImGuiToolkit::Spacing(); ImGui::TextDisabled("OSC"); - char msg[256]; - ImFormatString(msg, IM_ARRAYSIZE(msg), "Open Sound Control\n\n" - "vimix accepts OSC messages sent by UDP on Port %d and replies on Port %d." - "Example network addresses:\n" - " udp//%s:%d (localhost)\n" - " udp//%s:%d (local IP)", - Settings::application.control.osc_port_receive, - Settings::application.control.osc_port_send, - NetworkToolkit::host_ips()[0].c_str(), Settings::application.control.osc_port_receive, - NetworkToolkit::host_ips()[1].c_str(), Settings::application.control.osc_port_receive ); - ImGuiToolkit::Indication(msg, ICON_FA_NETWORK_WIRED); + std::ostringstream msg; + msg << "Open Sound Control" << std::endl << std::endl; + msg << "vimix accepts OSC messages sent by UDP on Port " << Settings::application.control.osc_port_receive; + msg << " and replies on Port " << Settings::application.control.osc_port_send << std::endl << std::endl; + msg << "Valid network addresses:" << std::endl; + for (const auto& ips : NetworkToolkit::host_ips()){ + msg << "udp://" << ips << ":" << Settings::application.control.osc_port_receive << std::endl; + } + ImGuiToolkit::Indication(msg.str().c_str(), ICON_FA_NETWORK_WIRED); ImGui::SameLine(0); ImGui::SetCursorPosX(width_);