Automation of LV2 plugin properties.
[ardour.git] / libs / ardour / ardour / parameter_types.h
1 /*
2     Copyright (C) 2014 Paul Davis
3     Author: David Robillard
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 */
20
21 #ifndef __ardour_parameter_types_h__
22 #define __ardour_parameter_types_h__
23
24 #include <stdint.h>
25
26 #include "ardour/types.h"
27 #include "evoral/midi_events.h"
28
29 namespace ARDOUR {
30
31 inline uint8_t
32 parameter_midi_type(AutomationType type)
33 {
34         switch (type) {
35         case MidiCCAutomation:              return MIDI_CMD_CONTROL;          break;
36         case MidiPgmChangeAutomation:       return MIDI_CMD_PGM_CHANGE;       break;
37         case MidiChannelPressureAutomation: return MIDI_CMD_CHANNEL_PRESSURE; break;
38         case MidiPitchBenderAutomation:     return MIDI_CMD_BENDER;           break;
39         case MidiSystemExclusiveAutomation: return MIDI_CMD_COMMON_SYSEX;     break;
40         default: return 0;
41         }
42 }
43
44 inline AutomationType
45 midi_parameter_type(uint8_t status)
46 {
47         switch (status & 0xF0) {
48         case MIDI_CMD_CONTROL:          return MidiCCAutomation;              break;
49         case MIDI_CMD_PGM_CHANGE:       return MidiPgmChangeAutomation;       break;
50         case MIDI_CMD_CHANNEL_PRESSURE: return MidiChannelPressureAutomation; break;
51         case MIDI_CMD_BENDER:           return MidiPitchBenderAutomation;     break;
52         case MIDI_CMD_COMMON_SYSEX:     return MidiSystemExclusiveAutomation; break;
53         default: return NullAutomation;
54         }
55 }
56
57 inline bool
58 parameter_is_midi(AutomationType type)
59 {
60         return (type >= MidiCCAutomation) && (type <= MidiChannelPressureAutomation);
61 }
62
63 }  // namespace ARDOUR
64
65 #endif /* __ardour_parameter_types_h__ */
66