2016-05-31 17:09:38 -04:00
|
|
|
/*
|
2019-08-03 08:34:29 -04:00
|
|
|
* Copyright (C) 2016-2017 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
* Copyright (C) 2016-2018 Len Ovens <len@ovenwerks.net>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2016-05-31 17:09:38 -04:00
|
|
|
|
|
|
|
#include "boost/lambda/lambda.hpp"
|
|
|
|
|
2017-06-18 18:57:53 -04:00
|
|
|
#include "pbd/control_math.h"
|
|
|
|
|
2017-10-26 00:22:59 -04:00
|
|
|
#include "ardour/amp.h"
|
2016-05-31 17:09:38 -04:00
|
|
|
#include "ardour/session.h"
|
|
|
|
#include "ardour/dB.h"
|
|
|
|
#include "ardour/meter.h"
|
2017-03-19 11:54:58 -04:00
|
|
|
#include "ardour/monitor_processor.h"
|
2016-05-31 17:09:38 -04:00
|
|
|
|
|
|
|
#include "osc.h"
|
|
|
|
#include "osc_global_observer.h"
|
|
|
|
|
2016-07-14 14:44:52 -04:00
|
|
|
#include "pbd/i18n.h"
|
2016-05-31 17:09:38 -04:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace PBD;
|
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace ArdourSurface;
|
|
|
|
|
2017-10-17 17:56:44 -04:00
|
|
|
OSCGlobalObserver::OSCGlobalObserver (OSC& o, Session& s, ArdourSurface::OSC::OSCSurface* su)
|
|
|
|
: _osc (o)
|
|
|
|
,sur (su)
|
2017-07-23 23:07:01 -04:00
|
|
|
,_init (true)
|
2018-04-17 16:10:59 -04:00
|
|
|
,_last_master_gain (-1.0)
|
|
|
|
,_last_master_trim (-1.0)
|
|
|
|
,_last_monitor_gain (-1.0)
|
2018-02-05 13:39:58 -05:00
|
|
|
,_jog_mode (1024)
|
2017-10-26 00:22:59 -04:00
|
|
|
,last_punchin (4)
|
|
|
|
,last_punchout (4)
|
|
|
|
,last_click (4)
|
2016-05-31 17:09:38 -04:00
|
|
|
{
|
2017-07-23 23:07:01 -04:00
|
|
|
addr = lo_address_new_from_url (sur->remote_url.c_str());
|
2016-08-21 17:15:54 -04:00
|
|
|
session = &s;
|
2017-07-23 23:07:01 -04:00
|
|
|
gainmode = sur->gainmode;
|
|
|
|
feedback = sur->feedback;
|
2018-02-05 13:39:58 -05:00
|
|
|
uint32_t jogmode = sur->jogmode;
|
2017-09-18 12:39:17 -04:00
|
|
|
_last_sample = -1;
|
2018-04-17 16:10:59 -04:00
|
|
|
mark_text = "";
|
2016-06-04 10:04:32 -04:00
|
|
|
if (feedback[4]) {
|
2016-05-31 17:09:38 -04:00
|
|
|
|
2016-06-04 10:04:32 -04:00
|
|
|
// connect to all the things we want to send feed back from
|
2016-05-31 17:09:38 -04:00
|
|
|
|
2016-06-04 10:04:32 -04:00
|
|
|
/*
|
|
|
|
* Master (todo)
|
|
|
|
* Pan width
|
|
|
|
*/
|
2016-05-31 17:09:38 -04:00
|
|
|
|
2016-06-04 10:04:32 -04:00
|
|
|
// Master channel first
|
2017-10-17 17:56:44 -04:00
|
|
|
_osc.text_message (X_("/master/name"), "Master", addr);
|
2016-06-04 10:04:32 -04:00
|
|
|
boost::shared_ptr<Stripable> strip = session->master_out();
|
2016-05-31 17:09:38 -04:00
|
|
|
|
2016-06-04 10:04:32 -04:00
|
|
|
boost::shared_ptr<Controllable> mute_controllable = boost::dynamic_pointer_cast<Controllable>(strip->mute_control());
|
2017-05-10 12:56:45 -04:00
|
|
|
mute_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCGlobalObserver::send_change_message, this, X_("/master/mute"), strip->mute_control()), OSC::instance());
|
2018-04-17 16:10:59 -04:00
|
|
|
send_change_message (X_("/master/mute"), mute_controllable);
|
2016-05-31 17:09:38 -04:00
|
|
|
|
2016-06-04 10:04:32 -04:00
|
|
|
boost::shared_ptr<Controllable> trim_controllable = boost::dynamic_pointer_cast<Controllable>(strip->trim_control());
|
2017-05-10 12:56:45 -04:00
|
|
|
trim_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCGlobalObserver::send_trim_message, this, X_("/master/trimdB"), strip->trim_control()), OSC::instance());
|
2018-04-17 16:10:59 -04:00
|
|
|
send_trim_message (X_("/master/trimdB"), trim_controllable);
|
2016-05-31 17:09:38 -04:00
|
|
|
|
2016-06-04 10:04:32 -04:00
|
|
|
boost::shared_ptr<Controllable> pan_controllable = boost::dynamic_pointer_cast<Controllable>(strip->pan_azimuth_control());
|
2016-07-18 18:57:27 -04:00
|
|
|
if (pan_controllable) {
|
2017-05-10 12:56:45 -04:00
|
|
|
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());
|
2018-04-17 16:10:59 -04:00
|
|
|
send_change_message (X_("/master/pan_stereo_position"), pan_controllable);
|
2016-07-18 18:57:27 -04:00
|
|
|
}
|
2016-05-31 17:09:38 -04:00
|
|
|
|
2016-06-04 10:04:32 -04:00
|
|
|
boost::shared_ptr<Controllable> gain_controllable = boost::dynamic_pointer_cast<Controllable>(strip->gain_control());
|
2017-05-10 12:56:45 -04:00
|
|
|
gain_controllable->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCGlobalObserver::send_gain_message, this, X_("/master/"), strip->gain_control()), OSC::instance());
|
2018-04-17 16:10:59 -04:00
|
|
|
send_gain_message (X_("/master/"), gain_controllable);
|
2016-06-04 10:04:32 -04:00
|
|
|
|
|
|
|
// monitor stuff next
|
|
|
|
strip = session->monitor_out();
|
|
|
|
if (strip) {
|
2017-10-17 17:56:44 -04:00
|
|
|
_osc.text_message (X_("/monitor/name"), "Monitor", addr);
|
2016-06-04 10:04:32 -04:00
|
|
|
|
2017-03-19 11:54:58 -04:00
|
|
|
boost::shared_ptr<Controllable> mon_mute_cont = strip->monitor_control()->cut_control();
|
2017-05-10 12:56:45 -04:00
|
|
|
mon_mute_cont->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCGlobalObserver::send_change_message, this, X_("/monitor/mute"), mon_mute_cont), OSC::instance());
|
2018-02-06 15:01:06 -05:00
|
|
|
send_change_message (X_("/monitor/mute"), mon_mute_cont);
|
2017-03-19 11:54:58 -04:00
|
|
|
|
|
|
|
boost::shared_ptr<Controllable> mon_dim_cont = strip->monitor_control()->dim_control();
|
2017-05-10 12:56:45 -04:00
|
|
|
mon_dim_cont->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCGlobalObserver::send_change_message, this, X_("/monitor/dim"), mon_dim_cont), OSC::instance());
|
2018-02-06 15:01:06 -05:00
|
|
|
send_change_message (X_("/monitor/dim"), mon_dim_cont);
|
2017-03-19 11:54:58 -04:00
|
|
|
|
|
|
|
boost::shared_ptr<Controllable> mon_mono_cont = strip->monitor_control()->mono_control();
|
2017-05-10 12:56:45 -04:00
|
|
|
mon_mono_cont->Changed.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCGlobalObserver::send_change_message, this, X_("/monitor/mono"), mon_mono_cont), OSC::instance());
|
2018-02-06 15:01:06 -05:00
|
|
|
send_change_message (X_("/monitor/mono"), mon_mono_cont);
|
2017-03-19 11:54:58 -04:00
|
|
|
|
2016-06-04 10:04:32 -04:00
|
|
|
gain_controllable = boost::dynamic_pointer_cast<Controllable>(strip->gain_control());
|
2018-04-17 16:10:59 -04:00
|
|
|
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 (X_("/monitor/"), gain_controllable);
|
2016-06-04 10:04:32 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
//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 ();
|
2017-12-23 16:16:23 -05:00
|
|
|
session->locations_modified.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&OSCGlobalObserver::marks_changed, this), OSC::instance());
|
|
|
|
marks_changed ();
|
2016-06-04 10:04:32 -04:00
|
|
|
|
|
|
|
// session feedback
|
2017-10-17 17:56:44 -04:00
|
|
|
session->StateSaved.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&OSCGlobalObserver::session_name, this, X_("/session_name"), _1), OSC::instance());
|
|
|
|
session_name (X_("/session_name"), session->snap_name());
|
2016-07-13 12:56:35 -04:00
|
|
|
session->SoloActive.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&OSCGlobalObserver::solo_active, this, _1), OSC::instance());
|
|
|
|
solo_active (session->soloing() || session->listening());
|
2016-06-04 10:04:32 -04:00
|
|
|
|
2017-10-26 00:22:59 -04:00
|
|
|
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());
|
2018-02-06 15:01:06 -05:00
|
|
|
send_change_message (X_("/click/level"), click_controllable);
|
2017-10-26 00:22:59 -04:00
|
|
|
|
2018-02-06 11:47:12 -05:00
|
|
|
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);
|
|
|
|
|
2017-10-26 00:22:59 -04:00
|
|
|
extra_check ();
|
2018-02-05 13:39:58 -05:00
|
|
|
jog_mode (jogmode);
|
2017-10-26 00:22:59 -04:00
|
|
|
|
2016-06-04 10:04:32 -04:00
|
|
|
/*
|
|
|
|
* Maybe (many) more
|
|
|
|
*/
|
2016-05-31 17:09:38 -04:00
|
|
|
}
|
2017-07-23 23:07:01 -04:00
|
|
|
_init = false;
|
2016-05-31 17:09:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
OSCGlobalObserver::~OSCGlobalObserver ()
|
|
|
|
{
|
2017-07-23 23:07:01 -04:00
|
|
|
_init = true;
|
2016-05-31 17:09:38 -04:00
|
|
|
|
2017-03-19 11:54:58 -04:00
|
|
|
// need to add general zero everything messages
|
2016-05-31 17:09:38 -04:00
|
|
|
strip_connections.drop_connections ();
|
|
|
|
session_connections.drop_connections ();
|
|
|
|
|
|
|
|
lo_address_free (addr);
|
|
|
|
}
|
|
|
|
|
2017-10-17 17:56:44 -04:00
|
|
|
void
|
|
|
|
OSCGlobalObserver::clear_observer ()
|
|
|
|
{
|
|
|
|
strip_connections.drop_connections ();
|
|
|
|
session_connections.drop_connections ();
|
|
|
|
_osc.text_message (X_("/master/name"), " ", addr);
|
|
|
|
_osc.text_message (X_("/monitor/name"), " ", addr);
|
|
|
|
_osc.text_message (X_("/session_name"), " ", addr);
|
2017-12-23 16:16:23 -05:00
|
|
|
_osc.text_message (X_("/marker"), " ", addr);
|
2017-10-17 17:56:44 -04:00
|
|
|
if (feedback[6]) { // timecode enabled
|
|
|
|
_osc.text_message (X_("/position/smpte"), " ", addr);
|
|
|
|
}
|
|
|
|
if (feedback[5]) { // Bar beat enabled
|
|
|
|
_osc.text_message (X_("/position/bbt"), " ", addr);
|
|
|
|
}
|
|
|
|
if (feedback[11]) { // minutes/seconds enabled
|
|
|
|
_osc.text_message (X_("/position/time"), " ", addr);
|
|
|
|
}
|
|
|
|
if (feedback[10]) { // samples
|
|
|
|
_osc.text_message (X_("/position/samples"), " ", addr);
|
|
|
|
}
|
|
|
|
if (feedback[3]) { //heart beat enabled
|
|
|
|
_osc.float_message (X_("/heartbeat"), 0.0, addr);
|
|
|
|
}
|
|
|
|
if (feedback[7] || feedback[8]) { // meters enabled
|
|
|
|
float meter = 0;
|
|
|
|
if (feedback[7] && !gainmode) {
|
|
|
|
meter = -193;
|
|
|
|
}
|
|
|
|
_osc.float_message (X_("/master/meter"), meter, addr);
|
|
|
|
}
|
|
|
|
if (feedback[9]) {
|
|
|
|
_osc.float_message (X_("/master/signal"), 0, addr);
|
|
|
|
}
|
2018-02-06 15:01:06 -05:00
|
|
|
_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);
|
2017-10-17 17:56:44 -04:00
|
|
|
_osc.float_message (X_("/master/trimdB"), 0, addr);
|
2018-02-06 15:01:06 -05:00
|
|
|
_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);
|
2017-10-17 17:56:44 -04:00
|
|
|
_osc.float_message (X_("/loop_toggle"), 0, addr);
|
|
|
|
_osc.float_message (X_("/transport_play"), 0, addr);
|
|
|
|
_osc.float_message (X_("/transport_stop"), 0, addr);
|
2017-10-26 00:22:59 -04:00
|
|
|
_osc.float_message (X_("/toggle_roll"), 0, addr);
|
2017-10-17 17:56:44 -04:00
|
|
|
_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);
|
2017-10-26 00:22:59 -04:00
|
|
|
_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);
|
2018-02-06 11:47:12 -05:00
|
|
|
_osc.text_message (X_("/group/list"), " ", addr);
|
2018-02-05 13:39:58 -05:00
|
|
|
_osc.text_message (X_("/jog/mode/name"), " ", addr);
|
|
|
|
_osc.int_message (X_("/jog/mode"), 0, addr);
|
2017-10-17 17:56:44 -04:00
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-05-31 17:09:38 -04:00
|
|
|
void
|
|
|
|
OSCGlobalObserver::tick ()
|
|
|
|
{
|
2017-07-23 23:07:01 -04:00
|
|
|
if (_init) {
|
|
|
|
return;
|
|
|
|
}
|
2017-09-18 12:39:17 -04:00
|
|
|
samplepos_t now_sample = session->transport_sample();
|
|
|
|
if (now_sample != _last_sample) {
|
2016-05-31 17:09:38 -04:00
|
|
|
if (feedback[6]) { // timecode enabled
|
|
|
|
Timecode::Time timecode;
|
2017-09-18 12:39:17 -04:00
|
|
|
session->timecode_time (now_sample, timecode);
|
2016-05-31 17:09:38 -04:00
|
|
|
|
2017-09-18 12:39:17 -04:00
|
|
|
// Timecode mode: Hours/Minutes/Seconds/Samples
|
2016-05-31 17:09:38 -04:00
|
|
|
ostringstream os;
|
|
|
|
os << setw(2) << setfill('0') << timecode.hours;
|
|
|
|
os << ':';
|
|
|
|
os << setw(2) << setfill('0') << timecode.minutes;
|
|
|
|
os << ':';
|
|
|
|
os << setw(2) << setfill('0') << timecode.seconds;
|
2016-07-01 20:28:08 -04:00
|
|
|
os << ':';
|
2016-05-31 17:09:38 -04:00
|
|
|
os << setw(2) << setfill('0') << timecode.frames;
|
|
|
|
|
2018-02-06 15:01:06 -05:00
|
|
|
_osc.text_message (X_("/position/smpte"), os.str(), addr);
|
2016-05-31 17:09:38 -04:00
|
|
|
}
|
|
|
|
if (feedback[5]) { // Bar beat enabled
|
|
|
|
Timecode::BBT_Time bbt_time;
|
|
|
|
|
2017-09-18 12:39:17 -04:00
|
|
|
session->bbt_time (now_sample, bbt_time);
|
2016-05-31 17:09:38 -04:00
|
|
|
|
|
|
|
// semantics: BBB/bb/tttt
|
|
|
|
ostringstream os;
|
|
|
|
|
|
|
|
os << setw(3) << setfill('0') << bbt_time.bars;
|
|
|
|
os << '|';
|
|
|
|
os << setw(2) << setfill('0') << bbt_time.beats;
|
|
|
|
os << '|';
|
|
|
|
os << setw(4) << setfill('0') << bbt_time.ticks;
|
|
|
|
|
2018-02-06 15:01:06 -05:00
|
|
|
_osc.text_message (X_("/position/bbt"), os.str(), addr);
|
2016-07-01 20:28:08 -04:00
|
|
|
}
|
|
|
|
if (feedback[11]) { // minutes/seconds enabled
|
2017-09-18 12:39:17 -04:00
|
|
|
samplepos_t left = now_sample;
|
|
|
|
int hrs = (int) floor (left / (session->sample_rate() * 60.0f * 60.0f));
|
|
|
|
left -= (samplecnt_t) floor (hrs * session->sample_rate() * 60.0f * 60.0f);
|
|
|
|
int mins = (int) floor (left / (session->sample_rate() * 60.0f));
|
|
|
|
left -= (samplecnt_t) floor (mins * session->sample_rate() * 60.0f);
|
|
|
|
int secs = (int) floor (left / (float) session->sample_rate());
|
|
|
|
left -= (samplecnt_t) floor ((double)(secs * session->sample_rate()));
|
|
|
|
int millisecs = floor (left * 1000.0 / (float) session->sample_rate());
|
2016-07-01 20:28:08 -04:00
|
|
|
|
|
|
|
// Min/sec mode: Hours/Minutes/Seconds/msec
|
|
|
|
ostringstream os;
|
|
|
|
os << setw(2) << setfill('0') << hrs;
|
|
|
|
os << ':';
|
|
|
|
os << setw(2) << setfill('0') << mins;
|
|
|
|
os << ':';
|
|
|
|
os << setw(2) << setfill('0') << secs;
|
|
|
|
os << '.';
|
|
|
|
os << setw(3) << setfill('0') << millisecs;
|
|
|
|
|
2018-02-06 15:01:06 -05:00
|
|
|
_osc.text_message (X_("/position/time"), os.str(), addr);
|
2016-07-01 20:28:08 -04:00
|
|
|
}
|
|
|
|
if (feedback[10]) { // samples
|
|
|
|
ostringstream os;
|
2017-09-18 12:39:17 -04:00
|
|
|
os << now_sample;
|
2018-02-06 15:01:06 -05:00
|
|
|
_osc.text_message (X_("/position/samples"), os.str(), addr);
|
2016-05-31 17:09:38 -04:00
|
|
|
}
|
2017-09-18 12:39:17 -04:00
|
|
|
_last_sample = now_sample;
|
2017-12-23 16:16:23 -05:00
|
|
|
mark_update ();
|
2016-05-31 17:09:38 -04:00
|
|
|
}
|
|
|
|
if (feedback[3]) { //heart beat enabled
|
|
|
|
if (_heartbeat == 10) {
|
2017-10-17 17:56:44 -04:00
|
|
|
_osc.float_message (X_("/heartbeat"), 1.0, addr);
|
2016-05-31 17:09:38 -04:00
|
|
|
}
|
|
|
|
if (!_heartbeat) {
|
2017-10-17 17:56:44 -04:00
|
|
|
_osc.float_message (X_("/heartbeat"), 0.0, addr);
|
2016-05-31 17:09:38 -04:00
|
|
|
}
|
|
|
|
_heartbeat++;
|
|
|
|
if (_heartbeat > 20) _heartbeat = 0;
|
|
|
|
}
|
|
|
|
if (feedback[7] || feedback[8] || feedback[9]) { // meters enabled
|
|
|
|
// the only meter here is master
|
|
|
|
float now_meter = session->master_out()->peak_meter()->meter_level(0, MeterMCP);
|
2016-07-26 17:11:06 -04:00
|
|
|
if (now_meter < -94) now_meter = -193;
|
2016-05-31 17:09:38 -04:00
|
|
|
if (_last_meter != now_meter) {
|
|
|
|
if (feedback[7] || feedback[8]) {
|
|
|
|
if (gainmode && feedback[7]) {
|
2016-07-26 17:11:06 -04:00
|
|
|
// change from db to 0-1
|
2017-10-17 17:56:44 -04:00
|
|
|
_osc.float_message (X_("/master/meter"), ((now_meter + 94) / 100), addr);
|
2016-05-31 17:09:38 -04:00
|
|
|
} else if ((!gainmode) && feedback[7]) {
|
2017-10-17 17:56:44 -04:00
|
|
|
_osc.float_message (X_("/master/meter"), now_meter, addr);
|
2016-05-31 17:09:38 -04:00
|
|
|
} else if (feedback[8]) {
|
|
|
|
uint32_t ledlvl = (uint32_t)(((now_meter + 54) / 3.75)-1);
|
|
|
|
uint32_t ledbits = ~(0xfff<<ledlvl);
|
2017-10-17 17:56:44 -04:00
|
|
|
_osc.float_message (X_("/master/meter"), ledbits, addr);
|
2016-05-31 17:09:38 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (feedback[9]) {
|
|
|
|
float signal;
|
|
|
|
if (now_meter < -40) {
|
|
|
|
signal = 0;
|
|
|
|
} else {
|
|
|
|
signal = 1;
|
|
|
|
}
|
2017-10-17 17:56:44 -04:00
|
|
|
_osc.float_message (X_("/master/signal"), signal, addr);
|
2016-05-31 17:09:38 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
_last_meter = now_meter;
|
|
|
|
|
|
|
|
}
|
2016-10-28 20:34:17 -04:00
|
|
|
if (feedback[4]) {
|
|
|
|
if (master_timeout) {
|
|
|
|
if (master_timeout == 1) {
|
2017-10-17 17:56:44 -04:00
|
|
|
_osc.text_message (X_("/master/name"), "Master", addr);
|
2016-10-28 20:34:17 -04:00
|
|
|
}
|
|
|
|
master_timeout--;
|
|
|
|
}
|
|
|
|
if (monitor_timeout) {
|
|
|
|
if (monitor_timeout == 1) {
|
2017-10-17 17:56:44 -04:00
|
|
|
_osc.text_message (X_("/monitor/name"), "Monitor", addr);
|
2016-10-28 20:34:17 -04:00
|
|
|
}
|
|
|
|
monitor_timeout--;
|
|
|
|
}
|
2017-10-26 00:22:59 -04:00
|
|
|
extra_check ();
|
2016-10-28 20:34:17 -04:00
|
|
|
}
|
2016-05-31 17:09:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
OSCGlobalObserver::send_change_message (string path, boost::shared_ptr<Controllable> controllable)
|
|
|
|
{
|
2017-10-26 00:22:59 -04:00
|
|
|
float val = controllable->get_value();
|
|
|
|
_osc.float_message (path, (float) controllable->internal_to_interface (val), addr);
|
2017-10-17 17:56:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
OSCGlobalObserver::session_name (string path, string name)
|
|
|
|
{
|
|
|
|
_osc.text_message (path, name, addr);
|
2016-05-31 17:09:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
OSCGlobalObserver::send_gain_message (string path, boost::shared_ptr<Controllable> controllable)
|
|
|
|
{
|
2017-07-24 13:14:21 -04:00
|
|
|
bool ismaster = false;
|
2018-04-17 16:10:59 -04:00
|
|
|
|
2018-02-06 15:01:06 -05:00
|
|
|
if (path.find(X_("master")) != std::string::npos) {
|
2017-07-24 13:14:21 -04:00
|
|
|
ismaster = true;
|
|
|
|
if (_last_master_gain != controllable->get_value()) {
|
|
|
|
_last_master_gain = controllable->get_value();
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (_last_monitor_gain != controllable->get_value()) {
|
|
|
|
_last_monitor_gain = controllable->get_value();
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2016-05-31 17:09:38 -04:00
|
|
|
if (gainmode) {
|
2018-02-06 15:01:06 -05:00
|
|
|
_osc.float_message (string_compose (X_("%1fader"), path), controllable->internal_to_interface (controllable->get_value()), addr);
|
2018-01-09 22:19:29 -05:00
|
|
|
if (gainmode == 1) {
|
2018-02-06 15:01:06 -05:00
|
|
|
_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);
|
2018-01-09 22:19:29 -05:00
|
|
|
if (ismaster) {
|
|
|
|
master_timeout = 8;
|
|
|
|
} else {
|
|
|
|
monitor_timeout = 8;
|
|
|
|
}
|
2016-10-28 20:34:17 -04:00
|
|
|
}
|
2018-01-09 22:19:29 -05:00
|
|
|
}
|
|
|
|
if (!gainmode || gainmode == 2) {
|
2016-05-31 17:09:38 -04:00
|
|
|
if (controllable->get_value() < 1e-15) {
|
2018-02-06 15:01:06 -05:00
|
|
|
_osc.float_message (string_compose (X_("%1gain"),path), -200, addr);
|
2016-05-31 17:09:38 -04:00
|
|
|
} else {
|
2018-02-06 15:01:06 -05:00
|
|
|
_osc.float_message (string_compose (X_("%1gain"),path), accurate_coefficient_to_dB (controllable->get_value()), addr);
|
2016-05-31 17:09:38 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
OSCGlobalObserver::send_trim_message (string path, boost::shared_ptr<Controllable> controllable)
|
|
|
|
{
|
2017-07-24 13:14:21 -04:00
|
|
|
if (_last_master_trim != controllable->get_value()) {
|
|
|
|
_last_master_trim = controllable->get_value();
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
2017-10-17 17:56:44 -04:00
|
|
|
_osc.float_message (X_("/master/trimdB"), (float) accurate_coefficient_to_dB (controllable->get_value()), addr);
|
2016-05-31 17:09:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
OSCGlobalObserver::send_transport_state_changed()
|
|
|
|
{
|
2017-10-17 17:56:44 -04:00
|
|
|
_osc.float_message (X_("/loop_toggle"), session->get_play_loop(), addr);
|
2020-02-23 09:46:12 -05:00
|
|
|
_osc.float_message (X_("/transport_play"), session->actual_speed() == 1.0, addr);
|
|
|
|
_osc.float_message (X_("/toggle_roll"), session->actual_speed() == 1.0, addr);
|
2019-12-29 20:43:37 -05:00
|
|
|
_osc.float_message (X_("/transport_stop"), session->transport_stopped_or_stopping(), addr);
|
2020-02-23 09:46:12 -05:00
|
|
|
_osc.float_message (X_("/rewind"), session->actual_speed() < 0.0, addr);
|
|
|
|
_osc.float_message (X_("/ffwd"), (session->actual_speed() != 1.0 && session->actual_speed() > 0.0), addr);
|
2016-05-31 17:09:38 -04:00
|
|
|
}
|
|
|
|
|
2017-12-23 16:16:23 -05:00
|
|
|
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 ()
|
|
|
|
{
|
2018-04-17 16:10:59 -04:00
|
|
|
string send_str = "No Marks";
|
|
|
|
if (lm.size()) {
|
|
|
|
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;
|
|
|
|
}
|
2017-12-23 16:16:23 -05:00
|
|
|
}
|
2018-04-17 16:10:59 -04:00
|
|
|
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);
|
|
|
|
}
|
2017-12-23 16:16:23 -05:00
|
|
|
}
|
|
|
|
}
|
2018-04-17 16:10:59 -04:00
|
|
|
if (send_str != mark_text) {
|
|
|
|
mark_text = send_str;
|
2017-12-23 16:16:23 -05:00
|
|
|
_osc.text_message (X_("/marker"), send_str, addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-05-31 17:09:38 -04:00
|
|
|
void
|
|
|
|
OSCGlobalObserver::send_record_state_changed ()
|
|
|
|
{
|
2017-10-17 17:56:44 -04:00
|
|
|
_osc.float_message (X_("/rec_enable_toggle"), (int)session->get_record_enabled (), addr);
|
2016-05-31 17:09:38 -04:00
|
|
|
|
2018-07-06 11:08:29 -04:00
|
|
|
if (session->have_rec_enabled_track () || session->get_record_enabled ()) {
|
2017-10-17 17:56:44 -04:00
|
|
|
_osc.float_message (X_("/record_tally"), 1, addr);
|
2016-05-31 17:09:38 -04:00
|
|
|
} else {
|
2017-10-17 17:56:44 -04:00
|
|
|
_osc.float_message (X_("/record_tally"), 0, addr);
|
2016-05-31 17:09:38 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-10-28 16:45:30 -04:00
|
|
|
OSCGlobalObserver::solo_active (bool active)
|
2016-05-31 17:09:38 -04:00
|
|
|
{
|
2017-10-17 17:56:44 -04:00
|
|
|
_osc.float_message (X_("/cancel_all_solos"), (float) active, addr);
|
2016-10-28 18:05:40 -04:00
|
|
|
}
|
2017-10-26 00:22:59 -04:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-05 13:39:58 -05:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2018-02-06 11:47:12 -05:00
|
|
|
void
|
|
|
|
OSCGlobalObserver::group_changed (ARDOUR::RouteGroup *rg)
|
|
|
|
{
|
|
|
|
_osc.send_group_list (addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
OSCGlobalObserver::group_changed ()
|
|
|
|
{
|
|
|
|
_osc.send_group_list (addr);
|
|
|
|
}
|
|
|
|
|