2009-12-28 11:49:44 -05:00
|
|
|
/*
|
2019-08-03 08:34:29 -04:00
|
|
|
* Copyright (C) 2006-2009 David Robillard <d@drobilla.net>
|
|
|
|
* Copyright (C) 2006-2018 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
* Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
|
|
|
|
* Copyright (C) 2015-2019 Robin Gareus <robin@gareus.org>
|
|
|
|
*
|
|
|
|
* 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.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2009-12-28 11:49:44 -05:00
|
|
|
|
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
|
|
|
|
2019-12-31 14:06:00 -05:00
|
|
|
#define ABSTRACT_UI_EXPORTS
|
|
|
|
#include "pbd/abstract_ui.h"
|
|
|
|
|
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;
|
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 {
|
2019-03-23 12:35:26 -04:00
|
|
|
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
|
|
|
|
2019-12-31 14:06:00 -05:00
|
|
|
struct GenericMIDIRequest : public BaseUI::BaseRequestObject {
|
|
|
|
public:
|
|
|
|
GenericMIDIRequest () {}
|
|
|
|
~GenericMIDIRequest () {}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class GenericMidiControlProtocol : public ARDOUR::ControlProtocol, public AbstractUI<GenericMIDIRequest> {
|
2019-03-22 21:09:39 -04:00
|
|
|
public:
|
2008-06-02 17:41:35 -04:00
|
|
|
GenericMidiControlProtocol (ARDOUR::Session&);
|
|
|
|
virtual ~GenericMidiControlProtocol();
|
|
|
|
|
2019-12-31 14:06:00 -05:00
|
|
|
void do_request (GenericMIDIRequest*);
|
|
|
|
int stop ();
|
|
|
|
|
|
|
|
void thread_init ();
|
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
int set_active (bool yn);
|
|
|
|
|
2017-05-12 09:51:31 -04:00
|
|
|
void stripable_selection_changed () {}
|
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
std::list<std::shared_ptr<ARDOUR::Bundle> > bundles ();
|
2016-07-08 17:09:44 -04:00
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<ARDOUR::Port> input_port () const;
|
|
|
|
std::shared_ptr<ARDOUR::Port> output_port () const;
|
2015-12-07 12:04:23 -05:00
|
|
|
|
2021-06-27 11:32:12 -04:00
|
|
|
void set_feedback_interval (PBD::microseconds_t);
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
int set_feedback (bool yn);
|
|
|
|
bool get_feedback () const;
|
|
|
|
|
2024-01-13 10:18:32 -05:00
|
|
|
std::shared_ptr<PBD::Controllable> lookup_controllable (std::string const &, MIDIControllable&) const;
|
2012-06-25 08:33:13 -04:00
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
void maybe_start_touch (std::shared_ptr<PBD::Controllable>);
|
2017-01-23 07:25:56 -05:00
|
|
|
|
2022-04-06 23:56:32 -04:00
|
|
|
XMLNode& get_state () const;
|
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 ();
|
2022-01-15 15:15:38 -05:00
|
|
|
void drop_all ();
|
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;
|
|
|
|
}
|
|
|
|
|
2022-06-05 17:37:04 -04:00
|
|
|
void add_rid_to_selection (int rid);
|
|
|
|
void set_rid_selection (int rid);
|
|
|
|
void toggle_rid_selection (int rid);
|
|
|
|
void remove_rid_from_selection (int rid);
|
|
|
|
|
2024-10-18 12:01:28 -04:00
|
|
|
PBD::Signal<void()> ConnectionChange;
|
2015-12-07 12:04:23 -05:00
|
|
|
|
2022-05-16 17:24:27 -04:00
|
|
|
CONTROL_PROTOCOL_THREADS_NEED_TEMPO_MAP_DECL();
|
|
|
|
|
2019-03-22 21:09:39 -04:00
|
|
|
private:
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<ARDOUR::Bundle> _input_bundle;
|
|
|
|
std::shared_ptr<ARDOUR::Bundle> _output_bundle;
|
|
|
|
std::shared_ptr<ARDOUR::AsyncMIDIPort> _input_port;
|
|
|
|
std::shared_ptr<ARDOUR::AsyncMIDIPort> _output_port;
|
2015-12-07 12:04:23 -05:00
|
|
|
|
2021-06-27 11:32:12 -04:00
|
|
|
PBD::microseconds_t _feedback_interval;
|
|
|
|
PBD::microseconds_t last_feedback_time;
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2016-07-21 14:00:18 -04:00
|
|
|
struct MIDIPendingControllable {
|
|
|
|
MIDIControllable* mc;
|
|
|
|
bool own_mc;
|
|
|
|
PBD::ScopedConnection connection;
|
|
|
|
|
|
|
|
MIDIPendingControllable (MIDIControllable* c, bool omc)
|
|
|
|
: mc (c)
|
|
|
|
, own_mc (omc)
|
|
|
|
{}
|
|
|
|
};
|
2009-12-20 11:50:41 -05:00
|
|
|
typedef std::list<MIDIPendingControllable* > MIDIPendingControllables;
|
2008-06-02 17:41:35 -04:00
|
|
|
MIDIPendingControllables pending_controllables;
|
2022-04-06 23:56:32 -04:00
|
|
|
mutable Glib::Threads::Mutex controllables_lock;
|
2019-03-23 12:35:26 -04:00
|
|
|
Glib::Threads::Mutex pending_lock;
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
bool start_learning (std::weak_ptr<PBD::Controllable>);
|
|
|
|
void stop_learning (std::weak_ptr<PBD::Controllable>);
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
void learning_stopped (MIDIControllable*);
|
|
|
|
|
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
|
|
|
|
2015-12-07 12:04:23 -05:00
|
|
|
enum ConnectionState {
|
|
|
|
InputConnected = 0x1,
|
|
|
|
OutputConnected = 0x2
|
|
|
|
};
|
|
|
|
|
|
|
|
int connection_state;
|
2023-02-16 18:33:28 -05:00
|
|
|
bool connection_handler (std::weak_ptr<ARDOUR::Port>, std::string name1, std::weak_ptr<ARDOUR::Port>, std::string name2, bool yn);
|
2021-02-04 00:19:37 -05:00
|
|
|
PBD::ScopedConnection _port_connection;
|
2015-12-07 12:04:23 -05:00
|
|
|
|
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
|
|
|
|
2019-12-31 14:06:00 -05:00
|
|
|
PBD::ScopedConnectionList midi_connections;
|
2015-12-07 12:04:23 -05:00
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
bool midi_input_handler (Glib::IOCondition ioc, std::weak_ptr<ARDOUR::AsyncMIDIPort> port);
|
2019-12-31 14:06:00 -05:00
|
|
|
void start_midi_handling ();
|
|
|
|
void stop_midi_handling ();
|
2008-06-02 17:41:35 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* ardour_generic_midi_control_protocol_h */
|