#include "ardour/phase_control.h"
#include "ardour/solo_isolate_control.h"
#include "ardour/solo_safe_control.h"
+#include "ardour/vca_manager.h"
#include "osc_select_observer.h"
#include "osc.h"
, _osc_unix_server (0)
, _send_route_changes (true)
, _debugmode (Off)
+ , tick (true)
+ , bank_dirty (false)
, gui (0)
{
_instance = this;
periodic_connection = periodic_timeout->connect (sigc::mem_fun (*this, &OSC::periodic));
periodic_timeout->attach (main_loop()->get_context());
+ // catch GUI select changes for GUI_select mode
StripableSelectionChanged.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&OSC::gui_selection_changed, this, _1), this);
+ // catch track reordering
+ // receive routes added
+ session->RouteAdded.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&OSC::notify_routes_added, this, _1), this);
+ // receive VCAs added
+ session->vca_manager().VCAAdded.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&OSC::notify_vca_added, this, _1), this);
+
return 0;
}
OSCRouteObserver* o = new OSCRouteObserver (strip, addr, sid, s->gainmode, s->feedback);
route_observers.push_back (o);
- strip->DropReferences.connect (*this, MISSING_INVALIDATOR, boost::bind (&OSC::drop_route, this, boost::weak_ptr<Stripable> (strip)), this);
+ strip->DropReferences.connect (*this, MISSING_INVALIDATOR, boost::bind (&OSC::route_lost, this, boost::weak_ptr<Stripable> (strip)), this);
+}
+
+void
+OSC::route_lost (boost::weak_ptr<Stripable> wr)
+{
+ tick = false;
+ drop_route (wr);
+ bank_dirty = true;
}
void
}
}
+void
+OSC::notify_routes_added (ARDOUR::RouteList &)
+{
+ recalcbanks();
+}
+
+void
+OSC::notify_vca_added (ARDOUR::VCAList &)
+{
+ recalcbanks();
+}
+
+void
+OSC::recalcbanks ()
+{
+ for (uint32_t it = 0; it < _surface.size(); ++it) {
+ OSCSurface* sur = &_surface[it];
+ // find lo_address
+ lo_address addr = lo_address_new_from_url (sur->remote_url.c_str());
+ _set_bank (sur->bank, addr);
+ }
+}
+
/*
* This gets called not only when bank changes but also:
* - bank size change
*/
int
OSC::set_bank (uint32_t bank_start, lo_message msg)
+{
+ return _set_bank (bank_start, lo_message_get_source (msg));
+}
+
+int
+OSC::_set_bank (uint32_t bank_start, lo_address addr)
{
if (!session) {
return -1;
nstrips = session->nroutes() - 1;
}
// reset local select
- _strip_select (0, lo_message_get_source (msg));
+ _strip_select (0, addr);
// undo all listeners for this url
for (int n = 0; n <= (int) nstrips; ++n) {
boost::shared_ptr<Stripable> stp = session->get_remote_nth_stripable (n, PresentationInfo::Route);
if (stp) {
- end_listen (stp, lo_message_get_source (msg));
+ end_listen (stp, addr);
}
}
- OSCSurface *s = get_surface (lo_message_get_source (msg));
+ OSCSurface *s = get_surface (addr);
uint32_t b_size;
if (!s->bank_size) {
boost::shared_ptr<Stripable> stp = session->get_remote_nth_stripable (n - 1, PresentationInfo::Route);
if (stp) {
- listen_to_route(stp, lo_message_get_source (msg));
+ listen_to_route(stp, addr);
if (!s->feedback[10]) {
if (stp->is_selected()) {
- _strip_select (n, lo_message_get_source (msg));
+ _strip_select (n, addr);
}
}
}
}
}
+ bank_dirty = false;
+ tick = true;
return 0;
}
if (s) {
sur->surface_sel = ssid;
OSCSelectObserver* sel_fb = new OSCSelectObserver (s, addr, ssid, sur->gainmode, sur->feedback);
+ s->DropReferences.connect (*this, MISSING_INVALIDATOR, boost::bind (&OSC::recalcbanks, this), this);
sur->sel_obs = sel_fb;
} else {
route_send_fail ("select", ssid, 0 , addr);
bool
OSC::periodic (void)
{
+ if (!tick) {
+ if (bank_dirty) {
+ recalcbanks ();
+ }
+ }
+
for (GlobalObservers::iterator x = global_observers.begin(); x != global_observers.end(); x++) {
OSCGlobalObserver* go;
ro->tick();
}
}
- for (uint32_t it = 0; it < _surface.size(); ++it) {
+ for (uint32_t it = 0; it < _surface.size(); it++) {
OSCSurface* sur = &_surface[it];
OSCSelectObserver* so;
if ((so = dynamic_cast<OSCSelectObserver*>(sur->sel_obs)) != 0) {
std::string _osc_url_file;
bool _send_route_changes;
OSCDebugMode _debugmode;
+ bool tick;
+ bool bank_dirty;
void register_callbacks ();
//banking functions
int set_bank (uint32_t bank_start, lo_message msg);
+ int _set_bank (uint32_t bank_start, lo_address addr);
int bank_up (lo_message msg);
int bank_down (lo_message msg);
int set_surface (uint32_t b_size, uint32_t strips, uint32_t fb, uint32_t gmode, lo_message msg);
void listen_to_route (boost::shared_ptr<ARDOUR::Stripable>, lo_address);
void end_listen (boost::shared_ptr<ARDOUR::Stripable>, lo_address);
void drop_route (boost::weak_ptr<ARDOUR::Stripable>);
+ void route_lost (boost::weak_ptr<ARDOUR::Stripable>);
void gui_selection_changed (ARDOUR::StripableNotificationListPtr stripables);
void route_name_changed (const PBD::PropertyChange&, boost::weak_ptr<ARDOUR::Route> r, lo_address addr);
+ void recalcbanks ();
+ void notify_routes_added (ARDOUR::RouteList &);
+ void notify_vca_added (ARDOUR::VCAList &);
void update_clock ();
bool periodic (void);
#include "ardour/phase_control.h"
#include "ardour/solo_isolate_control.h"
#include "ardour/solo_safe_control.h"
+#include "ardour/route.h"
#include "osc.h"
#include "osc_select_observer.h"
lo_message msg = lo_message_new ();
- // ssid is the strip on the surface this observer refers to
- // not part of the internal ordering.
string path = "/select/name";
- /*if (feedback[2]) {
- path = set_path (path);
- } else {
- lo_message_add_int32 (msg, ssid);
- }*/
lo_message_add_string (msg, _strip->name().c_str());
lo_send_message (addr, path.c_str(), msg);
lo_message_free (msg);
+
+ //spit out the comment at the same time
+ msg = lo_message_new ();
+ path = "/select/comment";
+ boost::shared_ptr<Route> route = boost::dynamic_pointer_cast<Route> (_strip);
+ lo_message_add_string (msg, route->comment().c_str());
+ lo_send_message (addr, path.c_str(), msg);
+ lo_message_free (msg);
+
+ // lets tell the surface how many inputs this strip has
+ msg = lo_message_new ();
+ path = "/select/n_inputs";
+ lo_message_add_int32 (msg, route->n_inputs().n_total());
+ lo_send_message (addr, path.c_str(), msg);
+ lo_message_free (msg);
+ // lets tell the surface how many outputs this strip has
+ msg = lo_message_new ();
+ path = "/select/n_outputs";
+ lo_message_add_int32 (msg, route->n_outputs().n_total());
+ lo_send_message (addr, path.c_str(), msg);
+ lo_message_free (msg);
+
}
void