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_surface_faderport_h
21 #define ardour_surface_faderport_h
24 #include <glibmm/threads.h>
26 #include "ardour/types.h"
28 #include "control_protocol/control_protocol.h"
32 class ControllableDescriptor;
35 #include <midi++/types.h>
37 //#include "pbd/signals.h"
40 //#include "midi_byte_array.h"
43 #include "glibmm/main.h"
59 class MIDIControllable;
63 class FaderPort : public ARDOUR::ControlProtocol {
65 FaderPort (ARDOUR::Session&);
68 int set_active (bool yn);
70 /* It would be nice to send a device query message here to see if
71 * faderport is out there. But the probe() API doesn't provide
72 * a set of ports to be checked, so there's really no nice
73 * way to do this. We would have to fall back on the PortManager
74 * and get a list of all physical ports. Could be done ....
76 static bool probe() { return true; }
78 void set_feedback_interval (ARDOUR::microseconds_t);
80 int set_feedback (bool yn);
81 bool get_feedback () const;
83 XMLNode& get_state ();
84 int set_state (const XMLNode&, int version);
86 bool has_editor () const { return true; }
87 void* get_gui () const;
88 void tear_down_gui ();
90 void set_current_bank (uint32_t);
94 void reset_controllables ();
96 void set_motorised (bool);
98 bool motorised () const {
102 void set_threshold (int);
104 int threshold () const {
108 bool device_active() const { return _device_active; }
111 boost::shared_ptr<ARDOUR::AsyncMIDIPort> _input_port;
112 boost::shared_ptr<ARDOUR::AsyncMIDIPort> _output_port;
114 ARDOUR::microseconds_t _feedback_interval;
115 ARDOUR::microseconds_t last_feedback_time;
119 void send_feedback ();
121 PBD::ScopedConnectionList midi_connections;
123 bool midi_input_handler (Glib::IOCondition ioc, boost::shared_ptr<ARDOUR::AsyncMIDIPort> port);
125 std::string _current_binding;
127 uint32_t _current_bank;
128 /** true if this surface is motorised. If it is, we assume
129 that the surface's controls are never out of sync with
130 Ardour's state, so we don't have to take steps to avoid
131 values jumping around when things are not in sync.
139 bool connection_handler (boost::weak_ptr<ARDOUR::Port>, std::string name1, boost::weak_ptr<ARDOUR::Port>, std::string name2, bool yn);
140 PBD::ScopedConnection port_connection;
142 enum ConnectionState {
143 InputConnected = 0x1,
144 OutputConnected = 0x2
147 int connection_state;
153 void sysex_handler (MIDI::Parser &p, MIDI::byte *, size_t);
154 void switch_handler (MIDI::Parser &, MIDI::EventTwoBytes* tb);
155 void encoder_handler (MIDI::Parser &, MIDI::pitchbend_t pb);
156 void fader_handler (MIDI::Parser &, MIDI::EventTwoBytes* tb);
216 #endif /* ardour_surface_faderport_h */