X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fsurfaces%2Fpush2%2Fpush2.h;h=2d4f17417ef5f0f96b4ac8a8d40494121d00d487;hb=b6e62c66545d84101e3f82d065862f75509f2d1e;hp=4ced88b67f82b56c20e3faed51996bd1c9c3f1b2;hpb=86578ea0cc1daef464953fdb80820d40a8167f78;p=ardour.git diff --git a/libs/surfaces/push2/push2.h b/libs/surfaces/push2/push2.h index 4ced88b67f..2d4f17417e 100644 --- a/libs/surfaces/push2/push2.h +++ b/libs/surfaces/push2/push2.h @@ -21,30 +21,26 @@ #include #include +#include #include #include #include -#include - #define ABSTRACT_UI_EXPORTS #include "pbd/abstract_ui.h" #include "midi++/types.h" +#include "ardour/mode.h" #include "ardour/types.h" #include "control_protocol/control_protocol.h" #include "control_protocol/types.h" -#include "midi_byte_array.h" -#include "mode.h" +#include "canvas/colors.h" -namespace Cairo { - class ImageSurface; - class Context; -} +#include "midi_byte_array.h" namespace Pango { class Layout; @@ -72,72 +68,13 @@ public: class P2GUI; class Push2Menu; +class Push2Layout; +class Push2Canvas; class Push2 : public ARDOUR::ControlProtocol , public AbstractUI { - public: - Push2 (ARDOUR::Session&); - ~Push2 (); - - static bool probe (); - static void* request_factory (uint32_t); - - std::list > bundles (); - - bool has_editor () const { return true; } - void* get_gui () const; - void tear_down_gui (); - - int set_active (bool yn); - XMLNode& get_state(); - int set_state (const XMLNode & node, int version); - - PBD::Signal0 ConnectionChange; - - boost::shared_ptr input_port(); - boost::shared_ptr output_port(); - - int pad_note (int row, int col) const; - PBD::Signal0 PadChange; - - void set_pad_scale (int root, int octave, MusicalMode::Type mode, bool inkey); - - MusicalMode::Type mode() const { return _mode; } - int scale_root() const { return _scale_root; } - int root_octave() const { return _root_octave; } - bool in_key() const { return _in_key; } - - static const int cols; - static const int rows; - - private: - libusb_device_handle *handle; - uint8_t frame_header[16]; - uint16_t* device_frame_buffer; - int device_buffer; - Cairo::RefPtr frame_buffer; - sigc::connection vblank_connection; - sigc::connection periodic_connection; - - enum ModifierState { - None = 0, - ModShift = 0x1, - ModSelect = 0x2, - }; - - ModifierState modifier_state; - - static const int pixels_per_row; - - void do_request (Push2Request*); - int stop (); - int open (); - int close (); - bool redraw (); - int blit_to_device_frame_buffer (); - bool vblank (); - + public: enum ButtonID { TapTempo, Metronome, @@ -341,6 +278,105 @@ class Push2 : public ARDOUR::ControlProtocol : Button (bb, ex, press, release, long_press) {} }; + enum ColorName { + DarkBackground, + LightBackground, + + ParameterName, + StripableName, + ClockText, + + KnobArcBackground, + KnobArcStart, + KnobArcEnd, + + KnobLine, + KnobLineShadow, + + KnobForeground, + KnobBackground, + KnobShadow, + KnobBorder, + }; + + enum PressureMode { + AfterTouch, + PolyPressure, + }; + + public: + Push2 (ARDOUR::Session&); + ~Push2 (); + + static bool probe (); + static void* request_factory (uint32_t); + + std::list > bundles (); + + bool has_editor () const { return true; } + void* get_gui () const; + void tear_down_gui (); + + int set_active (bool yn); + XMLNode& get_state(); + int set_state (const XMLNode & node, int version); + + PBD::Signal0 ConnectionChange; + + boost::shared_ptr input_port(); + boost::shared_ptr output_port(); + + int pad_note (int row, int col) const; + PBD::Signal0 PadChange; + + void update_selection_color (); + + void set_pad_scale (int root, int octave, MusicalMode::Type mode, bool inkey); + PBD::Signal0 ScaleChange; + + MusicalMode::Type mode() const { return _mode; } + int scale_root() const { return _scale_root; } + int root_octave() const { return _root_octave; } + bool in_key() const { return _in_key; } + + Push2Layout* current_layout() const; + void use_previous_layout (); + + Push2Canvas* canvas() const { return _canvas; } + + enum ModifierState { + None = 0, + ModShift = 0x1, + ModSelect = 0x2, + }; + + ModifierState modifier_state() const { return _modifier_state; } + + Button* button_by_id (ButtonID); + static std::string button_name_by_id (ButtonID); + + void strip_buttons_off (); + + void write (const MidiByteArray&); + + uint8_t get_color_index (ArdourCanvas::Color rgba); + ArdourCanvas::Color get_color (ColorName); + + PressureMode pressure_mode () const { return _pressure_mode; } + void set_pressure_mode (PressureMode); + PBD::Signal1 PressureModeChange; + + libusb_device_handle* usb_handle() const { return handle; } + + private: + libusb_device_handle *handle; + ModifierState _modifier_state; + + void do_request (Push2Request*); + int stop (); + int open (); + int close (); + void relax () {} /* map of Buttons by CC */ @@ -358,17 +394,16 @@ class Push2 : public ARDOUR::ControlProtocol void init_buttons (bool startup); void init_touch_strip (); - /* map of Pads by note number */ + /* map of Pads by note number (the "fixed" note number sent by the + * hardware, not the note number generated if the pad is touched) + */ typedef std::map NNPadMap; NNPadMap nn_pad_map; - /* map of Pads by coordinate - * - * coord = row * 64 + column; - * - * rows start at top left + + /* map of Pads by note number they generate (their "filtered" value) */ - typedef std::map CoordPadMap; - CoordPadMap coord_pad_map; + typedef std::multimap FNPadMap; + FNPadMap fn_pad_map; void set_button_color (ButtonID, uint8_t color_index); void set_button_state (ButtonID, LED::State); @@ -394,8 +429,9 @@ class Push2 : public ARDOUR::ControlProtocol void handle_midi_note_off_message (MIDI::Parser&, MIDI::EventTwoBytes*); void handle_midi_sysex (MIDI::Parser&, MIDI::byte *, size_t count); - void write (const MidiByteArray&); bool midi_input_handler (Glib::IOCondition ioc, MIDI::Port* port); + + sigc::connection periodic_connection; bool periodic (); void thread_init (); @@ -417,29 +453,13 @@ class Push2 : public ARDOUR::ControlProtocol void button_left (); void button_metronome (); void button_repeat (); + void button_mute (); void button_solo (); + void button_solo_long_press (); void button_fixed_length (); void button_new (); void button_browse (); void button_clip (); - void button_upper (uint32_t n); - void button_lower (uint32_t n); - void button_upper_1 () { button_upper (0); } - void button_upper_2 () { button_upper (1); } - void button_upper_3 () { button_upper (2); } - void button_upper_4 () { button_upper (3); } - void button_upper_5 () { button_upper (4); } - void button_upper_6 () { button_upper (5); } - void button_upper_7 () { button_upper (6); } - void button_upper_8 () { button_upper (7); } - void button_lower_1 () { button_lower (0); } - void button_lower_2 () { button_lower (1); } - void button_lower_3 () { button_lower (2); } - void button_lower_4 () { button_lower (3); } - void button_lower_5 () { button_lower (4); } - void button_lower_6 () { button_lower (5); } - void button_lower_7 () { button_lower (6); } - void button_lower_8 () { button_lower (7); } void button_undo (); void button_fwd32t (); void button_fwd32 (); @@ -451,6 +471,9 @@ class Push2 : public ARDOUR::ControlProtocol void button_fwd4 (); void button_add_track (); void button_stop (); + void button_master (); + void button_quantize (); + void button_duplicate (); void button_shift_press (); void button_shift_release (); void button_shift_long_press (); @@ -463,50 +486,65 @@ class Push2 : public ARDOUR::ControlProtocol void button_octave_down (); void button_layout_press (); void button_scale_press (); + void button_mix_press (); + + void button_upper (uint32_t n); + void button_lower (uint32_t n); + + void button_upper_1 () { button_upper (0); } + void button_upper_2 () { button_upper (1); } + void button_upper_3 () { button_upper (2); } + void button_upper_4 () { button_upper (3); } + void button_upper_5 () { button_upper (4); } + void button_upper_6 () { button_upper (5); } + void button_upper_7 () { button_upper (6); } + void button_upper_8 () { button_upper (7); } + void button_lower_1 () { button_lower (0); } + void button_lower_2 () { button_lower (1); } + void button_lower_3 () { button_lower (2); } + void button_lower_4 () { button_lower (3); } + void button_lower_5 () { button_lower (4); } + void button_lower_6 () { button_lower (5); } + void button_lower_7 () { button_lower (6); } + void button_lower_8 () { button_lower (7); } void start_shift (); void end_shift (); - void start_select (); - void end_select (); - /* encoders */ + /* non-strip encoders */ - void strip_vpot (int, int); void other_vpot (int, int); - void strip_vpot_touch (int, bool); void other_vpot_touch (int, bool); - /* widgets */ + /* special Stripables */ - Cairo::RefPtr context; - Glib::RefPtr tc_clock_layout; - Glib::RefPtr bbt_clock_layout; - Glib::RefPtr upper_layout[8]; - Glib::RefPtr mid_layout[8]; - Glib::RefPtr lower_layout[8]; + boost::shared_ptr master; + boost::shared_ptr monitor; + + sigc::connection vblank_connection; + bool vblank (); void splash (); ARDOUR::microseconds_t splash_start; - /* stripables */ + /* the canvas */ - int32_t bank_start; - PBD::ScopedConnectionList stripable_connections; - boost::shared_ptr stripable[8]; - boost::shared_ptr master; - boost::shared_ptr monitor; + Push2Canvas* _canvas; - void solo_change (int); - void mute_change (int); - void stripable_property_change (PBD::PropertyChange const& what_changed, int which); + /* Layouts */ - void switch_bank (uint32_t base); + mutable Glib::Threads::Mutex layout_lock; + Push2Layout* _current_layout; + Push2Layout* _previous_layout; + Push2Layout* mix_layout; + Push2Layout* scale_layout; + Push2Layout* track_mix_layout; + Push2Layout* splash_layout; + void set_current_layout (Push2Layout*); bool pad_filter (ARDOUR::MidiBuffer& in, ARDOUR::MidiBuffer& out) const; boost::weak_ptr current_pad_target; - PBD::ScopedConnection selection_connection; - void stripable_selection_change (ARDOUR::StripableNotificationListPtr); PBD::ScopedConnection port_reg_connection; void port_registration_handler (); @@ -519,6 +557,7 @@ class Push2 : public ARDOUR::ControlProtocol int connection_state; bool connection_handler (boost::weak_ptr, std::string name1, boost::weak_ptr, std::string name2, bool yn); PBD::ScopedConnection port_connection; + void connected (); /* GUI */ @@ -527,8 +566,8 @@ class Push2 : public ARDOUR::ControlProtocol /* pad mapping */ - std::map pad_map; - void build_pad_table(); + PBD::ScopedConnection selection_connection; + void stripable_selection_change (ARDOUR::StripableNotificationListPtr); MusicalMode::Type _mode; int _scale_root; @@ -540,15 +579,26 @@ class Push2 : public ARDOUR::ControlProtocol bool percussion; void set_percussive_mode (bool); - /* menus */ - Push2Menu* current_menu; - Push2Menu* drawn_menu; - Push2Menu* scale_menu; + /* color map (device side) */ + + typedef std::map ColorMap; + typedef std::stack ColorMapFreeList; + ColorMap color_map; + ColorMapFreeList color_map_free_list; + void build_color_map (); + + /* our own colors */ + + typedef std::map Colors; + Colors colors; + void fill_color_table (); + void reset_pad_colors (); + + PressureMode _pressure_mode; + void request_pressure_mode (); - void build_scale_menu (); - void set_menu (Push2Menu*); - void show_scale_menu (); - void cancel_menu (); + uint8_t selection_color; + uint8_t contrast_color; }; } /* namespace */