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>
25 #include "ardour/types.h"
27 #include "control_protocol/control_protocol.h"
35 class ControllableDescriptor;
42 class MIDIControllable;
46 class GenericMidiControlProtocol : public ARDOUR::ControlProtocol {
48 GenericMidiControlProtocol (ARDOUR::Session&);
49 virtual ~GenericMidiControlProtocol();
51 int set_active (bool yn);
52 static bool probe() { return true; }
54 MIDI::Port* input_port () const { return _input_port; }
55 MIDI::Port* output_port () const { return _output_port; }
56 void set_feedback_interval (ARDOUR::microseconds_t);
58 int set_feedback (bool yn);
59 bool get_feedback () const;
61 boost::shared_ptr<PBD::Controllable> lookup_controllable (const PBD::ControllableDescriptor&) const;
63 XMLNode& get_state ();
64 int set_state (const XMLNode&, int version);
66 bool has_editor () const { return true; }
67 void* get_gui () const;
68 void tear_down_gui ();
70 int load_bindings (const std::string&);
71 void drop_bindings ();
73 std::string current_binding() const { return _current_binding; }
80 std::list<MapInfo> map_info;
83 void set_current_bank (uint32_t);
87 void set_motorised (bool);
89 bool motorised () const {
93 void set_threshold (int);
95 int threshold () const {
100 MIDI::Port* _input_port;
101 MIDI::Port* _output_port;
102 ARDOUR::microseconds_t _feedback_interval;
103 ARDOUR::microseconds_t last_feedback_time;
106 void _send_feedback ();
107 void send_feedback ();
109 typedef std::list<MIDIControllable*> MIDIControllables;
110 MIDIControllables controllables;
112 typedef std::list<MIDIFunction*> MIDIFunctions;
113 MIDIFunctions functions;
115 typedef std::list<MIDIAction*> MIDIActions;
118 typedef std::pair<MIDIControllable*,PBD::ScopedConnection> MIDIPendingControllable;
119 typedef std::list<MIDIPendingControllable* > MIDIPendingControllables;
120 MIDIPendingControllables pending_controllables;
121 Glib::Threads::Mutex controllables_lock;
122 Glib::Threads::Mutex pending_lock;
124 bool start_learning (PBD::Controllable*);
125 void stop_learning (PBD::Controllable*);
127 void learning_stopped (MIDIControllable*);
129 void create_binding (PBD::Controllable*, int, int);
130 void delete_binding (PBD::Controllable*);
132 MIDIControllable* create_binding (const XMLNode&);
133 MIDIFunction* create_function (const XMLNode&);
134 MIDIAction* create_action (const XMLNode&);
136 void reset_controllables ();
139 std::string _current_binding;
141 uint32_t _current_bank;
142 /** true if this surface is motorised. If it is, we assume
143 that the surface's controls are never out of sync with
144 Ardour's state, so we don't have to take steps to avoid
145 values jumping around when things are not in sync.
154 #endif /* ardour_generic_midi_control_protocol_h */