ardour
parameter_types.h
Go to the documentation of this file.
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/Parameter.hpp"
28 #include "evoral/midi_events.h"
29 
30 namespace ARDOUR {
31 
32 inline uint8_t
34 {
35  switch (type) {
36  case MidiCCAutomation: return MIDI_CMD_CONTROL; break;
37  case MidiPgmChangeAutomation: return MIDI_CMD_PGM_CHANGE; break;
39  case MidiPitchBenderAutomation: return MIDI_CMD_BENDER; break;
41  default: return 0;
42  }
43 }
44 
45 inline AutomationType
46 midi_parameter_type(uint8_t status)
47 {
48  switch (status & 0xF0) {
49  case MIDI_CMD_CONTROL: return MidiCCAutomation; break;
50  case MIDI_CMD_PGM_CHANGE: return MidiPgmChangeAutomation; break;
52  case MIDI_CMD_BENDER: return MidiPitchBenderAutomation; break;
54  default: return NullAutomation;
55  }
56 }
57 
58 inline Evoral::Parameter
59 midi_parameter(const uint8_t* buf, const uint32_t len)
60 {
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]);
73  default:
75  }
76 }
77 
78 inline bool
80 {
81  return (type >= MidiCCAutomation) && (type <= MidiChannelPressureAutomation);
82 }
83 
84 } // namespace ARDOUR
85 
86 #endif /* __ardour_parameter_types_h__ */
87 
#define MIDI_CMD_CHANNEL_PRESSURE
Definition: midi_events.h:112
#define MIDI_CMD_PGM_CHANGE
Definition: midi_events.h:111
#define MIDI_CMD_BENDER
Definition: midi_events.h:113
Evoral::Parameter midi_parameter(const uint8_t *buf, const uint32_t len)
#define MIDI_CMD_CONTROL
Definition: midi_events.h:110
Definition: amp.h:29
AutomationType
Definition: types.h:121
#define MIDI_CMD_COMMON_SYSEX
Definition: midi_events.h:114
bool parameter_is_midi(AutomationType type)
AutomationType midi_parameter_type(uint8_t status)
uint8_t parameter_midi_type(AutomationType type)