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 std::string current_binding() const { return _current_binding; }
82 std::list<MapInfo> map_info;
85 void set_current_bank (uint32_t);
89 void set_motorised (bool);
91 bool motorised () const {
95 void set_threshold (int);
97 int threshold () const {
102 MIDI::Port* _input_port;
103 MIDI::Port* _output_port;
104 ARDOUR::microseconds_t _feedback_interval;
105 ARDOUR::microseconds_t last_feedback_time;
108 void _send_feedback ();
109 void send_feedback ();
111 typedef std::list<MIDIControllable*> MIDIControllables;
112 MIDIControllables controllables;
114 typedef std::list<MIDIFunction*> MIDIFunctions;
115 MIDIFunctions functions;
117 typedef std::list<MIDIAction*> MIDIActions;
120 typedef std::pair<MIDIControllable*,PBD::ScopedConnection> MIDIPendingControllable;
121 typedef std::list<MIDIPendingControllable* > MIDIPendingControllables;
122 MIDIPendingControllables pending_controllables;
123 Glib::Threads::Mutex controllables_lock;
124 Glib::Threads::Mutex pending_lock;
126 bool start_learning (PBD::Controllable*);
127 void stop_learning (PBD::Controllable*);
129 void learning_stopped (MIDIControllable*);
131 void create_binding (PBD::Controllable*, int, int);
132 void delete_binding (PBD::Controllable*);
134 MIDIControllable* create_binding (const XMLNode&);
135 MIDIFunction* create_function (const XMLNode&);
136 MIDIAction* create_action (const XMLNode&);
138 void reset_controllables ();
141 std::string _current_binding;
143 uint32_t _current_bank;
144 /** true if this surface is motorised. If it is, we assume
145 that the surface's controls are never out of sync with
146 Ardour's state, so we don't have to take steps to avoid
147 values jumping around when things are not in sync.
156 #endif /* ardour_generic_midi_control_protocol_h */