summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorLen Ovens <len@ovenwerks.net>2017-12-23 13:16:23 -0800
committerLen Ovens <len@ovenwerks.net>2017-12-23 13:17:11 -0800
commit283ff0230d0593bb9242921a376948b5ad803315 (patch)
tree89fa1ce0bdaaf6a253e7494155838701d2bbb61c /libs
parent37991bf4a5ca60d0eee3f743ddfeca902889a61b (diff)
OSC: Add feedback for /marker
Diffstat (limited to 'libs')
-rw-r--r--libs/surfaces/osc/osc_global_observer.cc59
-rw-r--r--libs/surfaces/osc/osc_global_observer.h18
2 files changed, 77 insertions, 0 deletions
diff --git a/libs/surfaces/osc/osc_global_observer.cc b/libs/surfaces/osc/osc_global_observer.cc
index 9307d989b6..30934f16e0 100644
--- a/libs/surfaces/osc/osc_global_observer.cc
+++ b/libs/surfaces/osc/osc_global_observer.cc
@@ -112,6 +112,8 @@ OSCGlobalObserver::OSCGlobalObserver (OSC& o, Session& s, ArdourSurface::OSC::OS
session->TransportLooped.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&OSCGlobalObserver::send_transport_state_changed, this), OSC::instance());
session->RecordStateChanged.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&OSCGlobalObserver::send_record_state_changed, this), OSC::instance());
send_record_state_changed ();
+ session->locations_modified.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&OSCGlobalObserver::marks_changed, this), OSC::instance());
+ marks_changed ();
// session feedback
session->StateSaved.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&OSCGlobalObserver::session_name, this, X_("/session_name"), _1), OSC::instance());
@@ -151,6 +153,7 @@ OSCGlobalObserver::clear_observer ()
_osc.text_message (X_("/master/name"), " ", addr);
_osc.text_message (X_("/monitor/name"), " ", addr);
_osc.text_message (X_("/session_name"), " ", addr);
+ _osc.text_message (X_("/marker"), " ", addr);
if (feedback[6]) { // timecode enabled
_osc.text_message (X_("/position/smpte"), " ", addr);
}
@@ -271,6 +274,7 @@ OSCGlobalObserver::tick ()
_osc.text_message ("/position/samples", os.str(), addr);
}
_last_sample = now_sample;
+ mark_update ();
}
if (feedback[3]) { //heart beat enabled
if (_heartbeat == 10) {
@@ -402,6 +406,61 @@ OSCGlobalObserver::send_transport_state_changed()
}
void
+OSCGlobalObserver::marks_changed ()
+{
+ const Locations::LocationList& ll (session->locations ()->list ());
+ // get Locations that are marks
+ for (Locations::LocationList::const_iterator l = ll.begin(); l != ll.end(); ++l) {
+ if ((*l)->is_session_range ()) {
+ lm.push_back (LocationMarker(_("start"), (*l)->start ()));
+ lm.push_back (LocationMarker(_("end"), (*l)->end ()));
+ continue;
+ }
+ if ((*l)->is_mark ()) {
+ lm.push_back (LocationMarker((*l)->name(), (*l)->start ()));
+ }
+ }
+ // sort them by position
+ LocationMarkerSort location_marker_sort;
+ std::sort (lm.begin(), lm.end(), location_marker_sort);
+ mark_update ();
+
+}
+
+void
+OSCGlobalObserver::mark_update ()
+{
+ uint32_t prev = 0;
+ uint32_t next = lm.size() - 1;
+ for (uint32_t i = 0; i < lm.size (); i++) {
+ if ((lm[i].when <= _last_sample) && (i > prev)) {
+ prev = i;
+ }
+ if ((lm[i].when >= _last_sample) && (i < next)) {
+ next = i;
+ break;
+ }
+ }
+ if ((prev_mark != lm[prev].when) || (next_mark != lm[next].when)) {
+ string send_str = lm[prev].label;
+ prev_mark = lm[prev].when;
+ next_mark = lm[next].when;
+ if (prev != next) {
+ send_str = string_compose ("%1 <-> %2", lm[prev].label, lm[next].label);
+ }
+ if (_last_sample > lm[lm.size() - 1].when) {
+ send_str = string_compose ("%1 <-", lm[lm.size() - 1].label);
+ }
+ if (_last_sample < lm[0].when) {
+ send_str = string_compose ("-> %1", lm[0].label);
+ }
+ _osc.text_message (X_("/marker"), send_str, addr);
+ }
+
+
+}
+
+void
OSCGlobalObserver::send_record_state_changed ()
{
_osc.float_message (X_("/rec_enable_toggle"), (int)session->get_record_enabled (), addr);
diff --git a/libs/surfaces/osc/osc_global_observer.h b/libs/surfaces/osc/osc_global_observer.h
index ef9637274f..41700bbd89 100644
--- a/libs/surfaces/osc/osc_global_observer.h
+++ b/libs/surfaces/osc/osc_global_observer.h
@@ -69,6 +69,22 @@ class OSCGlobalObserver
uint32_t last_punchin;
uint32_t last_punchout;
uint32_t last_click;
+ samplepos_t prev_mark;
+ samplepos_t next_mark;
+ struct LocationMarker {
+ LocationMarker (const std::string& l, samplepos_t w)
+ : label (l), when (w) {}
+ std::string label;
+ samplepos_t when;
+ };
+ std::vector<LocationMarker> lm;
+
+ struct LocationMarkerSort {
+ bool operator() (const LocationMarker& a, const LocationMarker& b) {
+ return (a.when < b.when);
+ }
+ };
+
void send_change_message (std::string path, boost::shared_ptr<PBD::Controllable> controllable);
void send_gain_message (std::string path, boost::shared_ptr<PBD::Controllable> controllable);
@@ -78,6 +94,8 @@ class OSCGlobalObserver
void solo_active (bool active);
void session_name (std::string path, std::string name);
void extra_check (void);
+ void marks_changed (void);
+ void mark_update (void);
};
#endif /* __osc_oscglobalobserver_h__ */