Ardour  8.12
parameter_types.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014-2015 David Robillard <d@drobilla.net>
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 along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #ifndef __ardour_parameter_types_h__
20 #define __ardour_parameter_types_h__
21 
22 #include <stdint.h>
23 
24 #include "ardour/types.h"
25 #include "evoral/Parameter.h"
26 #include "evoral/midi_events.h"
27 
28 namespace ARDOUR {
29 
30 inline uint8_t
32 {
33  switch (type) {
34  case MidiCCAutomation: return MIDI_CMD_CONTROL; break;
35  case MidiPgmChangeAutomation: return MIDI_CMD_PGM_CHANGE; break;
38  case MidiPitchBenderAutomation: return MIDI_CMD_BENDER; 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;
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]);
75  default:
77  }
78 }
79 
80 inline bool
82 {
83  return (type >= MidiCCAutomation) && (type <= MidiNotePressureAutomation);
84 }
85 
86 inline bool
88 {
89  AutomationType type = (AutomationType) t;
90  return (type >= MidiCCAutomation) && (type <= MidiNotePressureAutomation);
91 }
92 
93 } // namespace ARDOUR
94 
95 #endif /* __ardour_parameter_types_h__ */
96 
#define MIDI_CMD_NOTE_PRESSURE
Definition: midi_events.h:108
#define MIDI_CMD_BENDER
Definition: midi_events.h:112
#define MIDI_CMD_COMMON_SYSEX
Definition: midi_events.h:113
#define MIDI_CMD_PGM_CHANGE
Definition: midi_events.h:110
#define MIDI_CMD_CONTROL
Definition: midi_events.h:109
#define MIDI_CMD_CHANNEL_PRESSURE
Definition: midi_events.h:111
AutomationType midi_parameter_type(uint8_t status)
uint8_t parameter_midi_type(AutomationType type)
Evoral::Parameter midi_parameter(const uint8_t *buf, const uint32_t len)
bool parameter_is_midi(AutomationType type)
@ MidiNotePressureAutomation
@ MidiSystemExclusiveAutomation
@ MidiPitchBenderAutomation
@ MidiChannelPressureAutomation
uint32_t ParameterType