2015-11-24 15:17:25 -05:00
|
|
|
/*
|
|
|
|
Copyright (C) 2006 Paul Davis
|
|
|
|
|
|
|
|
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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
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;
|
|
|
|
class ControllableDescriptor;
|
|
|
|
}
|
|
|
|
|
|
|
|
#include <midi++/types.h>
|
|
|
|
|
|
|
|
//#include "pbd/signals.h"
|
|
|
|
|
|
|
|
|
|
|
|
//#include "midi_byte_array.h"
|
|
|
|
#include "types.h"
|
|
|
|
|
|
|
|
#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 {
|
|
|
|
|
2015-11-24 21:41:44 -05:00
|
|
|
struct FaderPortRequest : public BaseUI::BaseRequestObject {
|
|
|
|
public:
|
|
|
|
FaderPortRequest () {}
|
|
|
|
~FaderPortRequest () {}
|
|
|
|
};
|
|
|
|
|
|
|
|
class FaderPort : public ARDOUR::ControlProtocol, public AbstractUI<FaderPortRequest> {
|
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
|
|
|
|
2015-11-25 13:36:52 -05:00
|
|
|
/* we probe for a device when our ports are connected. Before that,
|
|
|
|
there's no way to know if the device exists or not.
|
2015-11-24 18:00:11 -05:00
|
|
|
*/
|
|
|
|
static bool probe() { return true; }
|
2015-12-28 10:14:17 -05:00
|
|
|
static void* request_factory (uint32_t);
|
2015-11-24 15:17:25 -05:00
|
|
|
|
|
|
|
XMLNode& get_state ();
|
|
|
|
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-24 21:41:44 -05:00
|
|
|
void do_request (FaderPortRequest*);
|
|
|
|
int stop ();
|
|
|
|
|
|
|
|
void thread_init ();
|
|
|
|
|
2015-11-29 11:32:28 -05:00
|
|
|
PBD::Signal0<void> ConnectionChange;
|
|
|
|
|
|
|
|
boost::shared_ptr<ARDOUR::Port> input_port();
|
|
|
|
boost::shared_ptr<ARDOUR::Port> output_port();
|
|
|
|
|
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,
|
|
|
|
UserDown = 0x8,
|
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
|
|
|
|
2015-12-03 12:44:21 -05:00
|
|
|
std::list<boost::shared_ptr<ARDOUR::Bundle> > bundles ();
|
2015-12-28 10:14:17 -05:00
|
|
|
|
2015-11-24 15:17:25 -05:00
|
|
|
private:
|
2016-05-17 11:42:31 -04:00
|
|
|
boost::shared_ptr<ARDOUR::Stripable> _current_stripable;
|
|
|
|
boost::weak_ptr<ARDOUR::Stripable> pre_master_stripable;
|
|
|
|
boost::weak_ptr<ARDOUR::Stripable> pre_monitor_stripable;
|
2015-11-25 16:47:20 -05:00
|
|
|
|
2015-11-24 18:00:11 -05:00
|
|
|
boost::shared_ptr<ARDOUR::AsyncMIDIPort> _input_port;
|
|
|
|
boost::shared_ptr<ARDOUR::AsyncMIDIPort> _output_port;
|
2015-11-24 15:17:25 -05:00
|
|
|
|
2015-12-03 12:44:21 -05:00
|
|
|
// Bundle to represent our input ports
|
|
|
|
boost::shared_ptr<ARDOUR::Bundle> _input_bundle;
|
|
|
|
// Bundle to represent our output ports
|
|
|
|
boost::shared_ptr<ARDOUR::Bundle> _output_bundle;
|
|
|
|
|
2015-11-24 18:00:11 -05:00
|
|
|
PBD::ScopedConnectionList midi_connections;
|
2015-11-24 15:17:25 -05:00
|
|
|
|
2015-11-24 18:00:11 -05:00
|
|
|
bool midi_input_handler (Glib::IOCondition ioc, boost::shared_ptr<ARDOUR::AsyncMIDIPort> port);
|
2015-11-24 15:17:25 -05:00
|
|
|
|
|
|
|
mutable void *gui;
|
|
|
|
void build_gui ();
|
2015-11-24 18:00:11 -05:00
|
|
|
|
|
|
|
bool connection_handler (boost::weak_ptr<ARDOUR::Port>, std::string name1, boost::weak_ptr<ARDOUR::Port>, std::string name2, bool yn);
|
|
|
|
PBD::ScopedConnection port_connection;
|
|
|
|
|
|
|
|
enum ConnectionState {
|
|
|
|
InputConnected = 0x1,
|
|
|
|
OutputConnected = 0x2
|
|
|
|
};
|
|
|
|
|
|
|
|
int connection_state;
|
|
|
|
void connected ();
|
|
|
|
bool _device_active;
|
|
|
|
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
|
|
|
|
2015-11-25 15:52:58 -05:00
|
|
|
ARDOUR::microseconds_t last_encoder_time;
|
|
|
|
int last_good_encoder_delta;
|
|
|
|
int last_encoder_delta, last_last_encoder_delta;
|
|
|
|
|
2015-11-24 18:00:11 -05:00
|
|
|
void sysex_handler (MIDI::Parser &p, MIDI::byte *, size_t);
|
2015-11-30 12:51:18 -05:00
|
|
|
void button_handler (MIDI::Parser &, MIDI::EventTwoBytes* tb);
|
2015-11-24 18:00:11 -05:00
|
|
|
void encoder_handler (MIDI::Parser &, MIDI::pitchbend_t pb);
|
|
|
|
void fader_handler (MIDI::Parser &, MIDI::EventTwoBytes* tb);
|
|
|
|
|
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));
|
|
|
|
void set_action (boost::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));
|
|
|
|
|
2015-12-08 11:07:37 -05:00
|
|
|
void set_led_state (boost::shared_ptr<MIDI::Port>, bool onoff);
|
2015-11-24 21:02:18 -05:00
|
|
|
void 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;
|
|
|
|
/* could be a union if boost::function didn't require a
|
|
|
|
* constructor
|
|
|
|
*/
|
2015-11-24 21:02:18 -05:00
|
|
|
std::string action_name;
|
|
|
|
boost::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 21:41:44 -05:00
|
|
|
void close ();
|
|
|
|
void start_midi_handling ();
|
|
|
|
void stop_midi_handling ();
|
2015-11-24 22:32:40 -05:00
|
|
|
|
2015-11-24 23:06:19 -05:00
|
|
|
PBD::ScopedConnectionList session_connections;
|
|
|
|
void connect_session_signals ();
|
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
|
|
|
|
2016-05-17 11:42:31 -04:00
|
|
|
void set_current_stripable (boost::shared_ptr<ARDOUR::Stripable>);
|
|
|
|
void drop_current_stripable ();
|
2015-11-25 16:34:11 -05:00
|
|
|
void use_master ();
|
|
|
|
void use_monitor ();
|
2016-05-17 11:42:31 -04:00
|
|
|
void gui_track_selection_changed (ARDOUR::StripableNotificationListPtr);
|
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
|
|
|
|
2015-11-27 16:41:26 -05:00
|
|
|
void ardour_pan_azimuth (int);
|
|
|
|
void ardour_pan_width (int);
|
2015-11-27 16:34:01 -05:00
|
|
|
void mixbus_pan (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 */
|