#include "pbd/control_math.h"
+#include "ardour/amp.h"
#include "ardour/session.h"
#include "ardour/dB.h"
#include "ardour/meter.h"
,_last_master_gain (0.0)
,_last_master_trim (0.0)
,_last_monitor_gain (0.0)
+ ,_jog_mode (1024)
+ ,last_punchin (4)
+ ,last_punchout (4)
+ ,last_click (4)
{
addr = lo_address_new_from_url (sur->remote_url.c_str());
- //addr = lo_address_new (lo_address_get_hostname(a) , lo_address_get_port(a));
session = &s;
gainmode = sur->gainmode;
feedback = sur->feedback;
+ uint32_t jogmode = sur->jogmode;
_last_sample = -1;
if (feedback[4]) {
boost::shared_ptr<Controllable> mute_controllable = boost::dynamic_pointer_cast<Controllable>(strip->mute_control());
mute_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCGlobalObserver::send_change_message, this, X_("/master/mute"), strip->mute_control()), OSC::instance());
- send_change_message ("/master/mute", strip->mute_control());
+ send_change_message (X_("/master/mute"), strip->mute_control());
boost::shared_ptr<Controllable> trim_controllable = boost::dynamic_pointer_cast<Controllable>(strip->trim_control());
trim_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCGlobalObserver::send_trim_message, this, X_("/master/trimdB"), strip->trim_control()), OSC::instance());
- send_trim_message ("/master/trimdB", strip->trim_control());
+ send_trim_message (X_("/master/trimdB"), strip->trim_control());
boost::shared_ptr<Controllable> pan_controllable = boost::dynamic_pointer_cast<Controllable>(strip->pan_azimuth_control());
if (pan_controllable) {
pan_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCGlobalObserver::send_change_message, this, X_("/master/pan_stereo_position"), strip->pan_azimuth_control()), OSC::instance());
- send_change_message ("/master/pan_stereo_position", strip->pan_azimuth_control());
+ send_change_message (X_("/master/pan_stereo_position"), strip->pan_azimuth_control());
}
boost::shared_ptr<Controllable> gain_controllable = boost::dynamic_pointer_cast<Controllable>(strip->gain_control());
gain_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCGlobalObserver::send_gain_message, this, X_("/master/"), strip->gain_control()), OSC::instance());
- send_gain_message ("/master/", strip->gain_control());
+ send_gain_message (X_("/master/"), strip->gain_control());
// monitor stuff next
strip = session->monitor_out();
boost::shared_ptr<Controllable> mon_mute_cont = strip->monitor_control()->cut_control();
mon_mute_cont->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCGlobalObserver::send_change_message, this, X_("/monitor/mute"), mon_mute_cont), OSC::instance());
- send_change_message ("/monitor/mute", mon_mute_cont);
+ send_change_message (X_("/monitor/mute"), mon_mute_cont);
boost::shared_ptr<Controllable> mon_dim_cont = strip->monitor_control()->dim_control();
mon_dim_cont->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCGlobalObserver::send_change_message, this, X_("/monitor/dim"), mon_dim_cont), OSC::instance());
- send_change_message ("/monitor/dim", mon_dim_cont);
+ send_change_message (X_("/monitor/dim"), mon_dim_cont);
boost::shared_ptr<Controllable> mon_mono_cont = strip->monitor_control()->mono_control();
mon_mono_cont->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCGlobalObserver::send_change_message, this, X_("/monitor/mono"), mon_mono_cont), OSC::instance());
- send_change_message ("/monitor/mono", mon_mono_cont);
+ send_change_message (X_("/monitor/mono"), mon_mono_cont);
gain_controllable = boost::dynamic_pointer_cast<Controllable>(strip->gain_control());
gain_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCGlobalObserver::send_gain_message, this, X_("/monitor/"), strip->gain_control()), OSC::instance());
- send_gain_message ("/monitor/", strip->gain_control());
+ send_gain_message (X_("/monitor/"), strip->gain_control());
}
- /*
- * Transport (todo)
- * punchin/out
- */
//Transport feedback
session->TransportStateChange.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&OSCGlobalObserver::send_transport_state_changed, this), OSC::instance());
send_transport_state_changed ();
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());
session->SoloActive.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&OSCGlobalObserver::solo_active, this, _1), OSC::instance());
solo_active (session->soloing() || session->listening());
+ boost::shared_ptr<Controllable> click_controllable = boost::dynamic_pointer_cast<Controllable>(session->click_gain()->gain_control());
+ click_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCGlobalObserver::send_change_message, this, X_("/click/level"), click_controllable), OSC::instance());
+ send_change_message (X_("/click/level"), click_controllable);
+
+ session->route_group_added.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&OSCGlobalObserver::group_changed, this, _1), OSC::instance());
+ session->route_group_removed.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&OSCGlobalObserver::group_changed, this), OSC::instance());
+ session->route_groups_reordered.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&OSCGlobalObserver::group_changed, this), OSC::instance());
+ _osc.send_group_list (addr);
+
+ extra_check ();
+ jog_mode (jogmode);
+
/*
* Maybe (many) more
*/
_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);
}
if (feedback[9]) {
_osc.float_message (X_("/master/signal"), 0, addr);
}
- _osc.float_message ("/master/fader", 0, addr);
- _osc.float_message ("/monitor/fader", 0, addr);
- _osc.float_message ("/master/gain", -193, addr);
- _osc.float_message ("/monitor/gain", -193, addr);
+ _osc.float_message (X_("/master/fader"), 0, addr);
+ _osc.float_message (X_("/monitor/fader"), 0, addr);
+ _osc.float_message (X_("/master/gain"), -193, addr);
+ _osc.float_message (X_("/monitor/gain"), -193, addr);
_osc.float_message (X_("/master/trimdB"), 0, addr);
- _osc.float_message ("/master/mute", 0, addr);
- _osc.float_message ("/master/pan_stereo_position", 0.5, addr);
- _osc.float_message ("/monitor/mute", 0, addr);
- _osc.float_message ("/monitor/dim", 0, addr);
- _osc.float_message ("/monitor/mono", 0, addr);
+ _osc.float_message (X_("/master/mute"), 0, addr);
+ _osc.float_message (X_("/master/pan_stereo_position"), 0.5, addr);
+ _osc.float_message (X_("/monitor/mute"), 0, addr);
+ _osc.float_message (X_("/monitor/dim"), 0, addr);
+ _osc.float_message (X_("/monitor/mono"), 0, addr);
_osc.float_message (X_("/loop_toggle"), 0, addr);
_osc.float_message (X_("/transport_play"), 0, addr);
_osc.float_message (X_("/transport_stop"), 0, addr);
+ _osc.float_message (X_("/toggle_roll"), 0, addr);
_osc.float_message (X_("/rewind"), 0, addr);
_osc.float_message (X_("/ffwd"), 0, addr);
_osc.float_message (X_("/record_tally"), 0, addr);
_osc.float_message (X_("/rec_enable_toggle"), 0, addr);
_osc.float_message (X_("/cancel_all_solos"), 0, addr);
+ _osc.float_message (X_("/toggle_punch_out"), 0, addr);
+ _osc.float_message (X_("/toggle_punch_in"), 0, addr);
+ _osc.float_message (X_("/toggle_click"), 0, addr);
+ _osc.float_message (X_("/click/level"), 0, addr);
+ _osc.text_message (X_("/group/list"), " ", addr);
+ _osc.text_message (X_("/jog/mode/name"), " ", addr);
+ _osc.int_message (X_("/jog/mode"), 0, addr);
}
os << ':';
os << setw(2) << setfill('0') << timecode.frames;
- _osc.text_message ("/position/smpte", os.str(), addr);
+ _osc.text_message (X_("/position/smpte"), os.str(), addr);
}
if (feedback[5]) { // Bar beat enabled
Timecode::BBT_Time bbt_time;
os << '|';
os << setw(4) << setfill('0') << bbt_time.ticks;
- _osc.text_message ("/position/bbt", os.str(), addr);
+ _osc.text_message (X_("/position/bbt"), os.str(), addr);
}
if (feedback[11]) { // minutes/seconds enabled
samplepos_t left = now_sample;
os << '.';
os << setw(3) << setfill('0') << millisecs;
- _osc.text_message ("/position/time", os.str(), addr);
+ _osc.text_message (X_("/position/time"), os.str(), addr);
}
if (feedback[10]) { // samples
ostringstream os;
os << now_sample;
- _osc.text_message ("/position/samples", os.str(), addr);
+ _osc.text_message (X_("/position/samples"), os.str(), addr);
}
_last_sample = now_sample;
+ mark_update ();
}
if (feedback[3]) { //heart beat enabled
if (_heartbeat == 10) {
}
monitor_timeout--;
}
+ extra_check ();
}
}
void
OSCGlobalObserver::send_change_message (string path, boost::shared_ptr<Controllable> controllable)
{
- _osc.float_message (path, (float) controllable->get_value(), addr);
+ float val = controllable->get_value();
+ _osc.float_message (path, (float) controllable->internal_to_interface (val), addr);
}
void
OSCGlobalObserver::send_gain_message (string path, boost::shared_ptr<Controllable> controllable)
{
bool ismaster = false;
- if (path.find("master") != std::string::npos) {
+ if (path.find(X_("master")) != std::string::npos) {
ismaster = true;
if (_last_master_gain != controllable->get_value()) {
_last_master_gain = controllable->get_value();
}
}
if (gainmode) {
- _osc.float_message (string_compose ("%1fader", path), controllable->internal_to_interface (controllable->get_value()), addr);
- _osc.text_message (string_compose ("%1name", path), string_compose ("%1%2%3", std::fixed, std::setprecision(2), accurate_coefficient_to_dB (controllable->get_value())), addr);
- if (ismaster) {
- master_timeout = 8;
- } else {
- monitor_timeout = 8;
+ _osc.float_message (string_compose (X_("%1fader"), path), controllable->internal_to_interface (controllable->get_value()), addr);
+ if (gainmode == 1) {
+ _osc.text_message (string_compose (X_("%1name"), path), string_compose ("%1%2%3", std::fixed, std::setprecision(2), accurate_coefficient_to_dB (controllable->get_value())), addr);
+ if (ismaster) {
+ master_timeout = 8;
+ } else {
+ monitor_timeout = 8;
+ }
}
-
- } else {
+ }
+ if (!gainmode || gainmode == 2) {
if (controllable->get_value() < 1e-15) {
- _osc.float_message (string_compose ("%1gain",path), -200, addr);
+ _osc.float_message (string_compose (X_("%1gain"),path), -200, addr);
} else {
- _osc.float_message (string_compose ("%1gain",path), accurate_coefficient_to_dB (controllable->get_value()), addr);
+ _osc.float_message (string_compose (X_("%1gain"),path), accurate_coefficient_to_dB (controllable->get_value()), addr);
}
}
}
_osc.float_message (X_("/ffwd"), (session->transport_speed() != 1.0 && session->transport_speed() > 0.0), addr);
}
+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 ()
+{
+ if (!lm.size()) {
+ _osc.text_message (X_("/marker"), "No Marks", addr);
+ return;
+ }
+ 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_("/cancel_all_solos"), (float) active, addr);
}
+
+void
+OSCGlobalObserver::extra_check ()
+{
+ if (last_punchin != session->config.get_punch_in()) {
+ last_punchin = session->config.get_punch_in();
+ _osc.float_message (X_("/toggle_punch_in"), last_punchin, addr);
+ }
+ if (last_punchout != session->config.get_punch_out()) {
+ last_punchout = session->config.get_punch_out();
+ _osc.float_message (X_("/toggle_punch_out"), last_punchout, addr);
+ }
+ if (last_click != Config->get_clicking()) {
+ last_click = Config->get_clicking();
+ _osc.float_message (X_("/toggle_click"), last_click, addr);
+ }
+}
+
+void
+OSCGlobalObserver::jog_mode (uint32_t jogmode)
+{
+ if (jogmode == _jog_mode || !feedback[4]) {
+ // no change
+ return;
+ }
+ _jog_mode = jogmode;
+
+ switch(jogmode)
+ {
+ case 0:
+ _osc.text_message (X_("/jog/mode/name"), "Jog", addr);
+ break;
+ case 1:
+ _osc.text_message (X_("/jog/mode/name"), "Nudge", addr);
+ break;
+ case 2:
+ _osc.text_message (X_("/jog/mode/name"), "Scrub", addr);
+ break;
+ case 3:
+ _osc.text_message (X_("/jog/mode/name"), "Shuttle", addr);
+ break;
+ case 4:
+ _osc.text_message (X_("/jog/mode/name"), "Marker", addr);
+ break;
+ case 5:
+ _osc.text_message (X_("/jog/mode/name"), "Scroll", addr);
+ break;
+ case 6:
+ _osc.text_message (X_("/jog/mode/name"), "Track", addr);
+ break;
+ case 7:
+ _osc.text_message (X_("/jog/mode/name"), "Bank", addr);
+ break;
+ default:
+ PBD::warning << X_("Jog Mode: ") << jogmode << X_(" is not valid.") << endmsg;
+ break;
+ }
+ _osc.int_message (X_("/jog/mode"), jogmode, addr);
+}
+
+void
+OSCGlobalObserver::group_changed (ARDOUR::RouteGroup *rg)
+{
+ _osc.send_group_list (addr);
+}
+
+void
+OSCGlobalObserver::group_changed ()
+{
+ _osc.send_group_list (addr);
+}
+