2 Copyright (C) 2014 Paul Davis
3 Author: David Robillard
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)
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
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.
20 #ifndef __ardour_parameter_descriptor_h__
21 #define __ardour_parameter_descriptor_h__
23 #include "ardour/variant.h"
24 #include "evoral/Parameter.hpp"
28 typedef std::map<const std::string, const float> ScalePoints;
30 /** Descriptor of a parameter or control.
32 * Essentially a union of LADSPA, VST and LV2 info.
34 struct ParameterDescriptor
39 MIDI_NOTE, ///< MIDI note number
42 ParameterDescriptor(const Evoral::Parameter& parameter)
44 , datatype(Variant::VOID)
45 , normal(parameter.normal())
46 , lower(parameter.min())
47 , upper(parameter.max())
48 , step((upper - lower) / 100.0f)
49 , smallstep((upper - lower) / 1000.0f)
50 , largestep((upper - lower) / 10.0f)
51 , integer_step(parameter.type() >= MidiCCAutomation &&
52 parameter.type() <= MidiChannelPressureAutomation)
53 , toggled(parameter.toggled())
60 if (parameter.type() == GainAutomation) {
67 , datatype(Variant::VOID)
83 /// Set step, smallstep, and largestep, based on current description
85 if (unit == ParameterDescriptor::MIDI_NOTE) {
86 step = smallstep = 1; // semitone
87 largestep = 12; // octave
89 const float delta = upper - lower;
91 step = delta / 1000.0f;
92 smallstep = delta / 10000.0f;
93 largestep = delta / 10.0f;
97 largestep = rint(largestep);
98 // leave smallstep alone for fine tuning
104 boost::shared_ptr<ScalePoints> scale_points;
105 uint32_t key; ///< for properties
106 Variant::Type datatype; ///< for properties
109 float lower; ///< for frequencies, this is in Hz (not a fraction of the sample rate)
110 float upper; ///< for frequencies, this is in Hz (not a fraction of the sample rate)
123 } // namespace ARDOUR
125 #endif // __ardour_parameter_descriptor_h__