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/thread.h>
25 #include "ardour/types.h"
27 #include "control_protocol/control_protocol.h"
41 class MIDIControllable;
44 class GenericMidiControlProtocol : public ARDOUR::ControlProtocol {
46 GenericMidiControlProtocol (ARDOUR::Session&);
47 virtual ~GenericMidiControlProtocol();
49 int set_active (bool yn);
50 static bool probe() { return true; }
52 MIDI::Port* port () const { return _port; }
53 void set_feedback_interval (ARDOUR::microseconds_t);
55 int set_feedback (bool yn);
56 bool get_feedback () const;
58 XMLNode& get_state ();
59 int set_state (const XMLNode&, int version);
61 bool has_editor () const { return true; }
62 void* get_gui () const;
63 void tear_down_gui ();
65 int load_bindings (const std::string&);
66 void drop_bindings ();
68 std::string current_binding() const { return _current_binding; }
75 std::list<MapInfo> map_info;
78 void set_current_bank (uint32_t);
84 ARDOUR::microseconds_t _feedback_interval;
85 ARDOUR::microseconds_t last_feedback_time;
88 void _send_feedback ();
89 void send_feedback ();
91 typedef std::list<MIDIControllable*> MIDIControllables;
92 MIDIControllables controllables;
94 typedef std::list<MIDIFunction*> MIDIFunctions;
95 MIDIFunctions functions;
97 typedef std::pair<MIDIControllable*,PBD::ScopedConnection> MIDIPendingControllable;
98 typedef std::list<MIDIPendingControllable* > MIDIPendingControllables;
99 MIDIPendingControllables pending_controllables;
100 Glib::Mutex controllables_lock;
101 Glib::Mutex pending_lock;
103 bool start_learning (PBD::Controllable*);
104 void stop_learning (PBD::Controllable*);
106 void learning_stopped (MIDIControllable*);
108 void create_binding (PBD::Controllable*, int, int);
109 void delete_binding (PBD::Controllable*);
111 MIDIControllable* create_binding (const XMLNode&);
112 MIDIFunction* create_function (const XMLNode&);
114 void reset_controllables ();
117 std::string _current_binding;
119 uint32_t _current_bank;
125 #endif /* ardour_generic_midi_control_protocol_h */