2017-04-05 05:04:16 -04:00
|
|
|
/*
|
2019-08-03 08:34:29 -04:00
|
|
|
* Copyright (C) 2017-2018 Robin Gareus <robin@gareus.org>
|
2017-04-05 05:04:16 -04:00
|
|
|
*
|
2019-08-03 08:34:29 -04:00
|
|
|
* 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.
|
2017-04-05 05:04:16 -04:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
2019-08-03 08:34:29 -04:00
|
|
|
* 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.
|
2017-04-05 05:04:16 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ardour/automation_control.h"
|
|
|
|
#include "ardour/gain_control.h"
|
|
|
|
#include "ardour/meter.h"
|
|
|
|
#include "ardour/plugin_insert.h"
|
|
|
|
#include "ardour/session.h"
|
|
|
|
#include "ardour/stripable.h"
|
|
|
|
#include "ardour/track.h"
|
|
|
|
#include "ardour/value_as_string.h"
|
|
|
|
|
|
|
|
#include "control_protocol/control_protocol.h"
|
|
|
|
|
|
|
|
#include "fp8_strip.h"
|
|
|
|
|
|
|
|
using namespace ARDOUR;
|
2017-12-12 08:09:40 -05:00
|
|
|
using namespace ArdourSurface::FP_NAMESPACE;
|
|
|
|
using namespace ArdourSurface::FP_NAMESPACE::FP8Types;
|
2017-04-05 05:04:16 -04:00
|
|
|
|
2017-10-19 10:57:12 -04:00
|
|
|
uint8_t /* static */
|
|
|
|
FP8Strip::midi_ctrl_id (CtrlElement type, uint8_t id)
|
|
|
|
{
|
|
|
|
assert (id < N_STRIPS);
|
2017-12-12 07:29:54 -05:00
|
|
|
if (id < 8) {
|
|
|
|
switch (type) {
|
|
|
|
case BtnSolo:
|
|
|
|
return 0x08 + id;
|
|
|
|
case BtnMute:
|
|
|
|
return 0x10 + id;
|
|
|
|
case BtnSelect:
|
|
|
|
return 0x18 + id;
|
|
|
|
case Fader:
|
|
|
|
return 0xe0 + id;
|
|
|
|
case Meter:
|
|
|
|
return 0xd0 + id;
|
|
|
|
case Redux:
|
|
|
|
return 0xd8 + id;
|
|
|
|
case BarVal:
|
|
|
|
return 0x30 + id;
|
|
|
|
case BarMode:
|
|
|
|
return 0x38 + id;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
id -= 8;
|
|
|
|
switch (type) {
|
|
|
|
case BtnSolo:
|
2018-01-23 13:00:18 -05:00
|
|
|
switch (id) {
|
|
|
|
case 3:
|
|
|
|
return 0x58;
|
|
|
|
case 6:
|
|
|
|
return 0x59;
|
|
|
|
default:
|
|
|
|
return 0x50 + id;
|
|
|
|
}
|
2017-12-12 07:29:54 -05:00
|
|
|
case BtnMute:
|
|
|
|
return 0x78 + id;
|
|
|
|
case BtnSelect:
|
|
|
|
if (id == 0) { // strip 8
|
|
|
|
return 0x07;
|
|
|
|
} else {
|
2017-12-13 15:59:22 -05:00
|
|
|
return 0x20 + id;
|
2017-12-12 07:29:54 -05:00
|
|
|
}
|
|
|
|
case Fader:
|
|
|
|
return 0xe8 + id;
|
|
|
|
case Meter:
|
|
|
|
return 0xc0 + id;
|
|
|
|
case Redux:
|
|
|
|
return 0xc8 + id;
|
|
|
|
case BarVal:
|
|
|
|
return 0x40 + id;
|
|
|
|
case BarMode:
|
|
|
|
return 0x48 + id;
|
|
|
|
}
|
2017-10-19 10:57:12 -04:00
|
|
|
}
|
|
|
|
assert (0);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-04-05 05:04:16 -04:00
|
|
|
FP8Strip::FP8Strip (FP8Base& b, uint8_t id)
|
|
|
|
: _base (b)
|
|
|
|
, _id (id)
|
2017-10-19 10:57:12 -04:00
|
|
|
, _solo (b, midi_ctrl_id (BtnSolo, id))
|
|
|
|
, _mute (b, midi_ctrl_id (BtnMute, id))
|
|
|
|
, _selrec (b, midi_ctrl_id (BtnSelect, id), true)
|
2017-04-05 05:04:16 -04:00
|
|
|
, _touching (false)
|
|
|
|
, _strip_mode (0)
|
|
|
|
, _bar_mode (0)
|
|
|
|
, _displaymode (Stripables)
|
|
|
|
{
|
2017-10-19 10:57:12 -04:00
|
|
|
assert (id < N_STRIPS);
|
2017-04-05 05:04:16 -04:00
|
|
|
|
|
|
|
_last_fader = 65535;
|
2017-04-14 07:57:14 -04:00
|
|
|
_last_meter = _last_redux = _last_barpos = 0xff;
|
2017-04-05 05:04:16 -04:00
|
|
|
|
|
|
|
_mute.StateChange.connect_same_thread (_button_connections, boost::bind (&FP8Strip::set_mute, this, _1));
|
|
|
|
_solo.StateChange.connect_same_thread (_button_connections, boost::bind (&FP8Strip::set_solo, this, _1));
|
|
|
|
select_button ().released.connect_same_thread (_button_connections, boost::bind (&FP8Strip::set_select, this));
|
|
|
|
recarm_button ().released.connect_same_thread (_button_connections, boost::bind (&FP8Strip::set_recarm, this));
|
|
|
|
b.Periodic.connect_same_thread (_base_connection, boost::bind (&FP8Strip::periodic, this));
|
|
|
|
}
|
|
|
|
|
|
|
|
FP8Strip::~FP8Strip ()
|
2017-04-18 09:01:54 -04:00
|
|
|
{
|
|
|
|
drop_automation_controls ();
|
|
|
|
_base_connection.disconnect ();
|
|
|
|
_button_connections.drop_connections ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FP8Strip::drop_automation_controls ()
|
2017-04-05 05:04:16 -04:00
|
|
|
{
|
|
|
|
_fader_connection.disconnect ();
|
|
|
|
_mute_connection.disconnect ();
|
|
|
|
_solo_connection.disconnect ();
|
|
|
|
_rec_connection.disconnect ();
|
|
|
|
_pan_connection.disconnect ();
|
2017-04-18 09:01:54 -04:00
|
|
|
_x_select_connection.disconnect ();
|
2017-04-05 05:04:16 -04:00
|
|
|
|
|
|
|
_fader_ctrl.reset ();
|
|
|
|
_mute_ctrl.reset ();
|
|
|
|
_solo_ctrl.reset ();
|
|
|
|
_rec_ctrl.reset ();
|
|
|
|
_pan_ctrl.reset ();
|
2017-04-18 09:01:54 -04:00
|
|
|
_x_select_ctrl.reset ();
|
|
|
|
_peak_meter.reset ();
|
|
|
|
_redux_ctrl.reset ();
|
|
|
|
_select_plugin_functor.clear ();
|
2017-04-05 05:04:16 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FP8Strip::initialize ()
|
|
|
|
{
|
|
|
|
/* this is called once midi transmission is possible,
|
|
|
|
* ie from FaderPort8::connected()
|
|
|
|
*/
|
|
|
|
_solo.set_active (false);
|
2017-07-18 19:52:14 -04:00
|
|
|
_solo.set_blinking (false);
|
2017-04-05 05:04:16 -04:00
|
|
|
_mute.set_active (false);
|
|
|
|
|
|
|
|
/* reset momentary button state */
|
|
|
|
_mute.reset ();
|
|
|
|
_solo.reset ();
|
|
|
|
|
2017-04-18 09:01:54 -04:00
|
|
|
drop_automation_controls ();
|
2017-04-05 05:04:16 -04:00
|
|
|
|
|
|
|
select_button ().set_color (0xffffffff);
|
|
|
|
select_button ().set_active (false);
|
|
|
|
select_button ().set_blinking (false);
|
|
|
|
|
|
|
|
recarm_button ().set_active (false);
|
|
|
|
recarm_button ().set_color (0xffffffff);
|
|
|
|
|
|
|
|
set_strip_mode (0, true);
|
|
|
|
|
|
|
|
// force unset txt
|
|
|
|
_last_line[0].clear ();
|
|
|
|
_last_line[1].clear ();
|
|
|
|
_last_line[2].clear ();
|
|
|
|
_last_line[3].clear ();
|
|
|
|
_base.tx_sysex (4, 0x12, _id, 0x00, 0x00);
|
|
|
|
_base.tx_sysex (4, 0x12, _id, 0x01, 0x00);
|
|
|
|
_base.tx_sysex (4, 0x12, _id, 0x02, 0x00);
|
|
|
|
_base.tx_sysex (4, 0x12, _id, 0x03, 0x00);
|
|
|
|
|
|
|
|
set_bar_mode (4); // off
|
|
|
|
|
2017-10-19 10:57:12 -04:00
|
|
|
_base.tx_midi2 (midi_ctrl_id (Meter, _id), 0); // reset meter
|
|
|
|
_base.tx_midi2 (midi_ctrl_id (Redux, _id), 0); // reset redux
|
2017-04-05 05:04:16 -04:00
|
|
|
|
2017-10-19 10:57:12 -04:00
|
|
|
_base.tx_midi3 (midi_ctrl_id (Fader, _id), 0, 0); // fader
|
2017-04-18 09:01:54 -04:00
|
|
|
|
|
|
|
/* clear cached values */
|
|
|
|
_last_fader = 65535;
|
|
|
|
_last_meter = _last_redux = _last_barpos = 0xff;
|
2017-04-05 05:04:16 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define GENERATE_SET_CTRL_FUNCTION(NAME) \
|
|
|
|
void \
|
|
|
|
FP8Strip::set_ ##NAME##_controllable (boost::shared_ptr<AutomationControl> ac) \
|
|
|
|
{ \
|
|
|
|
if (_##NAME##_ctrl == ac) { \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
_##NAME##_connection.disconnect(); \
|
|
|
|
_##NAME##_ctrl = ac; \
|
|
|
|
\
|
|
|
|
if (ac) { \
|
|
|
|
ac->Changed.connect (_##NAME##_connection, MISSING_INVALIDATOR, \
|
|
|
|
boost::bind (&FP8Strip::notify_##NAME##_changed, this), fp8_context()); \
|
|
|
|
} \
|
|
|
|
notify_##NAME##_changed (); \
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GENERATE_SET_CTRL_FUNCTION (fader)
|
|
|
|
GENERATE_SET_CTRL_FUNCTION (mute)
|
|
|
|
GENERATE_SET_CTRL_FUNCTION (solo)
|
|
|
|
GENERATE_SET_CTRL_FUNCTION (rec)
|
|
|
|
GENERATE_SET_CTRL_FUNCTION (pan)
|
2017-04-14 16:46:41 -04:00
|
|
|
GENERATE_SET_CTRL_FUNCTION (x_select)
|
2017-04-05 05:04:16 -04:00
|
|
|
|
|
|
|
#undef GENERATE_SET_CTRL_FUNCTION
|
|
|
|
|
2017-04-14 16:46:41 -04:00
|
|
|
// special case -- w/_select_plugin_functor
|
|
|
|
void
|
|
|
|
FP8Strip::set_select_controllable (boost::shared_ptr<AutomationControl> ac)
|
|
|
|
{
|
|
|
|
_select_plugin_functor.clear ();
|
|
|
|
set_x_select_controllable (ac);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FP8Strip::set_select_cb (boost::function<void ()>& functor)
|
|
|
|
{
|
|
|
|
set_select_controllable (boost::shared_ptr<AutomationControl>());
|
|
|
|
_select_plugin_functor = functor;
|
|
|
|
}
|
|
|
|
|
2017-04-05 05:04:16 -04:00
|
|
|
void
|
|
|
|
FP8Strip::unset_controllables (int which)
|
|
|
|
{
|
|
|
|
_peak_meter = boost::shared_ptr<ARDOUR::PeakMeter>();
|
|
|
|
_redux_ctrl = boost::shared_ptr<ARDOUR::ReadOnlyControl>();
|
2017-06-30 13:55:03 -04:00
|
|
|
_stripable_name.clear ();
|
2017-04-05 05:04:16 -04:00
|
|
|
|
|
|
|
if (which & CTRL_FADER) {
|
|
|
|
set_fader_controllable (boost::shared_ptr<AutomationControl>());
|
|
|
|
}
|
|
|
|
if (which & CTRL_MUTE) {
|
|
|
|
set_mute_controllable (boost::shared_ptr<AutomationControl>());
|
|
|
|
}
|
|
|
|
if (which & CTRL_SOLO) {
|
|
|
|
set_solo_controllable (boost::shared_ptr<AutomationControl>());
|
|
|
|
}
|
|
|
|
if (which & CTRL_REC) {
|
|
|
|
set_rec_controllable (boost::shared_ptr<AutomationControl>());
|
|
|
|
}
|
|
|
|
if (which & CTRL_PAN) {
|
|
|
|
set_pan_controllable (boost::shared_ptr<AutomationControl>());
|
|
|
|
}
|
|
|
|
if (which & CTRL_SELECT) {
|
2017-04-14 16:46:41 -04:00
|
|
|
set_select_controllable (boost::shared_ptr<AutomationControl>());
|
2017-04-05 05:04:16 -04:00
|
|
|
select_button ().set_color (0xffffffff);
|
|
|
|
select_button ().set_active (false);
|
|
|
|
select_button ().set_blinking (false);
|
|
|
|
}
|
2017-04-14 07:57:14 -04:00
|
|
|
if (which & CTRL_TEXT0) {
|
2017-06-30 13:55:03 -04:00
|
|
|
set_text_line (0, "");
|
2017-04-05 05:04:16 -04:00
|
|
|
}
|
2017-04-14 07:57:14 -04:00
|
|
|
if (which & CTRL_TEXT1) {
|
2017-06-30 13:55:03 -04:00
|
|
|
set_text_line (1, "");
|
2017-04-05 05:04:16 -04:00
|
|
|
}
|
2017-04-14 07:57:14 -04:00
|
|
|
if (which & CTRL_TEXT2) {
|
2017-06-30 13:55:03 -04:00
|
|
|
set_text_line (2, "");
|
2017-04-05 05:04:16 -04:00
|
|
|
}
|
2017-04-14 07:57:14 -04:00
|
|
|
if (which & CTRL_TEXT3) {
|
2017-06-30 13:55:03 -04:00
|
|
|
set_text_line (3, "");
|
2017-04-05 05:04:16 -04:00
|
|
|
}
|
2017-04-14 07:57:14 -04:00
|
|
|
set_bar_mode (4); // Off
|
2017-04-05 05:04:16 -04:00
|
|
|
}
|
|
|
|
|
2017-06-30 13:55:03 -04:00
|
|
|
void
|
|
|
|
FP8Strip::set_strip_name ()
|
|
|
|
{
|
|
|
|
size_t lb = _base.show_meters () ? 6 : 9;
|
|
|
|
set_text_line (0, _stripable_name.substr (0, lb));
|
|
|
|
set_text_line (1, _stripable_name.length() > lb ? _stripable_name.substr (lb) : "");
|
|
|
|
}
|
|
|
|
|
2017-04-05 05:04:16 -04:00
|
|
|
void
|
|
|
|
FP8Strip::set_stripable (boost::shared_ptr<Stripable> s, bool panmode)
|
|
|
|
{
|
|
|
|
assert (s);
|
|
|
|
|
2017-06-30 13:55:03 -04:00
|
|
|
if (_base.show_meters () && _base.show_panner ()) {
|
|
|
|
set_strip_mode (5, true);
|
|
|
|
} else if (_base.show_meters ()) {
|
|
|
|
set_strip_mode (4, true);
|
|
|
|
} else {
|
|
|
|
set_strip_mode (0, true);
|
|
|
|
}
|
|
|
|
if (!_base.show_panner ()) {
|
|
|
|
set_bar_mode (4, true); // Off
|
|
|
|
}
|
|
|
|
|
2017-04-05 05:04:16 -04:00
|
|
|
if (panmode) {
|
|
|
|
set_fader_controllable (s->pan_azimuth_control ());
|
|
|
|
} else {
|
|
|
|
set_fader_controllable (s->gain_control ());
|
|
|
|
}
|
|
|
|
set_pan_controllable (s->pan_azimuth_control ());
|
|
|
|
|
|
|
|
if (s->is_monitor ()) {
|
|
|
|
set_mute_controllable (boost::shared_ptr<AutomationControl>());
|
|
|
|
} else {
|
|
|
|
set_mute_controllable (s->mute_control ());
|
|
|
|
}
|
|
|
|
set_solo_controllable (s->solo_control ());
|
|
|
|
|
|
|
|
if (boost::dynamic_pointer_cast<Track> (s)) {
|
|
|
|
boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track>(s);
|
|
|
|
set_rec_controllable (t->rec_enable_control ());
|
|
|
|
recarm_button ().set_color (0xff0000ff);
|
|
|
|
} else {
|
|
|
|
set_rec_controllable (boost::shared_ptr<AutomationControl>());
|
|
|
|
recarm_button ().set_color (0xffffffff);
|
|
|
|
recarm_button ().set_active (false);
|
|
|
|
}
|
|
|
|
_peak_meter = s->peak_meter ();
|
|
|
|
_redux_ctrl = s->comp_redux_controllable ();
|
|
|
|
|
2017-04-14 16:46:41 -04:00
|
|
|
set_select_controllable (boost::shared_ptr<AutomationControl>());
|
2017-04-05 05:04:16 -04:00
|
|
|
select_button ().set_active (s->is_selected ());
|
2017-12-20 20:23:11 -05:00
|
|
|
|
|
|
|
set_select_button_color (s->presentation_info ().color());
|
2017-04-05 05:04:16 -04:00
|
|
|
//select_button ().set_blinking (false);
|
|
|
|
|
2017-06-30 13:55:03 -04:00
|
|
|
_stripable_name = s->name ();
|
|
|
|
|
|
|
|
if (_base.twolinetext ()) {
|
2017-07-01 19:57:21 -04:00
|
|
|
set_strip_name ();
|
|
|
|
} else {
|
2017-06-30 13:55:03 -04:00
|
|
|
set_text_line (0, s->name ());
|
|
|
|
set_text_line (1, _pan_ctrl ? _pan_ctrl->get_user_string () : "");
|
|
|
|
}
|
|
|
|
set_text_line (2, "");
|
|
|
|
set_text_line (3, "");
|
2017-04-05 05:04:16 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* *****************************************************************************
|
|
|
|
* Parse Strip Specifig MIDI Events
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool
|
|
|
|
FP8Strip::midi_touch (bool t)
|
|
|
|
{
|
|
|
|
_touching = t;
|
|
|
|
boost::shared_ptr<AutomationControl> ac = _fader_ctrl;
|
|
|
|
if (!ac) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (t) {
|
2017-09-18 12:39:17 -04:00
|
|
|
ac->start_touch (ac->session().transport_sample());
|
2017-04-05 05:04:16 -04:00
|
|
|
} else {
|
2017-09-18 12:39:17 -04:00
|
|
|
ac->stop_touch (ac->session().transport_sample());
|
2017-04-05 05:04:16 -04:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
FP8Strip::midi_fader (float val)
|
|
|
|
{
|
|
|
|
assert (val >= 0.f && val <= 1.f);
|
|
|
|
if (!_touching) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
boost::shared_ptr<AutomationControl> ac = _fader_ctrl;
|
|
|
|
if (!ac) {
|
|
|
|
return false;
|
|
|
|
}
|
2017-09-18 12:39:17 -04:00
|
|
|
ac->start_touch (ac->session().transport_sample());
|
2017-04-14 07:57:14 -04:00
|
|
|
ac->set_value (ac->interface_to_internal (val), group_mode ());
|
2017-04-05 05:04:16 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* *****************************************************************************
|
|
|
|
* Actions from Controller, Update Model
|
|
|
|
*/
|
|
|
|
|
2017-04-14 07:57:14 -04:00
|
|
|
PBD::Controllable::GroupControlDisposition
|
|
|
|
FP8Strip::group_mode () const
|
|
|
|
{
|
|
|
|
if (_base.shift_mod ()) {
|
|
|
|
return PBD::Controllable::InverseGroup;
|
|
|
|
} else {
|
|
|
|
return PBD::Controllable::UseGroup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-05 05:04:16 -04:00
|
|
|
void
|
|
|
|
FP8Strip::set_mute (bool on)
|
|
|
|
{
|
2017-04-20 11:19:03 -04:00
|
|
|
if (!_mute_ctrl) {
|
|
|
|
return;
|
2017-04-05 05:04:16 -04:00
|
|
|
}
|
2017-09-18 12:39:17 -04:00
|
|
|
_mute_ctrl->start_touch (_mute_ctrl->session().transport_sample());
|
2017-04-20 11:19:03 -04:00
|
|
|
_mute_ctrl->set_value (on ? 1.0 : 0.0, group_mode ());
|
2017-04-05 05:04:16 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FP8Strip::set_solo (bool on)
|
|
|
|
{
|
2017-04-20 11:19:03 -04:00
|
|
|
if (!_solo_ctrl) {
|
|
|
|
return;
|
|
|
|
}
|
2017-09-18 12:39:17 -04:00
|
|
|
_solo_ctrl->start_touch (_solo_ctrl->session().transport_sample());
|
2020-10-18 09:28:10 -04:00
|
|
|
PBD::Controllable::GroupControlDisposition gcd = group_mode ();
|
|
|
|
Session& s = const_cast<Session&> (_solo_ctrl->session());
|
|
|
|
s.set_control (_solo_ctrl, on ? 1.0 : 0.0, gcd);
|
2017-04-05 05:04:16 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FP8Strip::set_recarm ()
|
|
|
|
{
|
2017-04-20 11:19:03 -04:00
|
|
|
if (!_rec_ctrl) {
|
|
|
|
return;
|
2017-04-05 05:04:16 -04:00
|
|
|
}
|
2017-04-20 11:19:03 -04:00
|
|
|
const bool on = !recarm_button ().is_active();
|
|
|
|
_rec_ctrl->set_value (on ? 1.0 : 0.0, group_mode ());
|
2017-04-05 05:04:16 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FP8Strip::set_select ()
|
|
|
|
{
|
|
|
|
if (!_select_plugin_functor.empty ()) {
|
2017-04-14 16:46:41 -04:00
|
|
|
assert (!_x_select_ctrl);
|
2017-04-05 05:04:16 -04:00
|
|
|
_select_plugin_functor ();
|
2017-04-14 16:46:41 -04:00
|
|
|
} else if (_x_select_ctrl) {
|
2017-09-18 12:39:17 -04:00
|
|
|
_x_select_ctrl->start_touch (_x_select_ctrl->session().transport_sample());
|
2017-04-14 16:46:41 -04:00
|
|
|
const bool on = !select_button ().is_active();
|
|
|
|
_x_select_ctrl->set_value (on ? 1.0 : 0.0, group_mode ());
|
2017-04-05 05:04:16 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* *****************************************************************************
|
|
|
|
* Callbacks from Stripable, Update View
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
FP8Strip::notify_fader_changed ()
|
|
|
|
{
|
|
|
|
boost::shared_ptr<AutomationControl> ac = _fader_ctrl;
|
|
|
|
if (_touching) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
float val = 0;
|
|
|
|
if (ac) {
|
2017-04-17 14:06:00 -04:00
|
|
|
val = ac->internal_to_interface (ac->get_value());
|
|
|
|
val = std::max (0.f, std::min (1.f, val)) * 16368.f; /* 16 * 1023 */
|
2017-04-05 05:04:16 -04:00
|
|
|
}
|
|
|
|
unsigned short mv = lrintf (val);
|
|
|
|
if (mv == _last_fader) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
_last_fader = mv;
|
2017-10-19 10:57:12 -04:00
|
|
|
_base.tx_midi3 (midi_ctrl_id (Fader, _id), (mv & 0x7f), (mv >> 7) & 0x7f);
|
2017-04-05 05:04:16 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FP8Strip::notify_solo_changed ()
|
|
|
|
{
|
|
|
|
if (_solo_ctrl) {
|
2017-07-18 19:52:14 -04:00
|
|
|
boost::shared_ptr<SoloControl> sc = boost::dynamic_pointer_cast<SoloControl> (_solo_ctrl);
|
|
|
|
if (sc) {
|
|
|
|
_solo.set_blinking (sc->soloed_by_others () && !sc->self_soloed ());
|
|
|
|
_solo.set_active (sc->self_soloed ());
|
|
|
|
} else {
|
|
|
|
_solo.set_blinking (false);
|
|
|
|
_solo.set_active (_solo_ctrl->get_value () > 0);
|
|
|
|
}
|
2017-04-05 05:04:16 -04:00
|
|
|
} else {
|
2017-07-18 19:52:14 -04:00
|
|
|
_solo.set_blinking (false);
|
2017-04-05 05:04:16 -04:00
|
|
|
_solo.set_active (false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FP8Strip::notify_mute_changed ()
|
|
|
|
{
|
|
|
|
if (_mute_ctrl) {
|
|
|
|
_mute.set_active (_mute_ctrl->get_value () > 0);
|
|
|
|
} else {
|
|
|
|
_mute.set_active (false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FP8Strip::notify_rec_changed ()
|
|
|
|
{
|
|
|
|
if (_rec_ctrl) {
|
|
|
|
recarm_button ().set_active (_rec_ctrl->get_value() > 0.);
|
|
|
|
} else {
|
|
|
|
recarm_button ().set_active (false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FP8Strip::notify_pan_changed ()
|
|
|
|
{
|
2017-04-14 16:46:41 -04:00
|
|
|
// display only
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FP8Strip::notify_x_select_changed ()
|
|
|
|
{
|
|
|
|
if (!_select_plugin_functor.empty ()) {
|
|
|
|
assert (!_x_select_ctrl);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_x_select_ctrl) {
|
|
|
|
assert (_select_plugin_functor.empty ());
|
|
|
|
select_button ().set_active (_x_select_ctrl->get_value() > 0.);
|
|
|
|
select_button ().set_color (0xffff00ff);
|
|
|
|
select_button ().set_blinking (false);
|
|
|
|
}
|
2017-04-05 05:04:16 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* *****************************************************************************
|
|
|
|
* Periodic View Updates
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
FP8Strip::periodic_update_fader ()
|
|
|
|
{
|
|
|
|
boost::shared_ptr<AutomationControl> ac = _fader_ctrl;
|
|
|
|
if (!ac || _touching) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-06-13 10:07:20 -04:00
|
|
|
if (!ac->automation_playback ()) {
|
|
|
|
return;
|
2017-04-05 05:04:16 -04:00
|
|
|
}
|
2017-06-13 10:07:20 -04:00
|
|
|
notify_fader_changed ();
|
2017-04-05 05:04:16 -04:00
|
|
|
}
|
|
|
|
|
2017-04-14 07:57:14 -04:00
|
|
|
void
|
|
|
|
FP8Strip::set_periodic_display_mode (DisplayMode m) {
|
|
|
|
_displaymode = m;
|
2017-04-14 16:57:31 -04:00
|
|
|
if (_displaymode == SendDisplay || _displaymode == PluginParam) {
|
2017-04-14 07:57:14 -04:00
|
|
|
// need to change to 4 lines before calling set_text()
|
|
|
|
set_strip_mode (2); // 4 lines of small text
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-05 05:04:16 -04:00
|
|
|
void
|
|
|
|
FP8Strip::periodic_update_meter ()
|
|
|
|
{
|
2017-06-30 13:55:03 -04:00
|
|
|
bool show_meters = _base.show_meters ();
|
2017-04-05 05:04:16 -04:00
|
|
|
bool have_meter = false;
|
|
|
|
bool have_panner = false;
|
|
|
|
|
2017-06-30 13:55:03 -04:00
|
|
|
if (_peak_meter && show_meters) {
|
2017-04-05 05:04:16 -04:00
|
|
|
have_meter = true;
|
|
|
|
float dB = _peak_meter->meter_level (0, MeterMCP);
|
|
|
|
// TODO: deflect meter
|
|
|
|
int val = std::min (127.f, std::max (0.f, 2.f * dB + 127.f));
|
|
|
|
if (val != _last_meter || val > 0) {
|
2017-10-19 10:57:12 -04:00
|
|
|
_base.tx_midi2 (midi_ctrl_id (Meter, _id), val & 0x7f); // falls off automatically
|
2017-04-05 05:04:16 -04:00
|
|
|
_last_meter = val;
|
|
|
|
}
|
|
|
|
|
2017-06-30 13:55:03 -04:00
|
|
|
} else if (show_meters) {
|
2017-04-05 05:04:16 -04:00
|
|
|
if (0 != _last_meter) {
|
2017-10-19 10:57:12 -04:00
|
|
|
_base.tx_midi2 (midi_ctrl_id (Meter, _id), 0);
|
2017-04-05 05:04:16 -04:00
|
|
|
_last_meter = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// show redux only if there's a meter, too (strip display mode 5)
|
2017-06-30 13:55:03 -04:00
|
|
|
if (_peak_meter && _redux_ctrl && show_meters) {
|
2017-04-05 05:04:16 -04:00
|
|
|
float rx = (1.f - _redux_ctrl->get_parameter ()) * 127.f;
|
|
|
|
// TODO: deflect redux
|
|
|
|
int val = std::min (127.f, std::max (0.f, rx));
|
|
|
|
if (val != _last_redux) {
|
2017-10-19 10:57:12 -04:00
|
|
|
_base.tx_midi2 (midi_ctrl_id (Redux, _id), val & 0x7f);
|
2017-04-05 05:04:16 -04:00
|
|
|
_last_redux = val;
|
|
|
|
}
|
2017-06-30 13:55:03 -04:00
|
|
|
} else if (show_meters) {
|
2017-04-05 05:04:16 -04:00
|
|
|
if (0 != _last_redux) {
|
2017-10-19 10:57:12 -04:00
|
|
|
_base.tx_midi2 (midi_ctrl_id (Redux, _id), 0);
|
2017-04-05 05:04:16 -04:00
|
|
|
_last_redux = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_displaymode == PluginParam) {
|
2017-04-14 07:57:14 -04:00
|
|
|
if (_fader_ctrl) {
|
|
|
|
set_bar_mode (2); // Fill
|
2017-06-29 19:59:12 -04:00
|
|
|
set_text_line (2, value_as_string(_fader_ctrl->desc(), _fader_ctrl->get_value()));
|
2017-04-14 07:57:14 -04:00
|
|
|
float barpos = _fader_ctrl->internal_to_interface (_fader_ctrl->get_value());
|
|
|
|
int val = std::min (127.f, std::max (0.f, barpos * 128.f));
|
|
|
|
if (val != _last_barpos) {
|
2017-10-19 10:57:12 -04:00
|
|
|
_base.tx_midi3 (0xb0, midi_ctrl_id (BarVal, _id), val & 0x7f);
|
2017-04-14 07:57:14 -04:00
|
|
|
_last_barpos = val;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
set_bar_mode (4); // Off
|
2017-06-30 13:55:03 -04:00
|
|
|
set_text_line (2, "");
|
2017-04-14 07:57:14 -04:00
|
|
|
}
|
|
|
|
}
|
2017-07-01 19:57:21 -04:00
|
|
|
else if (_displaymode == PluginSelect) {
|
|
|
|
set_bar_mode (4); // Off
|
|
|
|
}
|
2017-04-14 07:57:14 -04:00
|
|
|
else if (_displaymode == SendDisplay) {
|
2017-04-05 05:04:16 -04:00
|
|
|
set_bar_mode (4); // Off
|
|
|
|
if (_fader_ctrl) {
|
2017-06-30 13:55:03 -04:00
|
|
|
set_text_line (1, value_as_string(_fader_ctrl->desc(), _fader_ctrl->get_value()));
|
2017-04-05 05:04:16 -04:00
|
|
|
} else {
|
2017-06-30 13:55:03 -04:00
|
|
|
set_text_line (1, "");
|
2017-04-05 05:04:16 -04:00
|
|
|
}
|
|
|
|
} else if (_pan_ctrl) {
|
2017-06-30 13:55:03 -04:00
|
|
|
have_panner = _base.show_panner ();
|
2020-02-12 21:13:30 -05:00
|
|
|
float panpos = _pan_ctrl->internal_to_interface (_pan_ctrl->get_value(), true);
|
2017-04-05 05:04:16 -04:00
|
|
|
int val = std::min (127.f, std::max (0.f, panpos * 128.f));
|
2017-06-30 13:55:03 -04:00
|
|
|
set_bar_mode (have_panner ? 1 : 4); // Bipolar or Off
|
|
|
|
if (val != _last_barpos && have_panner) {
|
2017-10-19 10:57:12 -04:00
|
|
|
_base.tx_midi3 (0xb0, midi_ctrl_id (BarVal, _id), val & 0x7f);
|
2017-04-14 07:57:14 -04:00
|
|
|
_last_barpos = val;
|
2017-04-05 05:04:16 -04:00
|
|
|
}
|
2017-06-30 13:55:03 -04:00
|
|
|
if (_base.twolinetext ()) {
|
|
|
|
set_strip_name ();
|
2017-07-01 19:57:21 -04:00
|
|
|
} else {
|
|
|
|
set_text_line (1, _pan_ctrl->get_user_string ());
|
2017-06-30 13:55:03 -04:00
|
|
|
}
|
2017-04-05 05:04:16 -04:00
|
|
|
} else {
|
|
|
|
set_bar_mode (4); // Off
|
2017-06-30 13:55:03 -04:00
|
|
|
if (_base.twolinetext ()) {
|
|
|
|
set_strip_name ();
|
2017-07-01 19:57:21 -04:00
|
|
|
} else {
|
|
|
|
set_text_line (1, "");
|
2017-06-30 13:55:03 -04:00
|
|
|
}
|
2017-04-05 05:04:16 -04:00
|
|
|
}
|
|
|
|
|
2017-04-14 16:57:31 -04:00
|
|
|
if (_displaymode == SendDisplay || _displaymode == PluginParam) {
|
2017-04-14 07:57:14 -04:00
|
|
|
set_strip_mode (2); // 4 lines of small text + value-bar
|
|
|
|
}
|
|
|
|
else if (have_meter && have_panner) {
|
|
|
|
set_strip_mode (5); // small meters + 3 lines of text (3rd is large) + value-bar
|
2017-04-05 05:04:16 -04:00
|
|
|
}
|
|
|
|
else if (have_meter) {
|
2017-12-20 19:52:36 -05:00
|
|
|
/* we cannot use "big meters" mode 4, since that implies
|
|
|
|
* 2 "Large" (4char) text lines, followed by a HUGE 2 char line
|
|
|
|
* and hides timecode-clock */
|
|
|
|
set_strip_mode (5);
|
2017-04-05 05:04:16 -04:00
|
|
|
}
|
|
|
|
else if (have_panner) {
|
2017-06-30 13:55:03 -04:00
|
|
|
set_strip_mode (0); // 3 lines of text (3rd line is large + long) + value-bar
|
2017-04-05 05:04:16 -04:00
|
|
|
} else {
|
2017-06-30 13:55:03 -04:00
|
|
|
set_strip_mode (0); // 3 lines of text (3rd line is large + long) + value-bar
|
2017-04-05 05:04:16 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FP8Strip::set_strip_mode (uint8_t strip_mode, bool clear)
|
|
|
|
{
|
|
|
|
if (strip_mode == _strip_mode && !clear) {
|
|
|
|
return;
|
|
|
|
}
|
2017-06-30 13:55:03 -04:00
|
|
|
|
2017-04-05 05:04:16 -04:00
|
|
|
_strip_mode = strip_mode;
|
|
|
|
_base.tx_sysex (3, 0x13, _id, (_strip_mode & 0x07) | (clear ? 0x10 : 0));
|
2017-06-30 13:55:03 -04:00
|
|
|
|
|
|
|
if (clear) {
|
|
|
|
/* work-around, when swiching modes, the FP8 may not
|
|
|
|
* properly redraw long lines. Only update lines 0, 1
|
|
|
|
* (line 2 is timecode, line 3 may be inverted)
|
|
|
|
*/
|
|
|
|
_base.tx_text (_id, 0, 0x00, _last_line[0]);
|
|
|
|
_base.tx_text (_id, 1, 0x00, _last_line[1]);
|
|
|
|
}
|
2017-04-05 05:04:16 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-06-30 13:55:03 -04:00
|
|
|
FP8Strip::set_bar_mode (uint8_t bar_mode, bool force)
|
2017-04-05 05:04:16 -04:00
|
|
|
{
|
2017-06-30 13:55:03 -04:00
|
|
|
if (bar_mode == _bar_mode && !force) {
|
2017-04-05 05:04:16 -04:00
|
|
|
return;
|
|
|
|
}
|
2017-06-30 13:55:03 -04:00
|
|
|
|
|
|
|
if (bar_mode == 4) {
|
2017-10-19 10:57:12 -04:00
|
|
|
_base.tx_midi3 (0xb0, midi_ctrl_id (BarVal, _id), 0);
|
2017-06-30 13:55:03 -04:00
|
|
|
_last_barpos = 0xff;
|
|
|
|
}
|
|
|
|
|
2017-04-05 05:04:16 -04:00
|
|
|
_bar_mode = bar_mode;
|
2017-10-19 10:57:12 -04:00
|
|
|
_base.tx_midi3 (0xb0, midi_ctrl_id (BarMode, _id), bar_mode);
|
2017-04-05 05:04:16 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-04-14 07:57:14 -04:00
|
|
|
FP8Strip::set_text_line (uint8_t line, std::string const& txt, bool inv)
|
2017-04-05 05:04:16 -04:00
|
|
|
{
|
|
|
|
assert (line < 4);
|
|
|
|
if (_last_line[line] == txt) {
|
|
|
|
return;
|
|
|
|
}
|
2017-04-14 07:57:14 -04:00
|
|
|
_base.tx_text (_id, line, inv ? 0x04 : 0x00, txt);
|
2017-04-05 05:04:16 -04:00
|
|
|
_last_line[line] = txt;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-06-30 13:55:03 -04:00
|
|
|
FP8Strip::periodic_update_timecode (uint32_t m)
|
2017-04-05 05:04:16 -04:00
|
|
|
{
|
2017-06-30 13:55:03 -04:00
|
|
|
if (m == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (m == 3) {
|
|
|
|
bool mc = _id >= 4;
|
|
|
|
std::string const& tc = mc ? _base.musical_time () : _base.timecode();
|
|
|
|
std::string t;
|
|
|
|
if (tc.size () == 12) {
|
|
|
|
t = tc.substr (1 + (_id - (mc ? 4 : 0)) * 3, 2);
|
|
|
|
}
|
|
|
|
set_text_line (2, t);
|
|
|
|
} else if (_id >= 2 && _id < 6) {
|
|
|
|
std::string const& tc = (m == 2) ? _base.musical_time () : _base.timecode();
|
|
|
|
//" HH:MM:SS:FF" or " BR|BT|TI|CK"
|
2017-04-05 05:04:16 -04:00
|
|
|
std::string t;
|
|
|
|
if (tc.size () == 12) {
|
|
|
|
t = tc.substr (1 + (_id - 2) * 3, 2);
|
|
|
|
}
|
2017-06-30 13:55:03 -04:00
|
|
|
set_text_line (2, t);
|
|
|
|
} else {
|
|
|
|
set_text_line (2, "");
|
2017-04-05 05:04:16 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FP8Strip::periodic ()
|
|
|
|
{
|
|
|
|
periodic_update_fader ();
|
2018-07-31 08:46:20 -04:00
|
|
|
#ifndef FADERPORT2
|
2017-04-05 05:04:16 -04:00
|
|
|
periodic_update_meter ();
|
2017-06-29 19:59:12 -04:00
|
|
|
if (_displaymode != PluginSelect && _displaymode != PluginParam) {
|
2017-06-30 13:55:03 -04:00
|
|
|
periodic_update_timecode (_base.clock_mode ());
|
2017-04-05 05:04:16 -04:00
|
|
|
}
|
2018-07-31 08:46:20 -04:00
|
|
|
#endif
|
2017-04-05 05:04:16 -04:00
|
|
|
}
|