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;
45 class GenericMidiControlProtocol : public ARDOUR::ControlProtocol {
47 GenericMidiControlProtocol (ARDOUR::Session&);
48 virtual ~GenericMidiControlProtocol();
50 int set_active (bool yn);
51 static bool probe() { return true; }
53 MIDI::Port* port () const { return _port; }
54 void set_feedback_interval (ARDOUR::microseconds_t);
56 int set_feedback (bool yn);
57 bool get_feedback () const;
59 XMLNode& get_state ();
60 int set_state (const XMLNode&, int version);
62 bool has_editor () const { return true; }
63 void* get_gui () const;
64 void tear_down_gui ();
66 int load_bindings (const std::string&);
67 void drop_bindings ();
69 std::string current_binding() const { return _current_binding; }
76 std::list<MapInfo> map_info;
79 void set_current_bank (uint32_t);
85 ARDOUR::microseconds_t _feedback_interval;
86 ARDOUR::microseconds_t last_feedback_time;
89 void _send_feedback ();
90 void send_feedback ();
92 typedef std::list<MIDIControllable*> MIDIControllables;
93 MIDIControllables controllables;
95 typedef std::list<MIDIFunction*> MIDIFunctions;
96 MIDIFunctions functions;
98 typedef std::list<MIDIAction*> MIDIActions;
101 typedef std::pair<MIDIControllable*,PBD::ScopedConnection> MIDIPendingControllable;
102 typedef std::list<MIDIPendingControllable* > MIDIPendingControllables;
103 MIDIPendingControllables pending_controllables;
104 Glib::Mutex controllables_lock;
105 Glib::Mutex pending_lock;
107 bool start_learning (PBD::Controllable*);
108 void stop_learning (PBD::Controllable*);
110 void learning_stopped (MIDIControllable*);
112 void create_binding (PBD::Controllable*, int, int);
113 void delete_binding (PBD::Controllable*);
115 MIDIControllable* create_binding (const XMLNode&);
116 MIDIFunction* create_function (const XMLNode&);
117 MIDIAction* create_action (const XMLNode&);
119 void reset_controllables ();
122 std::string _current_binding;
124 uint32_t _current_bank;
130 #endif /* ardour_generic_midi_control_protocol_h */