2 Copyright (C) 2014 Paul Davis
3 Author: David Robillard
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.
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.
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.
21 #ifndef __ardour_parameter_types_h__
22 #define __ardour_parameter_types_h__
26 #include "ardour/types.h"
27 #include "evoral/Parameter.hpp"
28 #include "evoral/midi_events.h"
33 parameter_midi_type(AutomationType type)
36 case MidiCCAutomation: return MIDI_CMD_CONTROL; break;
37 case MidiPgmChangeAutomation: return MIDI_CMD_PGM_CHANGE; break;
38 case MidiChannelPressureAutomation: return MIDI_CMD_CHANNEL_PRESSURE; break;
39 case MidiPitchBenderAutomation: return MIDI_CMD_BENDER; break;
40 case MidiSystemExclusiveAutomation: return MIDI_CMD_COMMON_SYSEX; break;
46 midi_parameter_type(uint8_t status)
48 switch (status & 0xF0) {
49 case MIDI_CMD_CONTROL: return MidiCCAutomation; break;
50 case MIDI_CMD_PGM_CHANGE: return MidiPgmChangeAutomation; break;
51 case MIDI_CMD_CHANNEL_PRESSURE: return MidiChannelPressureAutomation; break;
52 case MIDI_CMD_BENDER: return MidiPitchBenderAutomation; break;
53 case MIDI_CMD_COMMON_SYSEX: return MidiSystemExclusiveAutomation; break;
54 default: return NullAutomation;
58 inline Evoral::Parameter
59 midi_parameter(const uint8_t* buf, const uint32_t len)
61 const uint8_t channel = buf[0] & 0x0F;
62 switch (midi_parameter_type(buf[0])) {
63 case MidiCCAutomation:
64 return Evoral::Parameter(MidiCCAutomation, channel, buf[1]);
65 case MidiPgmChangeAutomation:
66 return Evoral::Parameter(MidiPgmChangeAutomation, channel);
67 case MidiChannelPressureAutomation:
68 return Evoral::Parameter(MidiChannelPressureAutomation, channel);
69 case MidiPitchBenderAutomation:
70 return Evoral::Parameter(MidiPitchBenderAutomation, channel);
71 case MidiSystemExclusiveAutomation:
72 return Evoral::Parameter(MidiSystemExclusiveAutomation, channel);
74 return Evoral::Parameter(NullAutomation);
79 parameter_is_midi(AutomationType type)
81 return (type >= MidiCCAutomation) && (type <= MidiChannelPressureAutomation);
86 #endif /* __ardour_parameter_types_h__ */