Ardour  9.0-pre0-582-g084a23a80d
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 #pragma once
20 
21 #include <stdint.h>
22 
23 #include "ardour/types.h"
24 #include "evoral/Parameter.h"
25 #include "evoral/midi_events.h"
26 
27 namespace ARDOUR {
28 
29 inline uint8_t
31 {
32  switch (type) {
33  case MidiCCAutomation: return MIDI_CMD_CONTROL; break;
34  case MidiPgmChangeAutomation: return MIDI_CMD_PGM_CHANGE; break;
37  case MidiPitchBenderAutomation: return MIDI_CMD_BENDER; break;
39  default: return 0;
40  }
41 }
42 
43 inline AutomationType
44 midi_parameter_type(uint8_t status)
45 {
46  switch (status & 0xF0) {
47  case MIDI_CMD_CONTROL: return MidiCCAutomation; break;
48  case MIDI_CMD_PGM_CHANGE: return MidiPgmChangeAutomation; break;
51  case MIDI_CMD_BENDER: return MidiPitchBenderAutomation; break;
53  default: return NullAutomation;
54  }
55 }
56 
57 inline Evoral::Parameter
58 midi_parameter(const uint8_t* buf, const uint32_t len)
59 {
60  const uint8_t channel = buf[0] & 0x0F;
61  switch (midi_parameter_type(buf[0])) {
62  case MidiCCAutomation:
63  return Evoral::Parameter(MidiCCAutomation, channel, buf[1]);
74  default:
76  }
77 }
78 
79 inline bool
81 {
82  return (type >= MidiCCAutomation) && (type <= MidiNotePressureAutomation);
83 }
84 
85 inline bool
87 {
88  AutomationType type = (AutomationType) t;
89  return (type >= MidiCCAutomation) && (type <= MidiNotePressureAutomation);
90 }
91 
92 } // namespace ARDOUR
93 
94 
#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