Remove ARDOUR::Parameter::is_integer.
[ardour.git] / libs / ardour / event_type_map.cc
1 /*
2     Copyright (C) 2008 Paul Davis
3     Author: Dave 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 #include <ardour/types.h>
22 #include <ardour/event_type_map.h>
23 #include <evoral/Parameter.hpp>
24 #include <evoral/midi_events.h>
25
26 namespace ARDOUR {
27
28 EventTypeMap EventTypeMap::event_type_map;
29
30 bool
31 EventTypeMap::type_is_midi(uint32_t type) const
32 {
33         return (type >= MidiCCAutomation) && (type <= MidiChannelPressureAutomation);
34 }
35
36 uint8_t
37 EventTypeMap::parameter_midi_type(const Evoral::Parameter& param) const
38 {
39         switch (param.type()) {
40         case MidiCCAutomation:              return MIDI_CMD_CONTROL; break; 
41         case MidiPgmChangeAutomation:       return MIDI_CMD_PGM_CHANGE; break; 
42         case MidiChannelPressureAutomation: return MIDI_CMD_CHANNEL_PRESSURE; break; 
43         case MidiPitchBenderAutomation:     return MIDI_CMD_BENDER; break; 
44         default: return 0;
45         }
46 }
47
48 uint32_t
49 EventTypeMap::midi_event_type(uint8_t status) const
50 {
51         switch (status & 0xF0) {
52         case MIDI_CMD_CONTROL:          return MidiCCAutomation; break;
53         case MIDI_CMD_PGM_CHANGE:       return MidiPgmChangeAutomation; break;
54         case MIDI_CMD_CHANNEL_PRESSURE: return MidiChannelPressureAutomation; break;
55         case MIDI_CMD_BENDER:           return MidiPitchBenderAutomation; break;
56         default: return 0;
57         }
58 }
59
60 bool
61 EventTypeMap::is_integer(const Evoral::Parameter& param) const
62 {
63         return (   param.type() >= MidiCCAutomation
64                         && param.type() <= MidiChannelPressureAutomation);
65 }
66
67 } // namespace ARDOUR
68