1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
/*
Copyright (C) 2007 Paul Davis
Author: Dave Robillard
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option)
any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __ardour_parameter_h__
#define __ardour_parameter_h__
#include <string>
#include <pbd/compose.h>
#include <pbd/error.h>
#include <ardour/types.h>
#include <evoral/Parameter.hpp>
#include <evoral/MIDIParameters.hpp>
namespace ARDOUR {
/** ID of an automatable parameter.
*
* A given automatable object has a number of automatable parameters. This is
* the unique ID for those parameters. Anything automatable (AutomationList,
* Curve) must have unique Parameter ID with respect to it's Automatable parent.
*
* These are fast to compare, but passing a (const) reference around is
* probably more efficient than copying because the Parameter contains
* metadata not used for comparison.
*
* See evoral/Parameter.hpp for precise definition.
*/
class Parameter : public Evoral::Parameter
{
public:
Parameter(AutomationType type = NullAutomation, uint32_t id=0, uint8_t channel=0)
: Evoral::Parameter((uint32_t)type, channel, id)
{
init_metadata(type);
}
Parameter(const Evoral::Parameter& copy)
: Evoral::Parameter(copy)
{
}
static void init_metadata(AutomationType type) {
double min = 0.0f;
double max = 1.0f;
double normal = 0.0f;
switch(type) {
case NullAutomation:
case GainAutomation:
max = 2.0f;
normal = 1.0f;
break;
case PanAutomation:
normal = 0.5f;
break;
case PluginAutomation:
case SoloAutomation:
case MuteAutomation:
case FadeInAutomation:
case FadeOutAutomation:
case EnvelopeAutomation:
max = 2.0f;
normal = 1.0f;
break;
case MidiCCAutomation:
case MidiPgmChangeAutomation:
case MidiChannelPressureAutomation:
Evoral::MIDI::controller_range(min, max, normal); break;
case MidiPitchBenderAutomation:
Evoral::MIDI::bender_range(min, max, normal); break;
}
set_range(type, min, max, normal);
}
Parameter(const std::string& str);
inline AutomationType type() const { return (AutomationType)_type; }
std::string symbol() const;
inline operator Parameter() { return (Parameter)*this; }
};
} // namespace ARDOUR
#endif // __ardour_parameter_h__
|