2009-12-28 11:49:44 -05:00
|
|
|
/*
|
|
|
|
Copyright (C) 2006 Paul Davis
|
2015-10-04 14:51:05 -04:00
|
|
|
|
2009-12-28 11:49:44 -05:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
#ifndef ardour_generic_midi_control_protocol_h
|
|
|
|
#define ardour_generic_midi_control_protocol_h
|
|
|
|
|
2009-12-28 11:49:44 -05:00
|
|
|
#include <list>
|
2012-07-25 13:48:55 -04:00
|
|
|
#include <glibmm/threads.h>
|
2013-08-07 22:22:11 -04:00
|
|
|
|
2009-10-29 20:21:40 -04:00
|
|
|
#include "ardour/types.h"
|
2015-12-02 19:31:43 -05:00
|
|
|
#include "ardour/port.h"
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2009-10-29 20:21:40 -04:00
|
|
|
#include "control_protocol/control_protocol.h"
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
namespace PBD {
|
|
|
|
class Controllable;
|
2015-10-05 10:17:49 -04:00
|
|
|
}
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
namespace ARDOUR {
|
2015-12-07 12:04:23 -05:00
|
|
|
class AsyncMIDIPort;
|
2016-05-16 11:08:32 -04:00
|
|
|
class ControllableDescriptor;
|
2013-08-07 22:22:11 -04:00
|
|
|
class MidiPort;
|
2015-12-07 12:04:23 -05:00
|
|
|
class Session;
|
2013-08-07 22:22:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace MIDI {
|
|
|
|
class Port;
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
class MIDIControllable;
|
2009-12-28 11:49:44 -05:00
|
|
|
class MIDIFunction;
|
2010-04-08 17:05:55 -04:00
|
|
|
class MIDIAction;
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
class GenericMidiControlProtocol : public ARDOUR::ControlProtocol {
|
|
|
|
public:
|
|
|
|
GenericMidiControlProtocol (ARDOUR::Session&);
|
|
|
|
virtual ~GenericMidiControlProtocol();
|
|
|
|
|
|
|
|
int set_active (bool yn);
|
|
|
|
static bool probe() { return true; }
|
|
|
|
|
2015-12-07 12:04:23 -05:00
|
|
|
boost::shared_ptr<ARDOUR::Port> input_port () const;
|
|
|
|
boost::shared_ptr<ARDOUR::Port> output_port () const;
|
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
void set_feedback_interval (ARDOUR::microseconds_t);
|
|
|
|
|
|
|
|
int set_feedback (bool yn);
|
|
|
|
bool get_feedback () const;
|
|
|
|
|
2016-05-16 11:08:32 -04:00
|
|
|
boost::shared_ptr<PBD::Controllable> lookup_controllable (const ARDOUR::ControllableDescriptor&) const;
|
2012-06-25 08:33:13 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
XMLNode& get_state ();
|
2009-10-15 14:56:11 -04:00
|
|
|
int set_state (const XMLNode&, int version);
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2009-12-29 16:31:14 -05:00
|
|
|
bool has_editor () const { return true; }
|
|
|
|
void* get_gui () const;
|
|
|
|
void tear_down_gui ();
|
|
|
|
|
|
|
|
int load_bindings (const std::string&);
|
|
|
|
void drop_bindings ();
|
2015-07-20 15:37:53 -04:00
|
|
|
|
|
|
|
void check_used_event (int, int);
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2009-12-29 16:31:14 -05:00
|
|
|
std::string current_binding() const { return _current_binding; }
|
|
|
|
|
|
|
|
struct MapInfo {
|
|
|
|
std::string name;
|
|
|
|
std::string path;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::list<MapInfo> map_info;
|
|
|
|
void reload_maps ();
|
|
|
|
|
|
|
|
void set_current_bank (uint32_t);
|
|
|
|
void next_bank ();
|
|
|
|
void prev_bank ();
|
|
|
|
|
2012-03-18 21:34:35 -04:00
|
|
|
void set_motorised (bool);
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2012-03-06 20:11:22 -05:00
|
|
|
bool motorised () const {
|
|
|
|
return _motorised;
|
|
|
|
}
|
|
|
|
|
2012-06-13 17:53:50 -04:00
|
|
|
void set_threshold (int);
|
|
|
|
|
|
|
|
int threshold () const {
|
|
|
|
return _threshold;
|
|
|
|
}
|
|
|
|
|
2015-12-02 19:31:43 -05:00
|
|
|
PBD::Signal0<void> ConnectionChange;
|
2015-12-07 12:04:23 -05:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
private:
|
2015-12-07 12:04:23 -05:00
|
|
|
boost::shared_ptr<ARDOUR::AsyncMIDIPort> _input_port;
|
|
|
|
boost::shared_ptr<ARDOUR::AsyncMIDIPort> _output_port;
|
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
ARDOUR::microseconds_t _feedback_interval;
|
|
|
|
ARDOUR::microseconds_t last_feedback_time;
|
|
|
|
|
|
|
|
bool do_feedback;
|
|
|
|
void _send_feedback ();
|
|
|
|
void send_feedback ();
|
|
|
|
|
2009-12-29 16:31:14 -05:00
|
|
|
typedef std::list<MIDIControllable*> MIDIControllables;
|
2008-06-02 17:41:35 -04:00
|
|
|
MIDIControllables controllables;
|
|
|
|
|
2009-12-28 11:49:44 -05:00
|
|
|
typedef std::list<MIDIFunction*> MIDIFunctions;
|
|
|
|
MIDIFunctions functions;
|
|
|
|
|
2010-04-08 17:05:55 -04:00
|
|
|
typedef std::list<MIDIAction*> MIDIActions;
|
|
|
|
MIDIActions actions;
|
|
|
|
|
2010-04-02 11:24:53 -04:00
|
|
|
typedef std::pair<MIDIControllable*,PBD::ScopedConnection> MIDIPendingControllable;
|
2009-12-20 11:50:41 -05:00
|
|
|
typedef std::list<MIDIPendingControllable* > MIDIPendingControllables;
|
2008-06-02 17:41:35 -04:00
|
|
|
MIDIPendingControllables pending_controllables;
|
2012-07-25 13:48:55 -04:00
|
|
|
Glib::Threads::Mutex controllables_lock;
|
|
|
|
Glib::Threads::Mutex pending_lock;
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
bool start_learning (PBD::Controllable*);
|
|
|
|
void stop_learning (PBD::Controllable*);
|
|
|
|
|
|
|
|
void learning_stopped (MIDIControllable*);
|
|
|
|
|
|
|
|
void create_binding (PBD::Controllable*, int, int);
|
|
|
|
void delete_binding (PBD::Controllable*);
|
2009-12-28 11:49:44 -05:00
|
|
|
|
|
|
|
MIDIControllable* create_binding (const XMLNode&);
|
|
|
|
MIDIFunction* create_function (const XMLNode&);
|
2010-04-08 17:05:55 -04:00
|
|
|
MIDIAction* create_action (const XMLNode&);
|
2009-12-28 11:49:44 -05:00
|
|
|
|
|
|
|
void reset_controllables ();
|
2009-12-29 16:31:14 -05:00
|
|
|
void drop_all ();
|
|
|
|
|
2015-12-07 12:04:23 -05:00
|
|
|
enum ConnectionState {
|
|
|
|
InputConnected = 0x1,
|
|
|
|
OutputConnected = 0x2
|
|
|
|
};
|
|
|
|
|
|
|
|
int connection_state;
|
|
|
|
bool connection_handler (boost::weak_ptr<ARDOUR::Port>, std::string name1, boost::weak_ptr<ARDOUR::Port>, std::string name2, bool yn);
|
|
|
|
PBD::ScopedConnection port_connection;
|
|
|
|
void connected();
|
|
|
|
|
2009-12-29 16:31:14 -05:00
|
|
|
std::string _current_binding;
|
|
|
|
uint32_t _bank_size;
|
|
|
|
uint32_t _current_bank;
|
2012-03-06 20:11:22 -05:00
|
|
|
/** true if this surface is motorised. If it is, we assume
|
|
|
|
that the surface's controls are never out of sync with
|
|
|
|
Ardour's state, so we don't have to take steps to avoid
|
|
|
|
values jumping around when things are not in sync.
|
|
|
|
*/
|
|
|
|
bool _motorised;
|
2012-06-13 17:53:50 -04:00
|
|
|
int _threshold;
|
2009-12-29 16:31:14 -05:00
|
|
|
|
|
|
|
mutable void *gui;
|
|
|
|
void build_gui ();
|
2015-12-07 12:04:23 -05:00
|
|
|
|
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* ardour_generic_midi_control_protocol_h */
|