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_midifunction_h__
21 #define __gm_midifunction_h__
25 #include "midi++/types.h"
27 #include "pbd/signals.h"
28 #include "pbd/stateful.h"
30 #include "ardour/types.h"
38 class GenericMidiControlProtocol;
40 class MIDIFunction : public PBD::Stateful
52 TransportRecordEnable,
53 TransportRecordDisable
56 MIDIFunction (MIDI::Port&);
57 virtual ~MIDIFunction ();
59 int init (GenericMidiControlProtocol&, const std::string& function_name, MIDI::byte* sysex = 0, size_t ssize = 0);
61 MIDI::Port& get_port() const { return _port; }
62 const std::string& function_name() const { return _function_name; }
64 XMLNode& get_state (void);
65 int set_state (const XMLNode&, int version);
67 void bind_midi (MIDI::channel_t, MIDI::eventType, MIDI::byte);
68 MIDI::channel_t get_control_channel () { return control_channel; }
69 MIDI::eventType get_control_type () { return control_type; }
70 MIDI::byte get_control_additional () { return control_additional; }
74 GenericMidiControlProtocol* _ui;
75 std::string _function_name;
77 PBD::ScopedConnection midi_sense_connection[2];
78 MIDI::eventType control_type;
79 MIDI::byte control_additional;
80 MIDI::channel_t control_channel;
86 void midi_sense_note (MIDI::Parser &, MIDI::EventTwoBytes *, bool is_on);
87 void midi_sense_note_on (MIDI::Parser &p, MIDI::EventTwoBytes *tb);
88 void midi_sense_note_off (MIDI::Parser &p, MIDI::EventTwoBytes *tb);
89 void midi_sense_controller (MIDI::Parser &, MIDI::EventTwoBytes *);
90 void midi_sense_program_change (MIDI::Parser &, MIDI::byte);
91 void midi_sense_sysex (MIDI::Parser &, MIDI::byte*, size_t);
94 #endif // __gm_midicontrollable_h__