8916f081a38be3c4cc3f9fc1683e4c6b62aee271
[ardour.git] / libs / ardour / ardour / parameter_descriptor.h
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 it
6     under the terms of the GNU General Public License as published by the Free
7     Software Foundation; either version 2 of the License, or (at your option)
8     any later version.
9
10     This program is distributed in the hope that it will be useful, but WITHOUT
11     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13     for more details.
14
15     You should have received a copy of the GNU General Public License along
16     with this program; if not, write to the Free Software Foundation, Inc.,
17     675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #ifndef __ardour_parameter_descriptor_h__
21 #define __ardour_parameter_descriptor_h__
22
23 #include "ardour/variant.h"
24 #include "evoral/Parameter.hpp"
25
26 namespace ARDOUR {
27
28 typedef std::map<const std::string, const float> ScalePoints;
29
30 /** Descriptor of a parameter or control.
31  *
32  * Essentially a union of LADSPA, VST and LV2 info.
33  */
34 struct ParameterDescriptor
35 {
36         ParameterDescriptor(const Evoral::Parameter& parameter)
37                 : key((uint32_t)-1)
38                 , datatype(Variant::VOID)
39                 , normal(parameter.normal())
40                 , lower(parameter.min())
41                 , upper(parameter.max())
42                 , step(0)
43                 , smallstep((upper - lower) / 100.0)
44                 , largestep((upper - lower) / 10.0)
45                 , integer_step(false)
46                 , toggled(parameter.toggled())
47                 , logarithmic(false)
48                 , sr_dependent(false)
49                 , min_unbound(0)
50                 , max_unbound(0)
51                 , enumeration(false)
52                 , midinote(false)
53         {}
54
55         ParameterDescriptor()
56                 : key((uint32_t)-1)
57                 , datatype(Variant::VOID)
58                 , normal(0)
59                 , lower(0)
60                 , upper(0)
61                 , step(0)
62                 , smallstep(0)
63                 , largestep(0)
64                 , integer_step(false)
65                 , toggled(false)
66                 , logarithmic(false)
67                 , sr_dependent(false)
68                 , min_unbound(0)
69                 , max_unbound(0)
70                 , enumeration(false)
71                 , midinote(false)
72         {}
73
74         std::string                    label;
75         boost::shared_ptr<ScalePoints> scale_points;
76         uint32_t                       key;  ///< for properties
77         Variant::Type                  datatype;  ///< for properties
78         float                          normal;
79         float                          lower;  ///< for frequencies, this is in Hz (not a fraction of the sample rate)
80         float                          upper;  ///< for frequencies, this is in Hz (not a fraction of the sample rate)
81         float                          step;
82         float                          smallstep;
83         float                          largestep;
84         bool                           integer_step;
85         bool                           toggled;
86         bool                           logarithmic;
87         bool                           sr_dependent;
88         bool                           min_unbound;
89         bool                           max_unbound;
90         bool                           enumeration;
91         bool                           midinote;  ///< only used if integer_step is also true
92 };
93
94 } // namespace ARDOUR
95
96 #endif // __ardour_parameter_descriptor_h__