add support for "msg=" bindings and also action="SomeGroup/Action"
[ardour2.git] / libs / surfaces / generic_midi / midiinvokable.h
blobb86bdb858bf6c50f6460d0c06b375d00f2db04a8
1 /*
2 Copyright (C) 2009 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 __gm_midiinvokable_h__
21 #define __gm_midiinvokable_h__
23 #include <string>
25 #include "midi++/types.h"
27 #include "pbd/signals.h"
28 #include "pbd/stateful.h"
30 #include "ardour/types.h"
32 namespace MIDI {
33 class Channel;
34 class Port;
35 class Parser;
38 class GenericMidiControlProtocol;
40 class MIDIInvokable : public PBD::Stateful
42 public:
43 MIDIInvokable (MIDI::Port&);
44 virtual ~MIDIInvokable ();
46 virtual int init (GenericMidiControlProtocol&, const std::string&, MIDI::byte* data = 0, size_t dsize = 0);
48 MIDI::Port& get_port() const { return _port; }
50 void bind_midi (MIDI::channel_t, MIDI::eventType, MIDI::byte);
51 MIDI::channel_t get_control_channel () { return control_channel; }
52 MIDI::eventType get_control_type () { return control_type; }
53 MIDI::byte get_control_additional () { return control_additional; }
55 protected:
56 GenericMidiControlProtocol* _ui;
57 std::string _invokable_name;
58 MIDI::Port& _port;
59 PBD::ScopedConnection midi_sense_connection[2];
60 MIDI::eventType control_type;
61 MIDI::byte control_additional;
62 MIDI::channel_t control_channel;
63 MIDI::byte* data;
64 size_t data_size;
66 void midi_sense_note (MIDI::Parser &, MIDI::EventTwoBytes *, bool is_on);
67 void midi_sense_note_on (MIDI::Parser &p, MIDI::EventTwoBytes *tb);
68 void midi_sense_note_off (MIDI::Parser &p, MIDI::EventTwoBytes *tb);
69 void midi_sense_controller (MIDI::Parser &, MIDI::EventTwoBytes *);
70 void midi_sense_program_change (MIDI::Parser &, MIDI::byte);
71 void midi_sense_sysex (MIDI::Parser &, MIDI::byte*, size_t);
72 void midi_sense_any (MIDI::Parser &, MIDI::byte*, size_t);
74 virtual void execute () = 0;
77 #endif // __gm_midicontrollable_h__