1 /* Faderport 8 Control Surface
2 * This is the button "View" of the MVC surface inteface,
3 * see actions.cc for the "Controller"
5 * Copyright (C) 2017 Robin Gareus <robin@gareus.org>
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 #include "ardour/plugin_insert.h"
23 #include "ardour/session.h"
24 #include "ardour/session_configuration.h"
26 #include "gtkmm2ext/actions.h"
28 #include "faderport8.h"
32 using namespace ARDOUR;
33 using namespace ArdourSurface;
34 using namespace ArdourSurface::FP8Types;
37 FaderPort8::connect_session_signals ()
39 session->RouteAdded.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort8::notify_stripable_added_or_removed, this), this);
40 PresentationInfo::Change.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort8::notify_pi_property_changed, this, _1), this);
42 Config->ParameterChanged.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort8::notify_parameter_changed, this, _1), this);
43 session->config.ParameterChanged.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort8::notify_parameter_changed, this, _1), this);
45 session->TransportStateChange.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort8::notify_transport_state_changed, this), this);
46 session->TransportLooped.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort8::notify_loop_state_changed, this), this);
47 session->RecordStateChanged.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort8::notify_record_state_changed, this), this);
49 session->DirtyChanged.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort8::notify_session_dirty_changed, this), this);
50 session->SoloChanged.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort8::notify_solo_changed, this), this);
51 session->MuteChanged.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort8::notify_mute_changed, this), this);
52 session->history().Changed.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort8::notify_history_changed, this), this);
56 FaderPort8::send_session_state ()
58 notify_transport_state_changed ();
59 notify_record_state_changed ();
60 notify_session_dirty_changed ();
61 notify_history_changed ();
62 notify_solo_changed ();
63 notify_mute_changed ();
64 notify_parameter_changed ("clicking");
66 notify_automation_mode_changed (); // XXX (stip specific, see below)
69 // TODO: AutomationState display of plugin & send automation
70 // TODO: link/lock control AS.
72 FaderPort8::notify_automation_mode_changed ()
74 boost::shared_ptr<Stripable> s = first_selected_stripable();
75 boost::shared_ptr<AutomationControl> ac;
77 switch (_ctrls.fader_mode ()) {
79 ac = s->gain_control();
82 ac = s->pan_azimuth_control();
89 _ctrls.button (FP8Controls::BtnALatch).set_active (false);
90 _ctrls.button (FP8Controls::BtnATrim).set_active (false);
91 _ctrls.button (FP8Controls::BtnAOff).set_active (false);
92 _ctrls.button (FP8Controls::BtnATouch).set_active (false);
93 _ctrls.button (FP8Controls::BtnARead).set_active (false);
94 _ctrls.button (FP8Controls::BtnAWrite).set_active (false);
98 ARDOUR::AutoState as = ac->automation_state();
99 _ctrls.button (FP8Controls::BtnAOff).set_active (as == Off);
100 _ctrls.button (FP8Controls::BtnATouch).set_active (as == Touch);
101 _ctrls.button (FP8Controls::BtnARead).set_active (as == Play);
102 _ctrls.button (FP8Controls::BtnAWrite).set_active (as == Write);
103 _ctrls.button (FP8Controls::BtnALatch).set_active (as == Latch);
107 FaderPort8::notify_parameter_changed (std::string param)
109 if (param == "clicking") {
110 _ctrls.button (FP8Controls::BtnClick).set_active (Config->get_clicking ());
115 FaderPort8::notify_transport_state_changed ()
117 if (session->transport_rolling ()) {
118 _ctrls.button (FP8Controls::BtnPlay).set_active (true);
119 _ctrls.button (FP8Controls::BtnStop).set_active (false);
121 _ctrls.button (FP8Controls::BtnPlay).set_active (false);
122 _ctrls.button (FP8Controls::BtnStop).set_active (true);
125 /* set rewind/fastforward lights */
126 const float ts = session->transport_speed ();
127 FP8ButtonInterface& b_rew = _ctrls.button (FP8Controls::BtnRewind);
128 FP8ButtonInterface& b_ffw = _ctrls.button (FP8Controls::BtnFastForward);
130 const bool rew = (ts < 0.f);
131 const bool ffw = (ts > 0.f && ts != 1.f);
132 if (b_rew.is_active() != rew) {
133 b_rew.set_active (rew);
135 if (b_ffw.is_active() != ffw) {
136 b_ffw.set_active (ffw);
139 notify_loop_state_changed ();
143 FaderPort8::notify_record_state_changed ()
145 switch (session->record_status ()) {
146 case Session::Disabled:
147 _ctrls.button (FP8Controls::BtnRecord).set_active (0);
148 _ctrls.button (FP8Controls::BtnRecord).set_blinking (false);
150 case Session::Enabled:
151 _ctrls.button (FP8Controls::BtnRecord).set_active (true);
152 _ctrls.button (FP8Controls::BtnRecord).set_blinking (true);
154 case Session::Recording:
155 _ctrls.button (FP8Controls::BtnRecord).set_active (true);
156 _ctrls.button (FP8Controls::BtnRecord).set_blinking (false);
162 FaderPort8::notify_loop_state_changed ()
164 bool looping = false;
165 Location* looploc = session->locations ()->auto_loop_location ();
166 if (looploc && session->get_play_loop ()) {
169 _ctrls.button (FP8Controls::BtnLoop).set_active (looping);
173 FaderPort8::notify_session_dirty_changed ()
175 const bool is_dirty = session->dirty ();
176 _ctrls.button (FP8Controls::BtnSave).set_active (is_dirty);
177 _ctrls.button (FP8Controls::BtnSave).set_color (is_dirty ? 0xff0000ff : 0x00ff00ff);
181 FaderPort8::notify_history_changed ()
183 _ctrls.button (FP8Controls::BtnRedo).set_active (session->redo_depth() > 0);
184 _ctrls.button (FP8Controls::BtnUndo).set_active (session->undo_depth() > 0);
188 FaderPort8::notify_solo_changed ()
190 bool soloing = session->soloing() || session->listening();
192 soloing |= session->mixbus_soloed();
194 _ctrls.button (FP8Controls::BtnSoloClear).set_active (soloing);
195 #ifdef FP8_MUTESOLO_UNDO
197 _solo_state.clear ();
203 FaderPort8::notify_mute_changed ()
205 bool muted = session->muted ();
206 #ifdef FP8_MUTESOLO_UNDO
208 _mute_state.clear ();
211 _ctrls.button (FP8Controls::BtnMuteClear).set_active (muted);
215 FaderPort8::notify_plugin_active_changed ()
217 boost::shared_ptr<PluginInsert> pi = _plugin_insert.lock();
219 _ctrls.button (FP8Controls::BtnBypass).set_active (true);
220 _ctrls.button (FP8Controls::BtnBypass).set_color (pi->enabled () ? 0x00ff00ff : 0xff0000ff);
222 _ctrls.button (FP8Controls::BtnBypass).set_active (false);
223 _ctrls.button (FP8Controls::BtnBypass).set_color (0x888888ff);
228 FaderPort8::nofity_focus_control (boost::weak_ptr<PBD::Controllable> c)
230 assert (_link_enabled && !_link_locked);
231 // TODO consider subscribing to c's DropReferences
232 // (in case the control goes away while it has focus, update the BtnColor)
234 if (c.expired () || 0 == boost::dynamic_pointer_cast<AutomationControl> (_link_control.lock ())) {
235 _ctrls.button (FP8Controls::BtnLink).set_color (0xff8800ff);
236 _ctrls.button (FP8Controls::BtnLock).set_color (0xff0000ff);
238 _ctrls.button (FP8Controls::BtnLink).set_color (0x88ff00ff);
239 _ctrls.button (FP8Controls::BtnLock).set_color (0x00ff88ff);