2016-06-17 01:29:00 -04:00
|
|
|
/*
|
2019-08-03 08:34:29 -04:00
|
|
|
* Copyright (C) 2016-2018 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
*
|
|
|
|
* 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-06-17 01:29:00 -04:00
|
|
|
|
2016-06-17 15:51:16 -04:00
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
#include "ardour/debug.h"
|
2016-06-17 01:29:00 -04:00
|
|
|
#include "ardour/mute_control.h"
|
2016-06-16 14:06:16 -04:00
|
|
|
#include "ardour/session.h"
|
2016-06-17 01:29:00 -04:00
|
|
|
#include "ardour/solo_control.h"
|
2016-06-16 14:06:16 -04:00
|
|
|
|
2016-07-10 12:38:36 -04:00
|
|
|
#include "layout.h"
|
2016-06-16 14:06:16 -04:00
|
|
|
#include "push2.h"
|
2016-07-10 13:02:42 -04:00
|
|
|
#include "track_mix.h"
|
2016-06-16 14:06:16 -04:00
|
|
|
|
|
|
|
using namespace ArdourSurface;
|
2016-06-17 01:29:00 -04:00
|
|
|
using namespace ARDOUR;
|
2016-06-17 15:51:16 -04:00
|
|
|
using namespace PBD;
|
|
|
|
using std::cerr;
|
|
|
|
|
|
|
|
void
|
|
|
|
Push2::build_maps ()
|
|
|
|
{
|
|
|
|
/* Pads */
|
|
|
|
|
2018-09-02 13:23:36 -04:00
|
|
|
boost::shared_ptr<Pad> pad;
|
2016-06-17 15:51:16 -04:00
|
|
|
|
|
|
|
#define MAKE_PAD(x,y,nn) \
|
2018-09-02 13:23:36 -04:00
|
|
|
pad.reset (new Pad ((x), (y), (nn))); \
|
2016-07-10 11:30:16 -04:00
|
|
|
nn_pad_map.insert (std::make_pair (pad->extra(), pad));
|
2016-06-17 15:51:16 -04:00
|
|
|
|
2016-07-07 14:26:55 -04:00
|
|
|
MAKE_PAD (0, 0, 92);
|
2016-06-17 15:51:16 -04:00
|
|
|
MAKE_PAD (0, 1, 93);
|
|
|
|
MAKE_PAD (0, 2, 94);
|
|
|
|
MAKE_PAD (0, 3, 95);
|
|
|
|
MAKE_PAD (0, 4, 96);
|
|
|
|
MAKE_PAD (0, 5, 97);
|
|
|
|
MAKE_PAD (0, 6, 98);
|
2016-07-07 14:26:55 -04:00
|
|
|
MAKE_PAD (0, 7, 99);
|
2016-06-17 15:51:16 -04:00
|
|
|
MAKE_PAD (1, 0, 84);
|
|
|
|
MAKE_PAD (1, 1, 85);
|
|
|
|
MAKE_PAD (1, 2, 86);
|
|
|
|
MAKE_PAD (1, 3, 87);
|
|
|
|
MAKE_PAD (1, 4, 88);
|
|
|
|
MAKE_PAD (1, 5, 89);
|
|
|
|
MAKE_PAD (1, 6, 90);
|
|
|
|
MAKE_PAD (1, 7, 91);
|
|
|
|
MAKE_PAD (2, 0, 76);
|
|
|
|
MAKE_PAD (2, 1, 77);
|
|
|
|
MAKE_PAD (2, 2, 78);
|
|
|
|
MAKE_PAD (2, 3, 79);
|
|
|
|
MAKE_PAD (2, 4, 80);
|
|
|
|
MAKE_PAD (2, 5, 81);
|
|
|
|
MAKE_PAD (2, 6, 82);
|
|
|
|
MAKE_PAD (2, 7, 83);
|
|
|
|
MAKE_PAD (3, 0, 68);
|
|
|
|
MAKE_PAD (3, 1, 69);
|
|
|
|
MAKE_PAD (3, 2, 70);
|
|
|
|
MAKE_PAD (3, 3, 71);
|
|
|
|
MAKE_PAD (3, 4, 72);
|
|
|
|
MAKE_PAD (3, 5, 73);
|
|
|
|
MAKE_PAD (3, 6, 74);
|
|
|
|
MAKE_PAD (3, 7, 75);
|
|
|
|
MAKE_PAD (4, 0, 60);
|
|
|
|
MAKE_PAD (4, 1, 61);
|
|
|
|
MAKE_PAD (4, 2, 62);
|
|
|
|
MAKE_PAD (4, 3, 63);
|
|
|
|
MAKE_PAD (4, 4, 64);
|
|
|
|
MAKE_PAD (4, 5, 65);
|
|
|
|
MAKE_PAD (4, 6, 66);
|
|
|
|
MAKE_PAD (4, 7, 67);
|
|
|
|
MAKE_PAD (5, 0, 52);
|
|
|
|
MAKE_PAD (5, 1, 53);
|
|
|
|
MAKE_PAD (5, 2, 54);
|
2016-06-20 08:31:05 -04:00
|
|
|
MAKE_PAD (5, 3, 55);
|
2016-06-17 15:51:16 -04:00
|
|
|
MAKE_PAD (5, 4, 56);
|
|
|
|
MAKE_PAD (5, 5, 57);
|
|
|
|
MAKE_PAD (5, 6, 58);
|
|
|
|
MAKE_PAD (5, 7, 59);
|
|
|
|
MAKE_PAD (6, 0, 44);
|
|
|
|
MAKE_PAD (6, 1, 45);
|
|
|
|
MAKE_PAD (6, 2, 46);
|
|
|
|
MAKE_PAD (6, 3, 47);
|
|
|
|
MAKE_PAD (6, 4, 48);
|
|
|
|
MAKE_PAD (6, 5, 49);
|
|
|
|
MAKE_PAD (6, 6, 50);
|
|
|
|
MAKE_PAD (6, 7, 51);
|
|
|
|
MAKE_PAD (7, 0, 36);
|
|
|
|
MAKE_PAD (7, 1, 37);
|
|
|
|
MAKE_PAD (7, 2, 38);
|
|
|
|
MAKE_PAD (7, 3, 39);
|
|
|
|
MAKE_PAD (7, 4, 40);
|
|
|
|
MAKE_PAD (7, 5, 41);
|
|
|
|
MAKE_PAD (7, 6, 42);
|
|
|
|
MAKE_PAD (7, 7, 43);
|
|
|
|
|
|
|
|
/* Now color buttons */
|
|
|
|
|
2018-09-02 13:23:36 -04:00
|
|
|
boost::shared_ptr<Button> button;
|
2016-06-17 15:51:16 -04:00
|
|
|
|
|
|
|
#define MAKE_COLOR_BUTTON(i,cc) \
|
2018-09-02 13:23:36 -04:00
|
|
|
button.reset (new ColorButton ((i), (cc))); \
|
2016-06-17 15:51:16 -04:00
|
|
|
cc_button_map.insert (std::make_pair (button->controller_number(), button)); \
|
|
|
|
id_button_map.insert (std::make_pair (button->id, button));
|
|
|
|
#define MAKE_COLOR_BUTTON_PRESS(i,cc,p)\
|
2018-09-02 13:23:36 -04:00
|
|
|
button.reset (new ColorButton ((i), (cc), (p))); \
|
2016-06-17 15:51:16 -04:00
|
|
|
cc_button_map.insert (std::make_pair (button->controller_number(), button)); \
|
|
|
|
id_button_map.insert (std::make_pair (button->id, button))
|
2016-07-11 13:13:04 -04:00
|
|
|
#define MAKE_COLOR_BUTTON_PRESS_RELEASE_LONG(i,cc,p,r,l) \
|
2018-09-02 13:23:36 -04:00
|
|
|
button.reset (new ColorButton ((i), (cc), (p), (r), (l))); \
|
2016-07-11 13:13:04 -04:00
|
|
|
cc_button_map.insert (std::make_pair (button->controller_number(), button)); \
|
|
|
|
id_button_map.insert (std::make_pair (button->id, button))
|
2016-06-17 15:51:16 -04:00
|
|
|
|
|
|
|
MAKE_COLOR_BUTTON_PRESS (Upper1, 102, &Push2::button_upper_1);
|
|
|
|
MAKE_COLOR_BUTTON_PRESS (Upper2, 103, &Push2::button_upper_2);
|
|
|
|
MAKE_COLOR_BUTTON_PRESS (Upper3, 104, &Push2::button_upper_3);
|
|
|
|
MAKE_COLOR_BUTTON_PRESS (Upper4, 105, &Push2::button_upper_4);
|
|
|
|
MAKE_COLOR_BUTTON_PRESS (Upper5, 106, &Push2::button_upper_5);
|
|
|
|
MAKE_COLOR_BUTTON_PRESS (Upper6, 107, &Push2::button_upper_6);
|
|
|
|
MAKE_COLOR_BUTTON_PRESS (Upper7, 108, &Push2::button_upper_7);
|
|
|
|
MAKE_COLOR_BUTTON_PRESS (Upper8, 109, &Push2::button_upper_8);
|
|
|
|
MAKE_COLOR_BUTTON_PRESS (Lower1, 20, &Push2::button_lower_1);
|
|
|
|
MAKE_COLOR_BUTTON_PRESS (Lower2, 21, &Push2::button_lower_2);
|
|
|
|
MAKE_COLOR_BUTTON_PRESS (Lower3, 22, &Push2::button_lower_3);
|
|
|
|
MAKE_COLOR_BUTTON_PRESS (Lower4, 23, &Push2::button_lower_4);
|
|
|
|
MAKE_COLOR_BUTTON_PRESS (Lower5, 24, &Push2::button_lower_5);
|
|
|
|
MAKE_COLOR_BUTTON_PRESS (Lower6, 25, &Push2::button_lower_6);
|
|
|
|
MAKE_COLOR_BUTTON_PRESS (Lower7, 26, &Push2::button_lower_7);
|
|
|
|
MAKE_COLOR_BUTTON_PRESS (Lower8, 27, &Push2::button_lower_8);
|
2016-09-22 15:41:49 -04:00
|
|
|
MAKE_COLOR_BUTTON_PRESS (Master, 28, &Push2::button_master);
|
2016-07-11 13:13:04 -04:00
|
|
|
MAKE_COLOR_BUTTON_PRESS (Mute, 60, &Push2::button_mute);
|
|
|
|
MAKE_COLOR_BUTTON_PRESS_RELEASE_LONG (Solo, 61, &Push2::relax, &Push2::button_solo, &Push2::button_solo_long_press);
|
2016-06-17 15:51:16 -04:00
|
|
|
MAKE_COLOR_BUTTON_PRESS (Stop, 29, &Push2::button_stop);
|
|
|
|
MAKE_COLOR_BUTTON_PRESS (Fwd32ndT, 43, &Push2::button_fwd32t);
|
|
|
|
MAKE_COLOR_BUTTON_PRESS (Fwd32nd,42 , &Push2::button_fwd32);
|
|
|
|
MAKE_COLOR_BUTTON_PRESS (Fwd16thT, 41, &Push2::button_fwd16t);
|
|
|
|
MAKE_COLOR_BUTTON_PRESS (Fwd16th, 40, &Push2::button_fwd16);
|
|
|
|
MAKE_COLOR_BUTTON_PRESS (Fwd8thT, 39 , &Push2::button_fwd8t);
|
|
|
|
MAKE_COLOR_BUTTON_PRESS (Fwd8th, 38, &Push2::button_fwd8);
|
|
|
|
MAKE_COLOR_BUTTON_PRESS (Fwd4trT, 37, &Push2::button_fwd4t);
|
|
|
|
MAKE_COLOR_BUTTON_PRESS (Fwd4tr, 36, &Push2::button_fwd4);
|
|
|
|
MAKE_COLOR_BUTTON (Automate, 89);
|
|
|
|
MAKE_COLOR_BUTTON_PRESS (RecordEnable, 86, &Push2::button_recenable);
|
|
|
|
MAKE_COLOR_BUTTON_PRESS (Play, 85, &Push2::button_play);
|
|
|
|
|
|
|
|
#define MAKE_WHITE_BUTTON(i,cc)\
|
2018-09-02 13:23:36 -04:00
|
|
|
button.reset (new WhiteButton ((i), (cc))); \
|
2016-06-17 15:51:16 -04:00
|
|
|
cc_button_map.insert (std::make_pair (button->controller_number(), button)); \
|
|
|
|
id_button_map.insert (std::make_pair (button->id, button))
|
|
|
|
#define MAKE_WHITE_BUTTON_PRESS(i,cc,p)\
|
2018-09-02 13:23:36 -04:00
|
|
|
button.reset (new WhiteButton ((i), (cc), (p))); \
|
2016-06-17 15:51:16 -04:00
|
|
|
cc_button_map.insert (std::make_pair (button->controller_number(), button)); \
|
|
|
|
id_button_map.insert (std::make_pair (button->id, button))
|
|
|
|
#define MAKE_WHITE_BUTTON_PRESS_RELEASE(i,cc,p,r) \
|
2018-09-02 13:23:36 -04:00
|
|
|
button.reset (new WhiteButton ((i), (cc), (p), (r))); \
|
2016-06-17 15:51:16 -04:00
|
|
|
cc_button_map.insert (std::make_pair (button->controller_number(), button)); \
|
|
|
|
id_button_map.insert (std::make_pair (button->id, button))
|
|
|
|
#define MAKE_WHITE_BUTTON_PRESS_RELEASE_LONG(i,cc,p,r,l) \
|
2018-09-02 13:23:36 -04:00
|
|
|
button.reset (new WhiteButton ((i), (cc), (p), (r), (l))); \
|
2016-06-17 15:51:16 -04:00
|
|
|
cc_button_map.insert (std::make_pair (button->controller_number(), button)); \
|
|
|
|
id_button_map.insert (std::make_pair (button->id, button))
|
|
|
|
|
|
|
|
MAKE_WHITE_BUTTON (TapTempo, 3);
|
|
|
|
MAKE_WHITE_BUTTON_PRESS (Metronome, 9, &Push2::button_metronome);
|
|
|
|
MAKE_WHITE_BUTTON (Setup, 30);
|
|
|
|
MAKE_WHITE_BUTTON (User, 59);
|
|
|
|
MAKE_WHITE_BUTTON (Delete, 118);
|
|
|
|
MAKE_WHITE_BUTTON (AddDevice, 52);
|
|
|
|
MAKE_WHITE_BUTTON (Device, 110);
|
2016-07-10 13:02:42 -04:00
|
|
|
MAKE_WHITE_BUTTON_PRESS (Mix, 112, &Push2::button_mix_press);
|
2016-06-17 15:51:16 -04:00
|
|
|
MAKE_WHITE_BUTTON_PRESS (Undo, 119, &Push2::button_undo);
|
|
|
|
MAKE_WHITE_BUTTON_PRESS (AddTrack, 53, &Push2::button_add_track);
|
|
|
|
MAKE_WHITE_BUTTON_PRESS (Browse, 111, &Push2::button_browse);
|
|
|
|
MAKE_WHITE_BUTTON_PRESS (Clip, 113, &Push2::button_clip);
|
|
|
|
MAKE_WHITE_BUTTON (Convert, 35);
|
|
|
|
MAKE_WHITE_BUTTON (DoubleLoop, 117);
|
2016-09-22 17:28:25 -04:00
|
|
|
MAKE_WHITE_BUTTON_PRESS (Quantize, 116, &Push2::button_quantize);
|
|
|
|
MAKE_WHITE_BUTTON_PRESS (Duplicate, 88, &Push2::button_duplicate);
|
2016-06-17 15:51:16 -04:00
|
|
|
MAKE_WHITE_BUTTON_PRESS (New, 87, &Push2::button_new);
|
|
|
|
MAKE_WHITE_BUTTON_PRESS (FixedLength, 90, &Push2::button_fixed_length);
|
|
|
|
MAKE_WHITE_BUTTON_PRESS (Up, 46, &Push2::button_up);
|
|
|
|
MAKE_WHITE_BUTTON_PRESS (Right, 45, &Push2::button_right);
|
|
|
|
MAKE_WHITE_BUTTON_PRESS (Down, 47, &Push2::button_down);
|
|
|
|
MAKE_WHITE_BUTTON_PRESS (Left, 44, &Push2::button_left);
|
|
|
|
MAKE_WHITE_BUTTON_PRESS (Repeat, 56, &Push2::button_repeat);
|
|
|
|
MAKE_WHITE_BUTTON (Accent, 57);
|
2016-07-10 08:37:45 -04:00
|
|
|
MAKE_WHITE_BUTTON_PRESS (Scale, 58, &Push2::button_scale_press);
|
2016-07-09 23:26:02 -04:00
|
|
|
MAKE_WHITE_BUTTON_PRESS (Layout, 31, &Push2::button_layout_press);
|
2016-06-17 15:51:16 -04:00
|
|
|
MAKE_WHITE_BUTTON (Note, 50);
|
|
|
|
MAKE_WHITE_BUTTON (Session, 51);
|
|
|
|
MAKE_WHITE_BUTTON (Layout, 31);
|
2016-07-06 23:49:07 -04:00
|
|
|
MAKE_WHITE_BUTTON_PRESS (OctaveUp, 55, &Push2::button_octave_up);
|
2016-06-17 18:54:13 -04:00
|
|
|
MAKE_WHITE_BUTTON_PRESS (PageRight, 63, &Push2::button_page_right);
|
2016-07-06 23:49:07 -04:00
|
|
|
MAKE_WHITE_BUTTON_PRESS (OctaveDown, 54, &Push2::button_octave_down);
|
2016-06-17 18:54:13 -04:00
|
|
|
MAKE_WHITE_BUTTON_PRESS (PageLeft, 62, &Push2::button_page_left);
|
2016-06-17 15:51:16 -04:00
|
|
|
MAKE_WHITE_BUTTON_PRESS_RELEASE_LONG (Shift, 49, &Push2::button_shift_press, &Push2::button_shift_release, &Push2::button_shift_long_press);
|
|
|
|
MAKE_WHITE_BUTTON_PRESS_RELEASE_LONG (Select, 48, &Push2::button_select_press, &Push2::button_select_release, &Push2::button_select_long_press);
|
|
|
|
}
|
2016-06-16 14:06:16 -04:00
|
|
|
|
2016-09-22 17:28:25 -04:00
|
|
|
std::string
|
|
|
|
Push2::button_name_by_id (ButtonID id)
|
|
|
|
{
|
|
|
|
switch (id) {
|
|
|
|
case TapTempo:
|
|
|
|
return "TapTempo";
|
|
|
|
case Metronome:
|
|
|
|
return "Metronome";
|
|
|
|
case Upper1:
|
|
|
|
return "Upper1";
|
|
|
|
case Upper2:
|
|
|
|
return "Upper2";
|
|
|
|
case Upper3:
|
|
|
|
return "Upper3";
|
|
|
|
case Upper4:
|
|
|
|
return "Upper4";
|
|
|
|
case Upper5:
|
|
|
|
return "Upper5";
|
|
|
|
case Upper6:
|
|
|
|
return "Upper6";
|
|
|
|
case Upper7:
|
|
|
|
return "Upper7";
|
|
|
|
case Upper8:
|
|
|
|
return "Upper8";
|
|
|
|
case Setup:
|
|
|
|
return "Setup";
|
|
|
|
case User:
|
|
|
|
return "User";
|
|
|
|
case Delete:
|
|
|
|
return "Delete";
|
|
|
|
case AddDevice:
|
|
|
|
return "AddDevice";
|
|
|
|
case Device:
|
|
|
|
return "Device";
|
|
|
|
case Mix:
|
|
|
|
return "Mix";
|
|
|
|
case Undo:
|
|
|
|
return "Undo";
|
|
|
|
case AddTrack:
|
|
|
|
return "AddTrack";
|
|
|
|
case Browse:
|
|
|
|
return "Browse";
|
|
|
|
case Clip:
|
|
|
|
return "Clip";
|
|
|
|
case Mute:
|
|
|
|
return "Mute";
|
|
|
|
case Solo:
|
|
|
|
return "Solo";
|
|
|
|
case Stop:
|
|
|
|
return "Stop";
|
|
|
|
case Lower1:
|
|
|
|
return "Lower1";
|
|
|
|
case Lower2:
|
|
|
|
return "Lower2";
|
|
|
|
case Lower3:
|
|
|
|
return "Lower3";
|
|
|
|
case Lower4:
|
|
|
|
return "Lower4";
|
|
|
|
case Lower5:
|
|
|
|
return "Lower5";
|
|
|
|
case Lower6:
|
|
|
|
return "Lower6";
|
|
|
|
case Lower7:
|
|
|
|
return "Lower7";
|
|
|
|
case Lower8:
|
|
|
|
return "Lower8";
|
|
|
|
case Master:
|
|
|
|
return "Master";
|
|
|
|
case Convert:
|
|
|
|
return "Convert";
|
|
|
|
case DoubleLoop:
|
|
|
|
return "DoubleLoop";
|
|
|
|
case Quantize:
|
|
|
|
return "Quantize";
|
|
|
|
case Duplicate:
|
|
|
|
return "Duplicate";
|
|
|
|
case New:
|
|
|
|
return "New";
|
|
|
|
case FixedLength:
|
|
|
|
return "FixedLength";
|
|
|
|
case Automate:
|
|
|
|
return "Automate";
|
|
|
|
case RecordEnable:
|
|
|
|
return "RecordEnable";
|
|
|
|
case Play:
|
|
|
|
return "Play";
|
|
|
|
case Fwd32ndT:
|
|
|
|
return "Fwd32ndT";
|
|
|
|
case Fwd32nd:
|
|
|
|
return "Fwd32nd";
|
|
|
|
case Fwd16thT:
|
|
|
|
return "Fwd16thT";
|
|
|
|
case Fwd16th:
|
|
|
|
return "Fwd16th";
|
|
|
|
case Fwd8thT:
|
|
|
|
return "Fwd8thT";
|
|
|
|
case Fwd8th:
|
|
|
|
return "Fwd8th";
|
|
|
|
case Fwd4trT:
|
|
|
|
return "Fwd4trT";
|
|
|
|
case Fwd4tr:
|
|
|
|
return "Fwd4tr";
|
|
|
|
case Up:
|
|
|
|
return "Up";
|
|
|
|
case Right:
|
|
|
|
return "Right";
|
|
|
|
case Down:
|
|
|
|
return "Down";
|
|
|
|
case Left:
|
|
|
|
return "Left";
|
|
|
|
case Repeat:
|
|
|
|
return "Repeat";
|
|
|
|
case Accent:
|
|
|
|
return "Accent";
|
|
|
|
case Scale:
|
|
|
|
return "Scale";
|
|
|
|
case Layout:
|
|
|
|
return "Layout";
|
|
|
|
case Note:
|
|
|
|
return "Note";
|
|
|
|
case Session:
|
|
|
|
return "Session";
|
|
|
|
case OctaveUp:
|
|
|
|
return "OctaveUp";
|
|
|
|
case PageRight:
|
|
|
|
return "PageRight";
|
|
|
|
case OctaveDown:
|
|
|
|
return "OctaveDown";
|
|
|
|
case PageLeft:
|
|
|
|
return "PageLeft";
|
|
|
|
case Shift:
|
|
|
|
return "Shift";
|
|
|
|
case Select:
|
|
|
|
return "Select";
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return "???";
|
|
|
|
}
|
|
|
|
|
2016-06-16 14:06:16 -04:00
|
|
|
void
|
|
|
|
Push2::button_play ()
|
|
|
|
{
|
2016-06-17 15:51:16 -04:00
|
|
|
if (!session) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-07-10 10:49:39 -04:00
|
|
|
if (_modifier_state & ModShift) {
|
2016-06-17 15:51:16 -04:00
|
|
|
goto_start (session->transport_rolling());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-09-28 12:28:38 -04:00
|
|
|
if (_modifier_state & ModSelect) {
|
|
|
|
if (in_range_select) {
|
|
|
|
in_range_select = true;
|
2017-01-28 12:35:04 -05:00
|
|
|
access_action ("Common/start-range-from-playhead");
|
2016-09-28 12:28:38 -04:00
|
|
|
} else {
|
2017-01-28 12:35:04 -05:00
|
|
|
access_action ("Common/finish-range-from-playhead");
|
2016-09-28 12:28:38 -04:00
|
|
|
in_range_select = false;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-06-16 14:06:16 -04:00
|
|
|
if (session->transport_rolling ()) {
|
|
|
|
transport_stop ();
|
|
|
|
} else {
|
|
|
|
transport_play ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Push2::button_recenable ()
|
|
|
|
{
|
|
|
|
rec_enable_toggle ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Push2::button_up ()
|
|
|
|
{
|
2016-09-21 16:25:44 -04:00
|
|
|
_current_layout->button_up ();
|
2016-06-16 14:06:16 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Push2::button_down ()
|
|
|
|
{
|
2016-09-21 16:25:44 -04:00
|
|
|
_current_layout->button_down ();
|
2016-06-16 14:06:16 -04:00
|
|
|
}
|
2016-06-16 17:45:41 -04:00
|
|
|
|
|
|
|
void
|
2016-06-17 18:54:13 -04:00
|
|
|
Push2::button_page_right ()
|
2016-06-16 17:45:41 -04:00
|
|
|
{
|
|
|
|
ScrollTimeline (0.75);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-06-17 18:54:13 -04:00
|
|
|
Push2::button_page_left ()
|
2016-06-16 17:45:41 -04:00
|
|
|
{
|
|
|
|
ScrollTimeline (-0.75);
|
|
|
|
}
|
|
|
|
|
2016-06-17 18:54:13 -04:00
|
|
|
void
|
|
|
|
Push2::button_right ()
|
|
|
|
{
|
2016-07-10 10:49:39 -04:00
|
|
|
_current_layout->button_right ();
|
2016-06-17 18:54:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Push2::button_left ()
|
|
|
|
{
|
2016-07-10 10:49:39 -04:00
|
|
|
_current_layout->button_left ();
|
2016-06-17 18:54:13 -04:00
|
|
|
}
|
|
|
|
|
2016-06-16 17:45:41 -04:00
|
|
|
void
|
|
|
|
Push2::button_repeat ()
|
|
|
|
{
|
|
|
|
loop_toggle ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Push2::button_metronome ()
|
|
|
|
{
|
|
|
|
toggle_click ();
|
|
|
|
}
|
2016-06-16 23:31:51 -04:00
|
|
|
|
|
|
|
void
|
2016-07-11 13:13:04 -04:00
|
|
|
Push2::button_solo_long_press ()
|
2016-06-16 23:31:51 -04:00
|
|
|
{
|
|
|
|
cancel_all_solo ();
|
|
|
|
}
|
2016-06-17 00:15:55 -04:00
|
|
|
|
2016-07-11 13:13:04 -04:00
|
|
|
void
|
|
|
|
Push2::button_mute ()
|
|
|
|
{
|
|
|
|
if (_current_layout) {
|
|
|
|
_current_layout->button_mute ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Push2::button_solo ()
|
|
|
|
{
|
|
|
|
if (_current_layout) {
|
|
|
|
_current_layout->button_solo ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-17 00:15:55 -04:00
|
|
|
void
|
|
|
|
Push2::button_new ()
|
|
|
|
{
|
2017-01-28 12:35:04 -05:00
|
|
|
access_action ("Common/start-range-from-playhead");
|
2016-06-17 00:15:55 -04:00
|
|
|
|
|
|
|
id_button_map[New]->set_color (LED::White);
|
|
|
|
id_button_map[New]->set_state (LED::NoTransition);
|
|
|
|
write (id_button_map[New]->state_msg());
|
|
|
|
|
|
|
|
/* blink the button for the other half of this operation */
|
|
|
|
|
|
|
|
id_button_map[FixedLength]->set_color (LED::White);
|
|
|
|
id_button_map[FixedLength]->set_state (LED::Blinking4th);
|
|
|
|
write (id_button_map[FixedLength]->state_msg());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
Push2::button_fixed_length ()
|
|
|
|
{
|
2017-01-28 12:35:04 -05:00
|
|
|
access_action ("Common/finish-range-from-playhead");
|
2016-06-17 00:15:55 -04:00
|
|
|
|
|
|
|
/* turn off both buttons for this operation */
|
|
|
|
|
|
|
|
id_button_map[New]->set_color (LED::Black);
|
|
|
|
id_button_map[New]->set_state (LED::NoTransition);
|
|
|
|
write (id_button_map[New]->state_msg());
|
|
|
|
id_button_map[FixedLength]->set_color (LED::Black);
|
|
|
|
id_button_map[FixedLength]->set_state (LED::NoTransition);
|
|
|
|
write (id_button_map[FixedLength]->state_msg());
|
|
|
|
}
|
2016-06-17 00:32:06 -04:00
|
|
|
|
2016-06-17 01:29:00 -04:00
|
|
|
void
|
|
|
|
Push2::button_browse ()
|
|
|
|
{
|
2017-01-28 13:16:24 -05:00
|
|
|
access_action ("Common/addExistingAudioFiles");
|
2016-06-17 01:29:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Push2::button_clip ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Push2::button_upper (uint32_t n)
|
|
|
|
{
|
2016-07-10 10:49:39 -04:00
|
|
|
_current_layout->button_upper (n);
|
2016-06-17 01:29:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Push2::button_lower (uint32_t n)
|
|
|
|
{
|
2016-07-10 10:49:39 -04:00
|
|
|
_current_layout->button_lower (n);
|
2016-06-17 01:29:00 -04:00
|
|
|
}
|
2016-06-17 01:59:01 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
Push2::button_undo ()
|
|
|
|
{
|
2016-07-10 10:49:39 -04:00
|
|
|
if (_modifier_state & ModShift) {
|
2016-06-17 01:59:01 -04:00
|
|
|
ControlProtocol::Redo ();
|
|
|
|
} else {
|
|
|
|
ControlProtocol::Undo ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Push2::button_fwd32t ()
|
|
|
|
{
|
2016-07-10 10:49:39 -04:00
|
|
|
const int n = (_modifier_state & ModShift) ? 8 : 0;
|
2016-06-17 01:59:01 -04:00
|
|
|
goto_nth_marker (0+n);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Push2::button_fwd32 ()
|
|
|
|
{
|
2016-07-10 10:49:39 -04:00
|
|
|
const int n = (_modifier_state & ModShift) ? 8 : 0;
|
2016-06-17 01:59:01 -04:00
|
|
|
goto_nth_marker (1+n);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Push2::button_fwd16t ()
|
|
|
|
{
|
2016-07-10 10:49:39 -04:00
|
|
|
const int n = (_modifier_state & ModShift) ? 8 : 0;
|
2016-06-17 01:59:01 -04:00
|
|
|
goto_nth_marker (2+n);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Push2::button_fwd16 ()
|
|
|
|
{
|
2016-07-10 10:49:39 -04:00
|
|
|
const int n = (_modifier_state & ModShift) ? 8 : 0;
|
2016-06-17 01:59:01 -04:00
|
|
|
goto_nth_marker (3+n);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Push2::button_fwd8t ()
|
|
|
|
{
|
2016-07-10 10:49:39 -04:00
|
|
|
const int n = (_modifier_state & ModShift) ? 8 : 0;
|
2016-06-17 01:59:01 -04:00
|
|
|
goto_nth_marker (4+n);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Push2::button_fwd8 ()
|
|
|
|
{
|
2016-07-10 10:49:39 -04:00
|
|
|
const int n = (_modifier_state & ModShift) ? 8 : 0;
|
2016-06-17 01:59:01 -04:00
|
|
|
goto_nth_marker (5+n);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Push2::button_fwd4t ()
|
|
|
|
{
|
2016-07-10 10:49:39 -04:00
|
|
|
const int n = (_modifier_state & ModShift) ? 8 : 0;
|
2016-06-17 01:59:01 -04:00
|
|
|
goto_nth_marker (6+n);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Push2::button_fwd4 ()
|
|
|
|
{
|
2016-07-10 10:49:39 -04:00
|
|
|
const int n = (_modifier_state & ModShift) ? 8 : 0;
|
2016-06-17 01:59:01 -04:00
|
|
|
goto_nth_marker (7+n);
|
|
|
|
}
|
|
|
|
|
2016-06-17 15:51:16 -04:00
|
|
|
void
|
|
|
|
Push2::button_add_track ()
|
|
|
|
{
|
|
|
|
access_action ("Main/AddTrackBus");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Push2::button_stop ()
|
|
|
|
{
|
|
|
|
/* close current window */
|
|
|
|
access_action ("Main/close-current-dialog");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Push2::button_shift_press ()
|
|
|
|
{
|
|
|
|
start_shift ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Push2::button_shift_release ()
|
|
|
|
{
|
|
|
|
end_shift ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Push2::button_shift_long_press ()
|
|
|
|
{
|
|
|
|
access_action ("Main/close-current-dialog");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Push2::button_select_press ()
|
|
|
|
{
|
2016-07-10 10:49:39 -04:00
|
|
|
cerr << "start select\n";
|
|
|
|
_modifier_state = ModifierState (_modifier_state | ModSelect);
|
2018-09-02 13:23:36 -04:00
|
|
|
boost::shared_ptr<Button> b = id_button_map[Select];
|
2016-07-10 10:49:39 -04:00
|
|
|
b->set_color (Push2::LED::White);
|
|
|
|
b->set_state (Push2::LED::Blinking16th);
|
|
|
|
write (b->state_msg());
|
|
|
|
|
|
|
|
_current_layout->button_select_press ();
|
2016-06-17 15:51:16 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Push2::button_select_release ()
|
|
|
|
{
|
2016-07-10 10:49:39 -04:00
|
|
|
if (_modifier_state & ModSelect) {
|
|
|
|
cerr << "end select\n";
|
|
|
|
_modifier_state = ModifierState (_modifier_state & ~(ModSelect));
|
2018-09-02 13:23:36 -04:00
|
|
|
boost::shared_ptr<Button> b = id_button_map[Select];
|
2016-07-10 10:49:39 -04:00
|
|
|
b->timeout_connection.disconnect ();
|
|
|
|
b->set_color (Push2::LED::White);
|
|
|
|
b->set_state (Push2::LED::OneShot24th);
|
|
|
|
write (b->state_msg());
|
2016-06-17 15:51:16 -04:00
|
|
|
}
|
|
|
|
|
2016-07-10 10:49:39 -04:00
|
|
|
_current_layout->button_select_release ();
|
2016-06-17 15:51:16 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Push2::button_select_long_press ()
|
|
|
|
{
|
|
|
|
access_action ("Main/Escape");
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Push2::button_long_press_timeout (ButtonID id)
|
|
|
|
{
|
|
|
|
if (buttons_down.find (id) != buttons_down.end()) {
|
|
|
|
DEBUG_TRACE (DEBUG::Push2, string_compose ("long press timeout for %1, invoking method\n", id));
|
2018-09-02 13:23:36 -04:00
|
|
|
boost::shared_ptr<Button> button = id_button_map[id];
|
2016-06-17 15:51:16 -04:00
|
|
|
(this->*button->long_press_method) ();
|
|
|
|
} else {
|
|
|
|
DEBUG_TRACE (DEBUG::Push2, string_compose ("long press timeout for %1, expired/cancelled\n", id));
|
|
|
|
/* release happened and somehow we were not cancelled */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* whichever button this was, we've used it ... don't invoke the
|
|
|
|
release action.
|
|
|
|
*/
|
|
|
|
consumed.insert (id);
|
|
|
|
|
|
|
|
return false; /* don't get called again */
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-09-02 13:23:36 -04:00
|
|
|
Push2::start_press_timeout (boost::shared_ptr<Button> button, ButtonID id)
|
2016-06-17 15:51:16 -04:00
|
|
|
{
|
2018-09-02 13:23:36 -04:00
|
|
|
assert (button);
|
2016-06-17 15:51:16 -04:00
|
|
|
Glib::RefPtr<Glib::TimeoutSource> timeout = Glib::TimeoutSource::create (500); // milliseconds
|
2018-09-02 13:23:36 -04:00
|
|
|
button->timeout_connection = timeout->connect (sigc::bind (sigc::mem_fun (*this, &Push2::button_long_press_timeout), id));
|
2016-06-17 15:51:16 -04:00
|
|
|
timeout->attach (main_loop()->get_context());
|
|
|
|
}
|
2016-07-06 23:49:07 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
Push2::button_octave_down ()
|
|
|
|
{
|
2016-07-10 11:29:57 -04:00
|
|
|
if (_modifier_state & ModShift) {
|
|
|
|
octave_shift = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-06-17 18:48:58 -04:00
|
|
|
int os = (std::max (-4, octave_shift - 1));
|
2016-07-07 00:10:27 -04:00
|
|
|
if (os != octave_shift) {
|
|
|
|
octave_shift = os;
|
|
|
|
}
|
2016-07-06 23:49:07 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Push2::button_octave_up ()
|
|
|
|
{
|
2016-07-10 11:29:57 -04:00
|
|
|
if (_modifier_state & ModShift) {
|
|
|
|
octave_shift = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-06-17 18:48:58 -04:00
|
|
|
int os = (std::min (4, octave_shift + 1));
|
2016-07-07 00:10:27 -04:00
|
|
|
if (os != octave_shift) {
|
|
|
|
octave_shift = os;
|
|
|
|
}
|
2016-07-06 23:49:07 -04:00
|
|
|
}
|
2016-07-10 08:37:45 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
Push2::button_layout_press ()
|
|
|
|
{
|
|
|
|
if (percussion) {
|
|
|
|
set_percussive_mode (false);
|
|
|
|
} else {
|
|
|
|
set_percussive_mode (true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Push2::button_scale_press ()
|
|
|
|
{
|
2016-07-10 10:49:39 -04:00
|
|
|
if (_current_layout != scale_layout) {
|
2016-09-21 16:25:44 -04:00
|
|
|
set_current_layout (scale_layout);
|
2016-07-10 08:37:45 -04:00
|
|
|
} else {
|
2016-09-21 16:25:44 -04:00
|
|
|
if (ControlProtocol::first_selected_stripable()) {
|
|
|
|
set_current_layout (mix_layout);
|
|
|
|
}
|
2016-07-10 08:37:45 -04:00
|
|
|
}
|
|
|
|
}
|
2016-07-10 13:02:42 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
Push2::button_mix_press ()
|
|
|
|
{
|
|
|
|
if (_current_layout == track_mix_layout) {
|
2016-07-11 13:13:04 -04:00
|
|
|
set_current_layout (mix_layout);
|
2016-07-10 13:02:42 -04:00
|
|
|
} else {
|
|
|
|
if (ControlProtocol::first_selected_stripable()) {
|
2016-07-11 13:13:04 -04:00
|
|
|
set_current_layout (track_mix_layout);
|
2016-07-10 13:02:42 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-09-19 17:11:22 -04:00
|
|
|
|
2016-09-22 15:41:49 -04:00
|
|
|
void
|
|
|
|
Push2::button_master ()
|
|
|
|
{
|
2016-09-27 15:30:43 -04:00
|
|
|
boost::shared_ptr<Stripable> main_out = session->master_out ();
|
2016-09-22 15:41:49 -04:00
|
|
|
|
2016-09-27 15:30:43 -04:00
|
|
|
if (!main_out) {
|
2016-09-22 15:41:49 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_current_layout != track_mix_layout) {
|
2016-09-27 15:30:43 -04:00
|
|
|
ControlProtocol::SetStripableSelection (main_out);
|
2016-09-22 15:41:49 -04:00
|
|
|
set_current_layout (track_mix_layout);
|
2016-09-25 20:10:26 -04:00
|
|
|
} else {
|
2016-09-27 15:30:43 -04:00
|
|
|
TrackMixLayout* tml = dynamic_cast<TrackMixLayout*> (_current_layout);
|
|
|
|
if (tml->current_stripable() == main_out) {
|
|
|
|
/* back to previous layout */
|
|
|
|
set_current_layout (_previous_layout);
|
|
|
|
} else {
|
|
|
|
ControlProtocol::SetStripableSelection (main_out);
|
|
|
|
}
|
2016-09-22 15:41:49 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-22 17:28:25 -04:00
|
|
|
void
|
|
|
|
Push2::button_quantize ()
|
2016-09-19 17:11:22 -04:00
|
|
|
{
|
2016-09-22 17:28:25 -04:00
|
|
|
access_action ("Editor/quantize");
|
|
|
|
}
|
2016-09-19 17:11:22 -04:00
|
|
|
|
2016-09-22 17:28:25 -04:00
|
|
|
void
|
|
|
|
Push2::button_duplicate ()
|
|
|
|
{
|
|
|
|
access_action ("Editor/duplicate-range");
|
2016-09-19 17:11:22 -04:00
|
|
|
}
|