Improve OSC Logs, Settings and testing

Stronger data testing on uniform message.
This commit is contained in:
Bruno Herbelin
2024-10-13 11:00:29 +02:00
parent 73a3ec3f63
commit 167cf7c659
5 changed files with 74 additions and 35 deletions

21
rsc/osc/osc_test.sh Normal file
View File

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

View File

@@ -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,13 +974,17 @@ 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;
if (str)
{
uniform_name = std::string(str);
// get uniform value
arguments >> uniform_value >> osc::EndMessage;
// apply to ImageFilter source only
CloneSource *clonesrc = dynamic_cast<CloneSource *>(target);
if (clonesrc) {
ImageFilter *f = dynamic_cast<ImageFilter *>(clonesrc->filter());
@@ -988,7 +992,7 @@ bool Control::receiveSourceAttribute(Source *target, const std::string &attribut
f->setProgramParameter(uniform_name, uniform_value);
}
}
}
}
/// e.g. '/vimix/current/filter sf blur 0.5'
else if (attribute.compare(OSC_SOURCE_FILTER) == 0) {

View File

@@ -36,10 +36,12 @@ struct AppLog
ImGuiTextFilter Filter;
ImVector<int> 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);
}
}

View File

@@ -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, ...);

View File

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