2 Copyright (C) 2006 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef ardour_generic_midi_control_protocol_h
21 #define ardour_generic_midi_control_protocol_h
24 #include <glibmm/threads.h>
26 #include "ardour/types.h"
28 #include "control_protocol/control_protocol.h"
32 class ControllableDescriptor;
44 class MIDIControllable;
48 class GenericMidiControlProtocol : public ARDOUR::ControlProtocol {
50 GenericMidiControlProtocol (ARDOUR::Session&);
51 virtual ~GenericMidiControlProtocol();
53 int set_active (bool yn);
54 static bool probe() { return true; }
56 MIDI::Port* input_port () const { return _input_port; }
57 MIDI::Port* output_port () const { return _output_port; }
58 void set_feedback_interval (ARDOUR::microseconds_t);
60 int set_feedback (bool yn);
61 bool get_feedback () const;
63 boost::shared_ptr<PBD::Controllable> lookup_controllable (const PBD::ControllableDescriptor&) const;
65 XMLNode& get_state ();
66 int set_state (const XMLNode&, int version);
68 bool has_editor () const { return true; }
69 void* get_gui () const;
70 void tear_down_gui ();
72 int load_bindings (const std::string&);
73 void drop_bindings ();
75 void check_used_event (int, int);
77 std::string current_binding() const { return _current_binding; }
84 std::list<MapInfo> map_info;
87 void set_current_bank (uint32_t);
91 void set_motorised (bool);
93 bool motorised () const {
97 void set_threshold (int);
99 int threshold () const {
104 MIDI::Port* _input_port;
105 MIDI::Port* _output_port;
106 ARDOUR::microseconds_t _feedback_interval;
107 ARDOUR::microseconds_t last_feedback_time;
110 void _send_feedback ();
111 void send_feedback ();
113 typedef std::list<MIDIControllable*> MIDIControllables;
114 MIDIControllables controllables;
116 typedef std::list<MIDIFunction*> MIDIFunctions;
117 MIDIFunctions functions;
119 typedef std::list<MIDIAction*> MIDIActions;
122 typedef std::pair<MIDIControllable*,PBD::ScopedConnection> MIDIPendingControllable;
123 typedef std::list<MIDIPendingControllable* > MIDIPendingControllables;
124 MIDIPendingControllables pending_controllables;
125 Glib::Threads::Mutex controllables_lock;
126 Glib::Threads::Mutex pending_lock;
128 bool start_learning (PBD::Controllable*);
129 void stop_learning (PBD::Controllable*);
131 void learning_stopped (MIDIControllable*);
133 void create_binding (PBD::Controllable*, int, int);
134 void delete_binding (PBD::Controllable*);
136 MIDIControllable* create_binding (const XMLNode&);
137 MIDIFunction* create_function (const XMLNode&);
138 MIDIAction* create_action (const XMLNode&);
140 void reset_controllables ();
143 std::string _current_binding;
145 uint32_t _current_bank;
146 /** true if this surface is motorised. If it is, we assume
147 that the surface's controls are never out of sync with
148 Ardour's state, so we don't have to take steps to avoid
149 values jumping around when things are not in sync.
158 #endif /* ardour_generic_midi_control_protocol_h */