NOOP, remove trailing tabs/whitespace.
[ardour.git] / libs / surfaces / generic_midi / midiinvokable.h
1 /*
2     Copyright (C) 2009 Paul Davis
3
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.
8
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.
13
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.
17
18 */
19
20 #ifndef __gm_midiinvokable_h__
21 #define __gm_midiinvokable_h__
22
23 #include <string>
24
25 #include "midi++/types.h"
26
27 #include "pbd/signals.h"
28 #include "pbd/stateful.h"
29
30 #include "ardour/types.h"
31
32 namespace MIDI {
33         class Channel;
34         class Parser;
35 }
36
37 class GenericMidiControlProtocol;
38
39 class MIDIInvokable : public PBD::Stateful
40 {
41   public:
42         MIDIInvokable (MIDI::Parser&);
43         virtual ~MIDIInvokable ();
44
45         virtual int init (GenericMidiControlProtocol&, const std::string&, MIDI::byte* data = 0, size_t dsize = 0);
46
47         MIDI::Parser& get_parser() { return _parser; }
48
49         void bind_midi (MIDI::channel_t, MIDI::eventType, MIDI::byte);
50         MIDI::channel_t get_control_channel () { return control_channel; }
51         MIDI::eventType get_control_type () { return control_type; }
52         MIDI::byte get_control_additional () { return control_additional; }
53
54   protected:
55         GenericMidiControlProtocol* _ui;
56         std::string     _invokable_name;
57         MIDI::Parser&     _parser;
58         PBD::ScopedConnection midi_sense_connection[2];
59         MIDI::eventType  control_type;
60         MIDI::byte       control_additional;
61         MIDI::channel_t  control_channel;
62         MIDI::byte*      data;
63         size_t           data_size;
64         bool            _parameterized;
65
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);
73
74         virtual void execute () = 0;
75 };
76
77 #endif // __gm_midicontrollable_h__
78