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* input_port () const { return _input_port; }
54 MIDI::Port* output_port () const { return _output_port; }
55 void set_feedback_interval (ARDOUR::microseconds_t);
57 int set_feedback (bool yn);
58 bool get_feedback () const;
60 XMLNode& get_state ();
61 int set_state (const XMLNode&, int version);
63 bool has_editor () const { return true; }
64 void* get_gui () const;
65 void tear_down_gui ();
67 int load_bindings (const std::string&);
68 void drop_bindings ();
70 std::string current_binding() const { return _current_binding; }
77 std::list<MapInfo> map_info;
80 void set_current_bank (uint32_t);
85 MIDI::Port* _input_port;
86 MIDI::Port* _output_port;
87 ARDOUR::microseconds_t _feedback_interval;
88 ARDOUR::microseconds_t last_feedback_time;
91 void _send_feedback ();
92 void send_feedback ();
94 typedef std::list<MIDIControllable*> MIDIControllables;
95 MIDIControllables controllables;
97 typedef std::list<MIDIFunction*> MIDIFunctions;
98 MIDIFunctions functions;
100 typedef std::list<MIDIAction*> MIDIActions;
103 typedef std::pair<MIDIControllable*,PBD::ScopedConnection> MIDIPendingControllable;
104 typedef std::list<MIDIPendingControllable* > MIDIPendingControllables;
105 MIDIPendingControllables pending_controllables;
106 Glib::Mutex controllables_lock;
107 Glib::Mutex pending_lock;
109 bool start_learning (PBD::Controllable*);
110 void stop_learning (PBD::Controllable*);
112 void learning_stopped (MIDIControllable*);
114 void create_binding (PBD::Controllable*, int, int);
115 void delete_binding (PBD::Controllable*);
117 MIDIControllable* create_binding (const XMLNode&);
118 MIDIFunction* create_function (const XMLNode&);
119 MIDIAction* create_action (const XMLNode&);
121 void reset_controllables ();
124 std::string _current_binding;
126 uint32_t _current_bank;
132 #endif /* ardour_generic_midi_control_protocol_h */