From 3b51a6e2a9db8f020f4fa972a010d4428d3cf2e8 Mon Sep 17 00:00:00 2001 From: Bruno Herbelin Date: Mon, 6 Feb 2023 08:21:37 +0100 Subject: [PATCH] Added OSC interface for batch# --- src/ControlManager.cpp | 42 ++++++++++++++++++++---------------- src/ControlManager.h | 5 ++--- src/UserInterfaceManager.cpp | 4 ++-- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/ControlManager.cpp b/src/ControlManager.cpp index 81fbe28..121f319 100644 --- a/src/ControlManager.cpp +++ b/src/ControlManager.cpp @@ -130,7 +130,17 @@ void Control::RequestListener::ProcessMessage( const osc::ReceivedMessage& m, } } // Selection sources target: apply attribute to all sources of the selection - else if ( target.compare(OSC_SELECTED) >= 0 ) + else if (target.compare(OSC_SELECTION) == 0) { + // Loop over dynamically selected sources + for (SourceList::iterator it = Mixer::selection().begin(); it != Mixer::selection().end(); ++it) { + // apply attributes + if ( Control::manager().receiveSourceAttribute( *it, attribute, m.ArgumentStream()) && Mixer::manager().currentSource() == *it) + // and send back feedback if needed + Control::manager().sendSourceAttibutes(remoteEndpoint, OSC_CURRENT); + } + } + // Batch sources target: apply attribute to all sources in the Batch + else if ( target.compare(OSC_BATCH) > 0 && target.compare(OSC_BATCH) < 3 ) { std::smatch reg_match; static std::regex reg_exp( "\\#[[:digit:]]+"); @@ -140,25 +150,19 @@ void Control::RequestListener::ProcessMessage( const osc::ReceivedMessage& m, int i = 0; std::string num = reg_match.str().substr(1, reg_match.length()-1); if ( BaseToolkit::is_a_number(num, &i)){ - // confirmed : the target is a Player selection (e.g. 'selection#2') - // loop over this selection of sources - SourceList _selection = Mixer::manager().session()->getBatch(i); - for (SourceList::iterator it = _selection.begin(); it != _selection.end(); ++it) { - // apply attributes - if ( Control::manager().receiveSourceAttribute( *it, attribute, m.ArgumentStream()) && Mixer::manager().currentSource() == *it) - // and send back feedback if needed - Control::manager().sendSourceAttibutes(remoteEndpoint, OSC_CURRENT); + if ( i < (int) Mixer::manager().session()->numBatch() ) { + // confirmed : the target is a Player Batch (e.g. 'batch#2') + // loop over this list of sources + SourceList _selection = Mixer::manager().session()->getBatch(i); + for (SourceList::iterator it = _selection.begin(); it != _selection.end(); ++it) { + // apply attributes + if ( Control::manager().receiveSourceAttribute( *it, attribute, m.ArgumentStream()) && Mixer::manager().currentSource() == *it) + // and send back feedback if needed + Control::manager().sendSourceAttibutes(remoteEndpoint, OSC_CURRENT); + } } - } - } - // not mathching regex; should be exactly OSC_SELECTED - else if (target.compare(OSC_SELECTED) == 0) { - // Loop over dynamically selected sources - for (SourceList::iterator it = Mixer::selection().begin(); it != Mixer::selection().end(); ++it) { - // apply attributes - if ( Control::manager().receiveSourceAttribute( *it, attribute, m.ArgumentStream()) && Mixer::manager().currentSource() == *it) - // and send back feedback if needed - Control::manager().sendSourceAttibutes(remoteEndpoint, OSC_CURRENT); + else + Log::Info(CONTROL_OSC_MSG "No batch '%s' requested by %s.", target.c_str(), sender); } } } diff --git a/src/ControlManager.h b/src/ControlManager.h index 7552b53..30df487 100644 --- a/src/ControlManager.h +++ b/src/ControlManager.h @@ -7,8 +7,6 @@ #include #include -#include "SourceList.h" -#include "BaseToolkit.h" #include "NetworkToolkit.h" #define OSC_SYNC "/sync" @@ -25,7 +23,8 @@ #define OSC_OUTPUT_FADE_OUT "/fade-out" #define OSC_ALL "/all" -#define OSC_SELECTED "/selection" +#define OSC_SELECTION "/selection" +#define OSC_BATCH "/batch#" #define OSC_CURRENT "/current" #define OSC_NEXT "/next" #define OSC_PREVIOUS "/previous" diff --git a/src/UserInterfaceManager.cpp b/src/UserInterfaceManager.cpp index 12a3c1a..689e367 100644 --- a/src/UserInterfaceManager.cpp +++ b/src/UserInterfaceManager.cpp @@ -105,7 +105,7 @@ TextEditor _editor; #define PLOT_CIRCLE_SEGMENTS 64 #define PLOT_ARRAY_SIZE 180 #define LABEL_AUTO_MEDIA_PLAYER ICON_FA_USER_CIRCLE " User selection" -#define LABEL_STORE_SELECTION " Create Batch" +#define LABEL_STORE_SELECTION " Create batch" #define LABEL_EDIT_FADING ICON_FA_RANDOM " Fade in & out" #define LABEL_VIDEO_SEQUENCE " Encode an image sequence" @@ -3028,7 +3028,7 @@ void SourceController::RenderSelection(size_t i) Mixer::manager().session()->deleteBatch(i); } if (ImGui::IsItemHovered()) - ImGuiToolkit::ToolTip("Delete"); + ImGuiToolkit::ToolTip("Delete batch"); ImGui::PopStyleColor(4); }