2019-08-03 08:34:29 -04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2017-2018 Robin Gareus <robin@gareus.org>
|
|
|
|
* Copyright (C) 2018 Ben Loftis <ben@harrisonconsoles.com>
|
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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Faderport 8 Control Surface
|
|
|
|
* This is the button "Controller" of the MVC surface inteface,
|
|
|
|
* see callbacks.cc for the "View".
|
2017-04-05 05:04:16 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ardour/dB.h"
|
2017-06-29 19:59:12 -04:00
|
|
|
#include "ardour/plugin_insert.h"
|
2017-04-05 05:04:16 -04:00
|
|
|
#include "ardour/session.h"
|
|
|
|
#include "ardour/session_configuration.h"
|
2018-07-31 08:46:20 -04:00
|
|
|
#include "ardour/track.h"
|
2017-04-05 05:04:16 -04:00
|
|
|
#include "ardour/types.h"
|
|
|
|
|
|
|
|
#include "gtkmm2ext/actions.h"
|
|
|
|
|
|
|
|
#include "faderport8.h"
|
|
|
|
|
|
|
|
#include "pbd/i18n.h"
|
|
|
|
|
|
|
|
using namespace std;
|
2017-12-12 08:09:40 -05:00
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace ArdourSurface::FP_NAMESPACE;
|
|
|
|
using namespace ArdourSurface::FP_NAMESPACE::FP8Types;
|
2017-04-05 05:04:16 -04:00
|
|
|
|
|
|
|
#define BindMethod(ID, CB) \
|
|
|
|
_ctrls.button (FP8Controls::ID).released.connect_same_thread (button_connections, boost::bind (&FaderPort8:: CB, this));
|
|
|
|
|
2018-07-31 08:46:20 -04:00
|
|
|
#define BindMethod2(ID, ACT, CB) \
|
|
|
|
_ctrls.button (FP8Controls::ID). ACT .connect_same_thread (button_connections, boost::bind (&FaderPort8:: CB, this));
|
|
|
|
|
2017-04-05 05:04:16 -04:00
|
|
|
#define BindFunction(ID, ACT, CB, ...) \
|
|
|
|
_ctrls.button (FP8Controls::ID). ACT .connect_same_thread (button_connections, boost::bind (&FaderPort8:: CB, this, __VA_ARGS__));
|
|
|
|
|
|
|
|
#define BindAction(ID, GRP, ITEM) \
|
|
|
|
_ctrls.button (FP8Controls::ID).released.connect_same_thread (button_connections, boost::bind (&FaderPort8::button_action, this, GRP, ITEM));
|
|
|
|
|
|
|
|
#define BindUserAction(ID) \
|
|
|
|
_ctrls.button (ID).pressed.connect_same_thread (button_connections, boost::bind (&FaderPort8::button_user, this, true, ID)); \
|
|
|
|
_ctrls.button (ID).released.connect_same_thread (button_connections, boost::bind (&FaderPort8::button_user, this, false, ID));
|
|
|
|
|
2017-04-20 11:19:03 -04:00
|
|
|
|
|
|
|
/* Bind button signals (press, release) to callback methods
|
|
|
|
* (called once after constructing buttons).
|
|
|
|
* Bound actions are handled the the ctrl-surface thread.
|
|
|
|
*/
|
2017-04-05 05:04:16 -04:00
|
|
|
void
|
|
|
|
FaderPort8::setup_actions ()
|
|
|
|
{
|
2018-07-31 08:46:20 -04:00
|
|
|
BindMethod2 (BtnPlay, pressed, button_play);
|
|
|
|
BindMethod2 (BtnStop, pressed, button_stop);
|
|
|
|
BindMethod2 (BtnLoop, pressed, button_loop);
|
|
|
|
BindMethod2 (BtnRecord, pressed, button_record);
|
|
|
|
BindMethod2 (BtnClick, pressed, button_metronom);
|
2017-04-05 05:04:16 -04:00
|
|
|
BindAction (BtnRedo, "Editor", "redo");
|
|
|
|
|
|
|
|
BindAction (BtnSave, "Common", "Save");
|
|
|
|
BindAction (BtnUndo, "Editor", "undo");
|
|
|
|
BindAction (BtnRedo, "Editor", "redo");
|
|
|
|
|
2017-05-05 09:26:52 -04:00
|
|
|
#ifdef FP8_MUTESOLO_UNDO
|
|
|
|
BindMethod (BtnSoloClear, button_solo_clear);
|
|
|
|
#else
|
2017-04-05 05:04:16 -04:00
|
|
|
BindAction (BtnSoloClear, "Main", "cancel-solo");
|
2017-05-05 09:26:52 -04:00
|
|
|
#endif
|
2017-04-05 05:04:16 -04:00
|
|
|
BindMethod (BtnMuteClear, button_mute_clear);
|
|
|
|
|
|
|
|
BindMethod (FP8Controls::BtnArmAll, button_arm_all);
|
|
|
|
|
|
|
|
BindFunction (BtnRewind, pressed, button_varispeed, false);
|
|
|
|
BindFunction (BtnFastForward, pressed, button_varispeed, true);
|
|
|
|
|
|
|
|
BindFunction (BtnPrev, released, button_prev_next, false);
|
|
|
|
BindFunction (BtnNext, released, button_prev_next, true);
|
|
|
|
|
|
|
|
BindFunction (BtnArm, pressed, button_arm, true);
|
|
|
|
BindFunction (BtnArm, released, button_arm, false);
|
|
|
|
|
|
|
|
BindFunction (BtnAOff, released, button_automation, ARDOUR::Off);
|
|
|
|
BindFunction (BtnATouch, released, button_automation, ARDOUR::Touch);
|
|
|
|
BindFunction (BtnARead, released, button_automation, ARDOUR::Play);
|
|
|
|
BindFunction (BtnAWrite, released, button_automation, ARDOUR::Write);
|
2017-07-25 10:30:00 -04:00
|
|
|
BindFunction (BtnALatch, released, button_automation, ARDOUR::Latch);
|
2017-04-05 05:04:16 -04:00
|
|
|
|
|
|
|
_ctrls.button (FP8Controls::BtnEncoder).pressed.connect_same_thread (button_connections, boost::bind (&FaderPort8::button_encoder, this));
|
2018-07-31 08:46:20 -04:00
|
|
|
#ifdef FADERPORT2
|
|
|
|
_ctrls.button (FP8Controls::BtnParam).pressed.connect_same_thread (button_connections, boost::bind (&FaderPort8::button_encoder, this));
|
|
|
|
#else
|
2017-04-05 05:04:16 -04:00
|
|
|
_ctrls.button (FP8Controls::BtnParam).pressed.connect_same_thread (button_connections, boost::bind (&FaderPort8::button_parameter, this));
|
2018-07-31 08:46:20 -04:00
|
|
|
#endif
|
2017-04-05 05:04:16 -04:00
|
|
|
|
|
|
|
|
2017-06-29 19:59:12 -04:00
|
|
|
BindMethod (BtnBypass, button_bypass);
|
2017-07-01 20:06:48 -04:00
|
|
|
BindAction (BtnBypassAll, "Mixer", "ab-plugins");
|
2017-04-05 05:04:16 -04:00
|
|
|
|
2017-07-02 19:42:36 -04:00
|
|
|
BindAction (BtnMacro, "Common", "toggle-editor-and-mixer");
|
2017-07-01 20:06:48 -04:00
|
|
|
BindMethod (BtnOpen, button_open);
|
2017-07-02 12:16:54 -04:00
|
|
|
|
|
|
|
BindMethod (BtnLink, button_link);
|
|
|
|
BindMethod (BtnLock, button_lock);
|
2017-04-05 05:04:16 -04:00
|
|
|
|
2018-07-31 09:23:49 -04:00
|
|
|
#ifdef FADERPORT2
|
|
|
|
BindMethod (BtnChanLock, button_chanlock);
|
|
|
|
BindMethod (BtnFlip, button_flip);
|
|
|
|
#endif
|
2018-07-31 08:46:20 -04:00
|
|
|
|
2017-04-05 05:04:16 -04:00
|
|
|
// user-specific
|
|
|
|
for (FP8Controls::UserButtonMap::const_iterator i = _ctrls.user_buttons ().begin ();
|
|
|
|
i != _ctrls.user_buttons ().end (); ++i) {
|
|
|
|
BindUserAction ((*i).first);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-20 11:19:03 -04:00
|
|
|
/* ****************************************************************************
|
|
|
|
* Direct control callback Actions
|
|
|
|
*/
|
|
|
|
|
2017-04-05 05:04:16 -04:00
|
|
|
void
|
|
|
|
FaderPort8::button_play ()
|
|
|
|
{
|
2020-02-23 09:49:40 -05:00
|
|
|
if (transport_rolling ()) {
|
|
|
|
if (get_transport_speed() != 1.0) {
|
2021-04-17 15:29:00 -04:00
|
|
|
session->request_roll (TRS_UI);
|
2017-04-05 05:04:16 -04:00
|
|
|
} else {
|
|
|
|
transport_stop ();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
transport_play ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FaderPort8::button_stop ()
|
|
|
|
{
|
2020-02-23 09:49:40 -05:00
|
|
|
if (transport_rolling ()) {
|
2017-04-15 15:20:51 -04:00
|
|
|
transport_stop ();
|
|
|
|
} else {
|
|
|
|
AccessAction ("Transport", "GotoStart");
|
|
|
|
}
|
2017-04-05 05:04:16 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FaderPort8::button_record ()
|
|
|
|
{
|
|
|
|
set_record_enable (!get_record_enabled ());
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FaderPort8::button_loop ()
|
|
|
|
{
|
|
|
|
loop_toggle ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FaderPort8::button_metronom ()
|
|
|
|
{
|
|
|
|
Config->set_clicking (!Config->get_clicking ());
|
|
|
|
}
|
|
|
|
|
2017-06-29 19:59:12 -04:00
|
|
|
void
|
|
|
|
FaderPort8::button_bypass ()
|
|
|
|
{
|
|
|
|
boost::shared_ptr<PluginInsert> pi = _plugin_insert.lock();
|
|
|
|
if (pi) {
|
|
|
|
pi->enable (! pi->enabled ());
|
|
|
|
} else {
|
|
|
|
AccessAction ("Mixer", "ab-plugins");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-01 20:06:48 -04:00
|
|
|
void
|
|
|
|
FaderPort8::button_open ()
|
|
|
|
{
|
|
|
|
boost::shared_ptr<PluginInsert> pi = _plugin_insert.lock();
|
|
|
|
if (pi) {
|
|
|
|
pi->ToggleUI (); /* EMIT SIGNAL */
|
|
|
|
} else {
|
|
|
|
AccessAction ("Common", "addExistingAudioFiles");
|
|
|
|
}
|
|
|
|
}
|
2018-07-31 08:46:20 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
FaderPort8::button_chanlock ()
|
|
|
|
{
|
|
|
|
_chan_locked = !_chan_locked;
|
|
|
|
|
|
|
|
_ctrls.button (FP8Controls::BtnChannel).set_blinking (_chan_locked);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FaderPort8::button_flip ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-07-02 12:16:54 -04:00
|
|
|
void
|
|
|
|
FaderPort8::button_lock ()
|
|
|
|
{
|
|
|
|
if (!_link_enabled) {
|
|
|
|
AccessAction ("Editor", "lock");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (_link_locked) {
|
|
|
|
unlock_link ();
|
|
|
|
} else if (!_link_control.expired ()) {
|
|
|
|
lock_link ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FaderPort8::button_link ()
|
|
|
|
{
|
|
|
|
switch (_ctrls.fader_mode()) {
|
|
|
|
case ModeTrack:
|
|
|
|
case ModePan:
|
|
|
|
if (_link_enabled) {
|
|
|
|
stop_link ();
|
|
|
|
} else {
|
|
|
|
start_link ();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
//AccessAction ("Window", "show-mixer");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2017-07-01 20:06:48 -04:00
|
|
|
|
2017-04-05 05:04:16 -04:00
|
|
|
void
|
|
|
|
FaderPort8::button_automation (ARDOUR::AutoState as)
|
|
|
|
{
|
|
|
|
FaderMode fadermode = _ctrls.fader_mode ();
|
|
|
|
switch (fadermode) {
|
|
|
|
case ModePlugins:
|
|
|
|
#if 0 // Plugin Control Automation Mode
|
2018-07-31 08:46:20 -04:00
|
|
|
for (std::list <ProcessorCtrl>::iterator i = _proc_params.begin(); i != _proc_params.end(); ++i) {
|
2017-04-05 05:04:16 -04:00
|
|
|
((*i).ac)->set_automation_state (as);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return;
|
|
|
|
case ModeSend:
|
|
|
|
if (first_selected_stripable()) {
|
|
|
|
#if 0 // Send Level Automation
|
|
|
|
boost::shared_ptr<Stripable> s = first_selected_stripable();
|
|
|
|
boost::shared_ptr<AutomationControl> send;
|
|
|
|
uint32_t i = 0;
|
|
|
|
while (0 != (send = s->send_level_controllable (i))) {
|
|
|
|
send->set_automation_state (as);
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-07-02 19:42:36 -04:00
|
|
|
// TODO link/lock control automation?
|
|
|
|
|
2017-04-05 05:04:16 -04:00
|
|
|
// apply to all selected tracks
|
|
|
|
StripableList all;
|
|
|
|
session->get_stripables (all);
|
|
|
|
for (StripableList::const_iterator i = all.begin(); i != all.end(); ++i) {
|
|
|
|
if ((*i)->is_master() || (*i)->is_monitor()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!(*i)->is_selected()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
boost::shared_ptr<AutomationControl> ac;
|
|
|
|
switch (fadermode) {
|
|
|
|
case ModeTrack:
|
|
|
|
ac = (*i)->gain_control ();
|
|
|
|
break;
|
|
|
|
case ModePan:
|
|
|
|
ac = (*i)->pan_azimuth_control ();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (ac) {
|
|
|
|
ac->set_automation_state (as);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FaderPort8::button_varispeed (bool ffw)
|
|
|
|
{
|
|
|
|
/* pressing both rew + ffwd -> return to zero */
|
|
|
|
FP8ButtonInterface& b_rew = _ctrls.button (FP8Controls::BtnRewind);
|
|
|
|
FP8ButtonInterface& b_ffw = _ctrls.button (FP8Controls::BtnFastForward);
|
|
|
|
if (b_rew.is_pressed () && b_ffw.is_pressed ()){
|
|
|
|
// stop key-repeat
|
|
|
|
dynamic_cast<FP8RepeatButton*>(&b_ffw)->stop_repeat();
|
|
|
|
dynamic_cast<FP8RepeatButton*>(&b_rew)->stop_repeat();
|
2020-01-17 17:26:01 -05:00
|
|
|
session->request_locate (0, MustStop);
|
2017-04-05 05:04:16 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-05-04 18:10:24 -04:00
|
|
|
BasicUI::button_varispeed (ffw);
|
2017-04-05 05:04:16 -04:00
|
|
|
}
|
|
|
|
|
2017-05-05 09:26:52 -04:00
|
|
|
#ifdef FP8_MUTESOLO_UNDO
|
|
|
|
void
|
|
|
|
FaderPort8::button_solo_clear ()
|
|
|
|
{
|
|
|
|
bool soloing = session->soloing() || session->listening();
|
2017-07-18 19:52:14 -04:00
|
|
|
#ifdef MIXBUS
|
|
|
|
soloing |= session->mixbus_soloed();
|
|
|
|
#endif
|
2017-05-05 09:26:52 -04:00
|
|
|
if (soloing) {
|
|
|
|
StripableList all;
|
|
|
|
session->get_stripables (all);
|
|
|
|
for (StripableList::const_iterator i = all.begin(); i != all.end(); ++i) {
|
|
|
|
if ((*i)->is_master() || (*i)->is_auditioner() || (*i)->is_monitor()) {
|
|
|
|
continue;
|
|
|
|
}
|
2017-07-18 19:52:14 -04:00
|
|
|
boost::shared_ptr<SoloControl> sc = (*i)->solo_control();
|
|
|
|
if (sc && sc->self_soloed ()) {
|
|
|
|
_solo_state.push_back (boost::weak_ptr<AutomationControl>(sc));
|
2017-05-05 09:26:52 -04:00
|
|
|
}
|
|
|
|
}
|
2017-09-18 11:24:57 -04:00
|
|
|
cancel_all_solo (); // AccessAction ("Main", "cancel-solo");
|
2017-05-05 09:26:52 -04:00
|
|
|
} else {
|
|
|
|
/* restore solo */
|
|
|
|
boost::shared_ptr<ControlList> cl (new ControlList);
|
|
|
|
for (std::vector <boost::weak_ptr<AutomationControl> >::const_iterator i = _solo_state.begin(); i != _solo_state.end(); ++i) {
|
|
|
|
boost::shared_ptr<AutomationControl> ac = (*i).lock();
|
|
|
|
if (!ac) {
|
|
|
|
continue;
|
|
|
|
}
|
2017-09-18 12:39:17 -04:00
|
|
|
ac->start_touch (ac->session().transport_sample());
|
2017-05-05 09:26:52 -04:00
|
|
|
cl->push_back (ac);
|
|
|
|
}
|
|
|
|
if (!cl->empty()) {
|
|
|
|
session->set_controls (cl, 1.0, PBD::Controllable::NoGroup);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-04-05 05:04:16 -04:00
|
|
|
void
|
|
|
|
FaderPort8::button_mute_clear ()
|
|
|
|
{
|
2017-05-05 09:26:52 -04:00
|
|
|
#ifdef FP8_MUTESOLO_UNDO
|
2017-05-05 10:48:11 -04:00
|
|
|
if (session->muted ()) {
|
|
|
|
_mute_state = session->cancel_all_mute ();
|
|
|
|
} else {
|
2017-05-05 09:26:52 -04:00
|
|
|
/* restore mute */
|
2017-05-05 10:48:11 -04:00
|
|
|
boost::shared_ptr<ControlList> cl (new ControlList);
|
2017-05-05 09:26:52 -04:00
|
|
|
for (std::vector <boost::weak_ptr<AutomationControl> >::const_iterator i = _mute_state.begin(); i != _mute_state.end(); ++i) {
|
|
|
|
boost::shared_ptr<AutomationControl> ac = (*i).lock();
|
2017-05-05 10:48:11 -04:00
|
|
|
if (!ac) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
cl->push_back (ac);
|
2017-09-18 12:39:17 -04:00
|
|
|
ac->start_touch (ac->session().transport_sample());
|
2017-05-05 09:26:52 -04:00
|
|
|
}
|
2017-05-05 10:48:11 -04:00
|
|
|
if (!cl->empty()) {
|
|
|
|
session->set_controls (cl, 1.0, PBD::Controllable::NoGroup);
|
2017-05-05 09:26:52 -04:00
|
|
|
}
|
|
|
|
}
|
2017-05-05 10:48:11 -04:00
|
|
|
#else
|
|
|
|
session->cancel_all_mute ();
|
2017-05-05 09:26:52 -04:00
|
|
|
#endif
|
2017-04-05 05:04:16 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FaderPort8::button_arm_all ()
|
|
|
|
{
|
|
|
|
BasicUI::all_tracks_rec_in ();
|
|
|
|
}
|
|
|
|
|
2017-04-20 11:19:03 -04:00
|
|
|
/* access generic action */
|
2017-04-05 05:04:16 -04:00
|
|
|
void
|
|
|
|
FaderPort8::button_action (const std::string& group, const std::string& item)
|
|
|
|
{
|
|
|
|
AccessAction (group, item);
|
|
|
|
}
|
|
|
|
|
2017-07-02 12:16:54 -04:00
|
|
|
/* ****************************************************************************
|
|
|
|
* Control Interaction (encoder)
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
FaderPort8::handle_encoder_pan (int steps)
|
|
|
|
{
|
|
|
|
boost::shared_ptr<Stripable> s = first_selected_stripable();
|
|
|
|
if (s) {
|
|
|
|
boost::shared_ptr<AutomationControl> ac;
|
|
|
|
if (shift_mod () || _ctrls.fader_mode() == ModePan) {
|
|
|
|
ac = s->pan_width_control ();
|
|
|
|
} else {
|
|
|
|
ac = s->pan_azimuth_control ();
|
|
|
|
}
|
|
|
|
if (ac) {
|
2017-09-18 12:39:17 -04:00
|
|
|
ac->start_touch (ac->session().transport_sample());
|
2017-07-02 12:16:54 -04:00
|
|
|
if (steps == 0) {
|
|
|
|
ac->set_value (ac->normal(), PBD::Controllable::UseGroup);
|
|
|
|
} else {
|
2020-02-12 14:12:08 -05:00
|
|
|
double v = ac->internal_to_interface (ac->get_value(), true);
|
2017-07-02 12:16:54 -04:00
|
|
|
v = std::max (0.0, std::min (1.0, v + steps * .01));
|
2020-02-12 14:12:08 -05:00
|
|
|
ac->set_value (ac->interface_to_internal(v, true), PBD::Controllable::UseGroup);
|
2017-07-02 12:16:54 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FaderPort8::handle_encoder_link (int steps)
|
|
|
|
{
|
|
|
|
if (_link_control.expired ()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
boost::shared_ptr<AutomationControl> ac = boost::dynamic_pointer_cast<AutomationControl> (_link_control.lock ());
|
|
|
|
if (!ac) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-02-12 14:12:08 -05:00
|
|
|
double v = ac->internal_to_interface (ac->get_value(), true);
|
2017-09-18 12:39:17 -04:00
|
|
|
ac->start_touch (ac->session().transport_sample());
|
2017-07-02 12:16:54 -04:00
|
|
|
|
|
|
|
if (steps == 0) {
|
|
|
|
ac->set_value (ac->normal(), PBD::Controllable::UseGroup);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ac->desc().toggled) {
|
|
|
|
v = v > 0 ? 0. : 1.;
|
2017-07-02 15:05:42 -04:00
|
|
|
} else if (ac->desc().integer_step) {
|
|
|
|
v += steps / (1.f + ac->desc().upper - ac->desc().lower);
|
|
|
|
} else if (ac->desc().enumeration) {
|
|
|
|
ac->set_value (ac->desc().step_enum (ac->get_value(), steps < 0), PBD::Controllable::UseGroup);
|
|
|
|
return;
|
2017-07-02 12:16:54 -04:00
|
|
|
} else {
|
|
|
|
v = std::max (0.0, std::min (1.0, v + steps * .01));
|
|
|
|
}
|
2020-02-12 14:12:08 -05:00
|
|
|
ac->set_value (ac->interface_to_internal(v, true), PBD::Controllable::UseGroup);
|
2017-07-02 12:16:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-04-20 11:19:03 -04:00
|
|
|
/* ****************************************************************************
|
|
|
|
* Mode specific and internal callbacks
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* handle "ARM" press -- act like shift, change "Select" button mode */
|
|
|
|
void
|
|
|
|
FaderPort8::button_arm (bool press)
|
|
|
|
{
|
2018-07-31 08:46:20 -04:00
|
|
|
#ifdef FADERPORT2
|
|
|
|
boost::shared_ptr<Stripable> s = first_selected_stripable();
|
|
|
|
if (press && s) {
|
|
|
|
boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track>(s);
|
|
|
|
if (t) {
|
|
|
|
t->rec_enable_control()->set_value (!t->rec_enable_control()->get_value(), PBD::Controllable::UseGroup);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
2017-04-20 11:19:03 -04:00
|
|
|
FaderMode fadermode = _ctrls.fader_mode ();
|
|
|
|
if (fadermode == ModeTrack || fadermode == ModePan) {
|
|
|
|
_ctrls.button (FP8Controls::BtnArm).set_active (press);
|
|
|
|
ARMButtonChange (press); /* EMIT SIGNAL */
|
|
|
|
}
|
2018-07-31 08:46:20 -04:00
|
|
|
#endif
|
2017-04-20 11:19:03 -04:00
|
|
|
}
|
|
|
|
|
2017-04-05 05:04:16 -04:00
|
|
|
void
|
|
|
|
FaderPort8::button_prev_next (bool next)
|
|
|
|
{
|
|
|
|
switch (_ctrls.nav_mode()) {
|
|
|
|
case NavChannel:
|
2018-08-01 12:34:56 -04:00
|
|
|
#ifndef FADERPORT2
|
2017-04-14 07:57:14 -04:00
|
|
|
select_prev_next (next);
|
|
|
|
break;
|
2018-08-01 12:34:56 -04:00
|
|
|
#endif
|
2017-04-14 07:57:14 -04:00
|
|
|
case NavMaster:
|
2017-04-05 05:04:16 -04:00
|
|
|
case NavScroll:
|
2018-07-31 08:46:20 -04:00
|
|
|
case NavPan:
|
2017-04-05 05:04:16 -04:00
|
|
|
bank (!next, false);
|
|
|
|
break;
|
|
|
|
case NavBank:
|
|
|
|
bank (!next, true);
|
|
|
|
break;
|
|
|
|
case NavZoom:
|
|
|
|
if (next) {
|
2017-04-14 07:57:14 -04:00
|
|
|
VerticalZoomInSelected ();
|
2017-04-05 05:04:16 -04:00
|
|
|
} else {
|
2017-04-14 07:57:14 -04:00
|
|
|
VerticalZoomOutSelected ();
|
2017-04-05 05:04:16 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NavSection:
|
2017-04-14 07:57:14 -04:00
|
|
|
if (next) {
|
|
|
|
AccessAction ("Region", "nudge-forward");
|
|
|
|
} else {
|
|
|
|
AccessAction ("Region", "nudge-backward");
|
|
|
|
}
|
2017-04-05 05:04:16 -04:00
|
|
|
break;
|
|
|
|
case NavMarker:
|
|
|
|
if (next) {
|
|
|
|
next_marker ();
|
|
|
|
} else {
|
|
|
|
prev_marker ();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* handle navigation encoder press */
|
|
|
|
void
|
|
|
|
FaderPort8::button_encoder ()
|
|
|
|
{
|
2017-04-16 11:18:05 -04:00
|
|
|
/* special-case metronome level */
|
|
|
|
if (_ctrls.button (FP8Controls::BtnClick).is_pressed ()) {
|
|
|
|
Config->set_click_gain (1.0);
|
|
|
|
_ctrls.button (FP8Controls::BtnClick).ignore_release();
|
|
|
|
return;
|
|
|
|
}
|
2017-04-05 05:04:16 -04:00
|
|
|
switch (_ctrls.nav_mode()) {
|
|
|
|
case NavZoom:
|
|
|
|
ZoomToSession (); // XXX undo zoom
|
|
|
|
break;
|
|
|
|
case NavScroll:
|
|
|
|
ZoomToSession ();
|
|
|
|
break;
|
|
|
|
case NavChannel:
|
2017-04-29 06:38:38 -04:00
|
|
|
AccessAction ("Editor", "select-topmost");
|
|
|
|
break;
|
2017-04-05 05:04:16 -04:00
|
|
|
case NavBank:
|
|
|
|
move_selected_into_view ();
|
|
|
|
break;
|
|
|
|
case NavMaster:
|
|
|
|
{
|
|
|
|
/* master || monitor level -- reset to 0dB */
|
|
|
|
boost::shared_ptr<AutomationControl> ac;
|
|
|
|
if (session->monitor_active() && !_ctrls.button (FP8Controls::BtnMaster).is_pressed ()) {
|
|
|
|
ac = session->monitor_out()->gain_control ();
|
|
|
|
} else if (session->master_out()) {
|
|
|
|
ac = session->master_out()->gain_control ();
|
|
|
|
}
|
|
|
|
if (ac) {
|
2017-09-18 12:39:17 -04:00
|
|
|
ac->start_touch (ac->session().transport_sample());
|
2017-04-05 05:04:16 -04:00
|
|
|
ac->set_value (ac->normal(), PBD::Controllable::NoGroup);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2018-07-31 08:46:20 -04:00
|
|
|
case NavPan:
|
|
|
|
break;
|
2017-04-05 05:04:16 -04:00
|
|
|
case NavSection:
|
2017-04-14 07:57:14 -04:00
|
|
|
// TODO nudge
|
2017-04-05 05:04:16 -04:00
|
|
|
break;
|
|
|
|
case NavMarker:
|
|
|
|
{
|
|
|
|
string markername;
|
|
|
|
/* Don't add another mark if one exists within 1/100th of a second of
|
|
|
|
* the current position and we're not rolling.
|
|
|
|
*/
|
2017-09-18 12:39:17 -04:00
|
|
|
samplepos_t where = session->audible_sample();
|
2019-12-29 20:43:37 -05:00
|
|
|
if (session->transport_stopped_or_stopping() && session->locations()->mark_at (where, session->sample_rate() / 100.0)) {
|
2017-04-05 05:04:16 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
session->locations()->next_available_name (markername,"mark");
|
|
|
|
add_marker (markername);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* handle navigation encoder turn */
|
|
|
|
void
|
|
|
|
FaderPort8::encoder_navigate (bool neg, int steps)
|
|
|
|
{
|
|
|
|
/* special-case metronome level */
|
|
|
|
if (_ctrls.button (FP8Controls::BtnClick).is_pressed ()) {
|
|
|
|
// compare to ARDOUR_UI::click_button_scroll()
|
|
|
|
gain_t gain = Config->get_click_gain();
|
|
|
|
float gain_db = accurate_coefficient_to_dB (gain);
|
|
|
|
gain_db += (neg ? -1.f : 1.f) * steps;
|
|
|
|
gain_db = std::max (-60.f, gain_db);
|
|
|
|
gain = dB_to_coefficient (gain_db);
|
|
|
|
gain = std::min (gain, Config->get_max_gain());
|
|
|
|
Config->set_click_gain (gain);
|
|
|
|
_ctrls.button (FP8Controls::BtnClick).ignore_release();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (_ctrls.nav_mode()) {
|
|
|
|
case NavChannel:
|
|
|
|
if (neg) {
|
2017-04-29 06:37:31 -04:00
|
|
|
AccessAction ("Mixer", "scroll-left");
|
|
|
|
AccessAction ("Editor", "step-tracks-up");
|
2017-04-05 05:04:16 -04:00
|
|
|
} else {
|
2017-04-29 06:37:31 -04:00
|
|
|
AccessAction ("Mixer", "scroll-right");
|
|
|
|
AccessAction ("Editor", "step-tracks-down");
|
2017-04-05 05:04:16 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NavZoom:
|
|
|
|
if (neg) {
|
|
|
|
ZoomOut ();
|
|
|
|
} else {
|
|
|
|
ZoomIn ();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NavMarker:
|
|
|
|
case NavScroll:
|
|
|
|
ScrollTimeline ((neg ? -1.f : 1.f) * steps / (shift_mod() ? 1024.f : 256.f));
|
|
|
|
break;
|
|
|
|
case NavBank:
|
|
|
|
bank (neg, false);
|
|
|
|
break;
|
|
|
|
case NavMaster:
|
|
|
|
{
|
|
|
|
/* master || monitor level */
|
|
|
|
boost::shared_ptr<AutomationControl> ac;
|
|
|
|
if (session->monitor_active() && !_ctrls.button (FP8Controls::BtnMaster).is_pressed ()) {
|
|
|
|
ac = session->monitor_out()->gain_control ();
|
|
|
|
} else if (session->master_out()) {
|
|
|
|
ac = session->master_out()->gain_control ();
|
|
|
|
}
|
|
|
|
if (ac) {
|
|
|
|
double v = ac->internal_to_interface (ac->get_value());
|
|
|
|
v = std::max (0.0, std::min (1.0, v + steps * (neg ? -.01 : .01)));
|
2017-09-18 12:39:17 -04:00
|
|
|
ac->start_touch (ac->session().transport_sample());
|
2017-04-05 05:04:16 -04:00
|
|
|
ac->set_value (ac->interface_to_internal(v), PBD::Controllable::NoGroup);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NavSection:
|
2017-04-14 07:57:14 -04:00
|
|
|
if (neg) {
|
|
|
|
AccessAction ("Common", "nudge-playhead-backward");
|
|
|
|
} else {
|
|
|
|
AccessAction ("Common", "nudge-playhead-forward");
|
|
|
|
}
|
2017-04-05 05:04:16 -04:00
|
|
|
break;
|
2018-07-31 08:46:20 -04:00
|
|
|
case NavPan:
|
|
|
|
abort(); /*NOTREACHED*/
|
|
|
|
break;
|
2017-04-05 05:04:16 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* handle pan/param encoder press */
|
|
|
|
void
|
|
|
|
FaderPort8::button_parameter ()
|
|
|
|
{
|
|
|
|
switch (_ctrls.fader_mode()) {
|
|
|
|
case ModeTrack:
|
|
|
|
case ModePan:
|
2017-07-02 12:16:54 -04:00
|
|
|
if (_link_enabled || _link_locked) {
|
|
|
|
handle_encoder_link (0);
|
|
|
|
} else {
|
|
|
|
handle_encoder_pan (0);
|
2017-04-14 07:57:14 -04:00
|
|
|
}
|
2017-04-05 05:04:16 -04:00
|
|
|
break;
|
|
|
|
case ModePlugins:
|
2017-06-30 06:13:21 -04:00
|
|
|
toggle_preset_param_mode ();
|
2017-04-05 05:04:16 -04:00
|
|
|
break;
|
|
|
|
case ModeSend:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* handle pan/param encoder turn */
|
|
|
|
void
|
|
|
|
FaderPort8::encoder_parameter (bool neg, int steps)
|
|
|
|
{
|
|
|
|
switch (_ctrls.fader_mode()) {
|
|
|
|
case ModeTrack:
|
|
|
|
case ModePan:
|
2017-07-02 12:16:54 -04:00
|
|
|
if (steps != 0) {
|
|
|
|
if (_link_enabled || _link_locked) {
|
|
|
|
handle_encoder_link (neg ? -steps : steps);
|
|
|
|
} else {
|
|
|
|
handle_encoder_pan (neg ? -steps : steps);
|
2017-04-05 05:04:16 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ModePlugins:
|
|
|
|
case ModeSend:
|
|
|
|
while (steps > 0) {
|
2017-07-01 20:06:48 -04:00
|
|
|
bank_param (neg, shift_mod());
|
2017-04-05 05:04:16 -04:00
|
|
|
--steps;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* handle user-specific actions */
|
|
|
|
void
|
|
|
|
FaderPort8::button_user (bool press, FP8Controls::ButtonId btn)
|
|
|
|
{
|
|
|
|
_user_action_map[btn].call (*this, press);
|
|
|
|
}
|