X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fsurfaces%2Fgeneric_midi%2Fgeneric_midi_control_protocol.h;h=a4a51b7f99a5c2114894ee0aff282f15904cfafe;hb=1ab61b8564f9934c533d1c1a229888bc7e2fd557;hp=5f5a470b13c2c8b04c341a295067ffc54fb03675;hpb=26843b34fdd62e6f80630868c5eb3f8fee0c17f1;p=ardour.git diff --git a/libs/surfaces/generic_midi/generic_midi_control_protocol.h b/libs/surfaces/generic_midi/generic_midi_control_protocol.h index 5f5a470b13..a4a51b7f99 100644 --- a/libs/surfaces/generic_midi/generic_midi_control_protocol.h +++ b/libs/surfaces/generic_midi/generic_midi_control_protocol.h @@ -1,25 +1,49 @@ +/* + 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. + +*/ + #ifndef ardour_generic_midi_control_protocol_h #define ardour_generic_midi_control_protocol_h -#include -#include -#include +#include +#include -#include +#include "ardour/types.h" -namespace MIDI { - class Port; -} +#include "control_protocol/control_protocol.h" namespace PBD { class Controllable; + class ControllableDescriptor; } namespace ARDOUR { class Session; + class MidiPort; +} + +namespace MIDI { + class Port; } class MIDIControllable; +class MIDIFunction; +class MIDIAction; class GenericMidiControlProtocol : public ARDOUR::ControlProtocol { public: @@ -29,30 +53,104 @@ class GenericMidiControlProtocol : public ARDOUR::ControlProtocol { int set_active (bool yn); static bool probe() { return true; } - MIDI::Port* port () const { return _port; } + MIDI::Port* input_port () const { return _input_port; } + MIDI::Port* output_port () const { return _output_port; } void set_feedback_interval (ARDOUR::microseconds_t); + int set_feedback (bool yn); + bool get_feedback () const; + + boost::shared_ptr lookup_controllable (const PBD::ControllableDescriptor&) const; + XMLNode& get_state (); - int set_state (const XMLNode&); + int set_state (const XMLNode&, int version); + + bool has_editor () const { return true; } + void* get_gui () const; + void tear_down_gui (); + + int load_bindings (const std::string&); + void drop_bindings (); + + std::string current_binding() const { return _current_binding; } + + struct MapInfo { + std::string name; + std::string path; + }; + + std::list map_info; + void reload_maps (); + + void set_current_bank (uint32_t); + void next_bank (); + void prev_bank (); + + void set_motorised (bool); + + bool motorised () const { + return _motorised; + } + + void set_threshold (int); + + int threshold () const { + return _threshold; + } private: - MIDI::Port* _port; + MIDI::Port* _input_port; + MIDI::Port* _output_port; ARDOUR::microseconds_t _feedback_interval; ARDOUR::microseconds_t last_feedback_time; + bool do_feedback; void _send_feedback (); void send_feedback (); - typedef std::set MIDIControllables; + typedef std::list MIDIControllables; MIDIControllables controllables; - MIDIControllables pending_controllables; - Glib::Mutex controllables_lock; - Glib::Mutex pending_lock; + + typedef std::list MIDIFunctions; + MIDIFunctions functions; + + typedef std::list MIDIActions; + MIDIActions actions; + + typedef std::pair MIDIPendingControllable; + typedef std::list MIDIPendingControllables; + MIDIPendingControllables pending_controllables; + Glib::Threads::Mutex controllables_lock; + Glib::Threads::Mutex pending_lock; bool start_learning (PBD::Controllable*); void stop_learning (PBD::Controllable*); void learning_stopped (MIDIControllable*); + + void create_binding (PBD::Controllable*, int, int); + void delete_binding (PBD::Controllable*); + + MIDIControllable* create_binding (const XMLNode&); + MIDIFunction* create_function (const XMLNode&); + MIDIAction* create_action (const XMLNode&); + + void reset_controllables (); + void drop_all (); + + std::string _current_binding; + uint32_t _bank_size; + uint32_t _current_bank; + /** true if this surface is motorised. If it is, we assume + that the surface's controls are never out of sync with + Ardour's state, so we don't have to take steps to avoid + values jumping around when things are not in sync. + */ + bool _motorised; + int _threshold; + + mutable void *gui; + void build_gui (); }; #endif /* ardour_generic_midi_control_protocol_h */