2015-11-24 15:17:25 -05:00
|
|
|
/*
|
2019-08-03 08:34:29 -04:00
|
|
|
* Copyright (C) 2015-2018 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
* Copyright (C) 2015 Ben Loftis <ben@harrisonconsoles.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.
|
|
|
|
*/
|
2015-11-24 15:17:25 -05:00
|
|
|
|
2015-11-24 18:00:11 -05:00
|
|
|
#ifndef ardour_surface_faderport_h
|
|
|
|
#define ardour_surface_faderport_h
|
2015-11-24 15:17:25 -05:00
|
|
|
|
|
|
|
#include <list>
|
2015-11-24 18:20:07 -05:00
|
|
|
#include <map>
|
2015-12-01 13:15:38 -05:00
|
|
|
#include <set>
|
2015-11-24 15:17:25 -05:00
|
|
|
#include <glibmm/threads.h>
|
|
|
|
|
2015-11-24 21:41:44 -05:00
|
|
|
#define ABSTRACT_UI_EXPORTS
|
|
|
|
#include "pbd/abstract_ui.h"
|
|
|
|
|
2015-11-24 15:17:25 -05:00
|
|
|
#include "ardour/types.h"
|
|
|
|
|
|
|
|
#include "control_protocol/control_protocol.h"
|
|
|
|
|
|
|
|
namespace PBD {
|
|
|
|
class Controllable;
|
|
|
|
}
|
|
|
|
|
|
|
|
#include <midi++/types.h>
|
|
|
|
|
2022-10-20 13:34:26 -04:00
|
|
|
#include "midi_surface/midi_byte_array.h"
|
|
|
|
#include "midi_surface/midi_surface.h"
|
2015-11-24 15:17:25 -05:00
|
|
|
|
|
|
|
#include "glibmm/main.h"
|
|
|
|
|
|
|
|
namespace MIDI {
|
|
|
|
class Parser;
|
|
|
|
class Port;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
namespace ARDOUR {
|
|
|
|
class AsyncMIDIPort;
|
2015-12-03 12:44:21 -05:00
|
|
|
class Bundle;
|
2015-11-24 15:17:25 -05:00
|
|
|
class Port;
|
|
|
|
class Session;
|
|
|
|
class MidiPort;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class MIDIControllable;
|
|
|
|
class MIDIFunction;
|
|
|
|
class MIDIAction;
|
|
|
|
|
2015-11-24 20:12:01 -05:00
|
|
|
namespace ArdourSurface {
|
|
|
|
|
2022-10-20 13:34:26 -04:00
|
|
|
class FaderPort : public MIDISurface {
|
2015-11-24 15:17:25 -05:00
|
|
|
public:
|
2015-11-24 18:00:11 -05:00
|
|
|
FaderPort (ARDOUR::Session&);
|
|
|
|
virtual ~FaderPort();
|
2015-11-24 15:17:25 -05:00
|
|
|
|
|
|
|
int set_active (bool yn);
|
2015-11-24 18:00:11 -05:00
|
|
|
|
2022-10-20 13:34:26 -04:00
|
|
|
std::string input_port_name () const;
|
|
|
|
std::string output_port_name () const;
|
2015-11-24 15:17:25 -05:00
|
|
|
|
2022-04-06 23:56:32 -04:00
|
|
|
XMLNode& get_state () const;
|
2015-11-24 15:17:25 -05:00
|
|
|
int set_state (const XMLNode&, int version);
|
|
|
|
|
|
|
|
bool has_editor () const { return true; }
|
|
|
|
void* get_gui () const;
|
|
|
|
void tear_down_gui ();
|
|
|
|
|
2015-11-25 13:36:52 -05:00
|
|
|
/* Note: because the FaderPort speaks an inherently duplex protocol,
|
|
|
|
we do not implement get/set_feedback() since this aspect of
|
|
|
|
support for the protocol is not optional.
|
|
|
|
*/
|
2015-11-24 18:00:11 -05:00
|
|
|
|
2015-11-29 11:58:31 -05:00
|
|
|
/* In a feat of engineering brilliance, the Presonus Faderport sends
|
|
|
|
* one button identifier when the button is pressed/released, but
|
|
|
|
* responds to another button identifier as a command to light the LED
|
|
|
|
* corresponding to the button. These ID's define what is sent
|
|
|
|
* for press/release; a separate data structure contains information
|
|
|
|
* on what to send to turn the LED on/off.
|
|
|
|
*
|
|
|
|
* One can only conclude that Presonus just didn't want to fix this
|
|
|
|
* issue because it contradicts their own documentation and is more or
|
|
|
|
* less the first thing you discover when programming the device.
|
|
|
|
*/
|
|
|
|
|
2015-11-29 11:32:28 -05:00
|
|
|
enum ButtonID {
|
|
|
|
Mute = 18,
|
|
|
|
Solo = 17,
|
|
|
|
Rec = 16,
|
|
|
|
Left = 19,
|
|
|
|
Bank = 20,
|
|
|
|
Right = 21,
|
|
|
|
Output = 22,
|
|
|
|
FP_Read = 10,
|
|
|
|
FP_Write = 9,
|
|
|
|
FP_Touch = 8,
|
|
|
|
FP_Off = 23,
|
|
|
|
Mix = 11,
|
|
|
|
Proj = 12,
|
|
|
|
Trns = 13,
|
|
|
|
Undo = 14,
|
|
|
|
Shift = 2,
|
|
|
|
Punch = 1,
|
|
|
|
User = 0,
|
|
|
|
Loop = 15,
|
|
|
|
Rewind = 3,
|
|
|
|
Ffwd = 4,
|
|
|
|
Stop = 5,
|
|
|
|
Play = 6,
|
|
|
|
RecEnable = 7,
|
2016-01-25 14:32:09 -05:00
|
|
|
Footswitch = 126,
|
2015-11-29 11:32:28 -05:00
|
|
|
FaderTouch = 127,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ButtonState {
|
|
|
|
ShiftDown = 0x1,
|
|
|
|
RewindDown = 0x2,
|
|
|
|
StopDown = 0x4,
|
2024-07-23 20:20:51 -04:00
|
|
|
/* gap when we removed UserMode as a modifier */
|
2015-12-01 09:23:02 -05:00
|
|
|
LongPress = 0x10
|
2015-11-29 11:32:28 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
void set_action (ButtonID, std::string const& action_name, bool on_press, FaderPort::ButtonState = ButtonState (0));
|
2015-11-30 13:50:33 -05:00
|
|
|
std::string get_action (ButtonID, bool on_press, FaderPort::ButtonState = ButtonState (0));
|
2015-11-29 11:32:28 -05:00
|
|
|
|
2023-09-14 14:14:55 -04:00
|
|
|
void notify_record_state_changed ();
|
|
|
|
void notify_transport_state_changed ();
|
|
|
|
void notify_loop_state_changed ();
|
|
|
|
|
2015-11-24 15:17:25 -05:00
|
|
|
private:
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<ARDOUR::Stripable> _current_stripable;
|
|
|
|
std::weak_ptr<ARDOUR::Stripable> pre_master_stripable;
|
|
|
|
std::weak_ptr<ARDOUR::Stripable> pre_monitor_stripable;
|
2015-11-25 16:47:20 -05:00
|
|
|
|
2015-11-24 15:17:25 -05:00
|
|
|
mutable void *gui;
|
|
|
|
void build_gui ();
|
2015-11-24 18:00:11 -05:00
|
|
|
|
|
|
|
void connected ();
|
|
|
|
int fader_msb;
|
|
|
|
int fader_lsb;
|
2015-11-25 13:22:35 -05:00
|
|
|
bool fader_is_touched;
|
2015-11-24 18:00:11 -05:00
|
|
|
|
2021-06-27 11:32:12 -04:00
|
|
|
PBD::microseconds_t last_encoder_time;
|
2015-11-25 15:52:58 -05:00
|
|
|
int last_good_encoder_delta;
|
|
|
|
int last_encoder_delta, last_last_encoder_delta;
|
|
|
|
|
2022-10-20 13:34:26 -04:00
|
|
|
void handle_midi_sysex (MIDI::Parser &p, MIDI::byte *, size_t);
|
|
|
|
void handle_midi_polypressure_message (MIDI::Parser &, MIDI::EventTwoBytes* tb);
|
|
|
|
void handle_midi_pitchbend_message (MIDI::Parser &, MIDI::pitchbend_t pb);
|
|
|
|
void handle_midi_controller_message (MIDI::Parser &, MIDI::EventTwoBytes* tb);
|
|
|
|
|
|
|
|
int begin_using_device ();
|
|
|
|
int stop_using_device ();
|
|
|
|
int device_acquire () { return 0; }
|
2023-09-14 14:14:55 -04:00
|
|
|
void device_release () { }
|
|
|
|
void run_event_loop ();
|
|
|
|
void stop_event_loop ();
|
2015-11-24 18:00:11 -05:00
|
|
|
|
2015-11-24 21:02:18 -05:00
|
|
|
ButtonState button_state;
|
|
|
|
|
2015-11-30 12:51:18 -05:00
|
|
|
friend class Button;
|
2015-11-24 21:02:18 -05:00
|
|
|
|
2015-11-30 12:51:18 -05:00
|
|
|
class Button {
|
2015-11-24 21:02:18 -05:00
|
|
|
public:
|
|
|
|
|
|
|
|
enum ActionType {
|
|
|
|
NamedAction,
|
|
|
|
InternalFunction,
|
|
|
|
};
|
|
|
|
|
2015-11-30 12:51:18 -05:00
|
|
|
Button (FaderPort& f, std::string const& str, ButtonID i, int o)
|
2015-11-24 21:02:18 -05:00
|
|
|
: fp (f)
|
|
|
|
, name (str)
|
|
|
|
, id (i)
|
|
|
|
, out (o)
|
2015-11-24 21:41:44 -05:00
|
|
|
, flash (false)
|
2015-11-24 21:02:18 -05:00
|
|
|
{}
|
|
|
|
|
2015-11-24 22:32:40 -05:00
|
|
|
void set_action (std::string const& action_name, bool on_press, FaderPort::ButtonState = ButtonState (0));
|
2024-10-18 19:51:44 -04:00
|
|
|
void set_action (std::function<void()> function, bool on_press, FaderPort::ButtonState = ButtonState (0));
|
2015-11-30 13:50:33 -05:00
|
|
|
std::string get_action (bool press, FaderPort::ButtonState bs = ButtonState (0));
|
|
|
|
|
2022-10-20 13:34:26 -04:00
|
|
|
void set_led_state (bool onoff);
|
2018-03-26 18:26:39 -04:00
|
|
|
bool invoke (ButtonState bs, bool press);
|
2015-11-24 21:41:44 -05:00
|
|
|
bool uses_flash () const { return flash; }
|
|
|
|
void set_flash (bool yn) { flash = yn; }
|
2015-11-30 12:51:18 -05:00
|
|
|
|
|
|
|
XMLNode& get_state () const;
|
|
|
|
int set_state (XMLNode const&);
|
2015-11-24 21:02:18 -05:00
|
|
|
|
2015-12-01 13:15:38 -05:00
|
|
|
sigc::connection timeout_connection;
|
|
|
|
|
2015-11-24 21:02:18 -05:00
|
|
|
private:
|
|
|
|
FaderPort& fp;
|
2015-11-24 18:20:07 -05:00
|
|
|
std::string name;
|
2015-11-24 21:02:18 -05:00
|
|
|
ButtonID id;
|
2015-11-24 18:20:07 -05:00
|
|
|
int out;
|
2015-11-24 21:41:44 -05:00
|
|
|
bool flash;
|
2015-11-24 21:02:18 -05:00
|
|
|
|
2015-11-24 22:32:40 -05:00
|
|
|
struct ToDo {
|
2015-11-30 12:51:18 -05:00
|
|
|
ActionType type;
|
2024-10-18 19:51:44 -04:00
|
|
|
/* could be a union if std::function didn't require a
|
2015-11-30 12:51:18 -05:00
|
|
|
* constructor
|
|
|
|
*/
|
2015-11-24 21:02:18 -05:00
|
|
|
std::string action_name;
|
2024-10-18 19:51:44 -04:00
|
|
|
std::function<void()> function;
|
2015-11-24 22:32:40 -05:00
|
|
|
};
|
2015-11-24 21:02:18 -05:00
|
|
|
|
2015-11-24 22:32:40 -05:00
|
|
|
typedef std::map<FaderPort::ButtonState,ToDo> ToDoMap;
|
|
|
|
ToDoMap on_press;
|
|
|
|
ToDoMap on_release;
|
2015-11-24 18:00:11 -05:00
|
|
|
};
|
2015-11-24 21:02:18 -05:00
|
|
|
|
2015-11-30 12:51:18 -05:00
|
|
|
typedef std::map<ButtonID,Button> ButtonMap;
|
2015-11-24 21:10:22 -05:00
|
|
|
|
|
|
|
ButtonMap buttons;
|
2015-11-30 12:51:18 -05:00
|
|
|
Button& get_button (ButtonID) const;
|
2015-11-24 21:10:22 -05:00
|
|
|
|
2015-12-01 13:15:38 -05:00
|
|
|
std::set<ButtonID> buttons_down;
|
2015-12-03 18:38:09 -05:00
|
|
|
std::set<ButtonID> consumed;
|
2015-12-01 13:15:38 -05:00
|
|
|
|
|
|
|
bool button_long_press_timeout (ButtonID id);
|
|
|
|
void start_press_timeout (Button&, ButtonID);
|
|
|
|
|
2015-11-24 21:10:22 -05:00
|
|
|
void all_lights_out ();
|
2015-11-24 22:32:40 -05:00
|
|
|
|
2015-12-08 11:07:37 -05:00
|
|
|
void map_recenable_state ();
|
|
|
|
void map_transport_state ();
|
2015-11-24 23:06:19 -05:00
|
|
|
|
2015-12-14 13:28:24 -05:00
|
|
|
sigc::connection periodic_connection;
|
|
|
|
bool periodic ();
|
|
|
|
|
2015-11-24 23:06:19 -05:00
|
|
|
sigc::connection blink_connection;
|
|
|
|
typedef std::list<ButtonID> Blinkers;
|
|
|
|
Blinkers blinkers;
|
|
|
|
bool blink_state;
|
|
|
|
bool blink ();
|
2015-12-03 08:36:56 -05:00
|
|
|
void start_blinking (ButtonID);
|
|
|
|
void stop_blinking (ButtonID);
|
2015-11-24 23:06:19 -05:00
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
void set_current_stripable (std::shared_ptr<ARDOUR::Stripable>);
|
2016-05-17 11:42:31 -04:00
|
|
|
void drop_current_stripable ();
|
2015-11-25 16:34:11 -05:00
|
|
|
void use_master ();
|
|
|
|
void use_monitor ();
|
2017-05-12 09:51:31 -04:00
|
|
|
void stripable_selection_changed ();
|
2015-11-25 12:37:29 -05:00
|
|
|
PBD::ScopedConnection selection_connection;
|
2016-05-17 11:42:31 -04:00
|
|
|
PBD::ScopedConnectionList stripable_connections;
|
2015-11-25 12:37:29 -05:00
|
|
|
|
2016-05-17 11:42:31 -04:00
|
|
|
void map_stripable_state ();
|
2016-01-21 11:03:14 -05:00
|
|
|
void map_solo ();
|
|
|
|
void map_mute ();
|
2016-02-02 09:05:00 -05:00
|
|
|
bool rec_enable_state;
|
2015-11-25 12:37:29 -05:00
|
|
|
void map_recenable ();
|
2015-11-25 13:22:35 -05:00
|
|
|
void map_gain ();
|
2015-11-25 17:20:00 -05:00
|
|
|
void map_cut ();
|
2015-12-02 21:06:29 -05:00
|
|
|
void map_auto ();
|
2015-12-01 18:45:43 -05:00
|
|
|
void parameter_changed (std::string);
|
2015-11-25 12:37:29 -05:00
|
|
|
|
2015-11-24 22:32:40 -05:00
|
|
|
/* operations (defined in operations.cc) */
|
|
|
|
|
2015-11-25 18:33:42 -05:00
|
|
|
void read ();
|
|
|
|
void write ();
|
|
|
|
|
|
|
|
void left ();
|
|
|
|
void right ();
|
|
|
|
|
|
|
|
void touch ();
|
|
|
|
void off ();
|
|
|
|
|
2015-11-24 22:32:40 -05:00
|
|
|
void undo ();
|
|
|
|
void redo ();
|
2015-11-25 12:37:29 -05:00
|
|
|
void solo ();
|
|
|
|
void mute ();
|
|
|
|
void rec_enable ();
|
2015-11-27 16:34:01 -05:00
|
|
|
|
2019-09-25 06:03:06 -04:00
|
|
|
void pan_azimuth (int);
|
|
|
|
void pan_width (int);
|
2015-12-01 10:35:30 -05:00
|
|
|
|
|
|
|
void punch ();
|
2015-11-24 15:17:25 -05:00
|
|
|
};
|
|
|
|
|
2015-11-24 20:12:01 -05:00
|
|
|
}
|
|
|
|
|
2015-11-24 18:00:11 -05:00
|
|
|
#endif /* ardour_surface_faderport_h */
|