Ardour  8.12
parameter_descriptor.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014-2017 Robin Gareus <robin@gareus.org>
3  * Copyright (C) 2014 David Robillard <d@drobilla.net>
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 along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef __ardour_parameter_descriptor_h__
21 #define __ardour_parameter_descriptor_h__
22 
23 #include "pbd/natsort.h"
24 #include "ardour/types.h"
25 #include "ardour/variant.h"
26 
27 #include "evoral/Parameter.h"
29 
30 namespace ARDOUR {
31 
33  bool operator() (std::string const& a, std::string const& b) const {
34  return PBD::numerically_less (a.c_str(), b.c_str());
35  }
36 };
37 
38 typedef std::map<const std::string, const float, CompareNumericallyLess> ScalePoints;
39 
45 {
46  enum Unit {
47  NONE,
48  DB,
50  HZ,
51  };
52 
53  static std::string midi_note_name (uint8_t, bool translate=true);
54 
56  typedef std::map<std::string, uint8_t> NameNumMap;
57  static std::string normalize_note_name(const std::string& name);
59  static uint8_t midi_note_num (const std::string& name);
60 
62 
64 
76  float to_interface (float v, bool rotary = false) const;
77 
89  float from_interface (float v, bool rotary = false) const;
90 
91  bool is_linear () const;
92  float compute_delta (float from, float to) const;
93  float apply_delta (float value, float delta) const;
94 
95  /* find the closest scale-point, return the internal value of
96  * the prev/next scale-point (no wrap-around)
97  *
98  * If the given parameter is not en enum, the given val is returned.
99  *
100  * @param val internal (not interface) value
101  * @param prev if true, step to prev scale-point, otherwise next
102  * @return internal value, suitable for set_value()
103  */
104  float step_enum (float val, bool prev) const;
105 
107  void update_steps();
108 
109  std::string label;
110  std::string print_fmt;
111  std::shared_ptr<ScalePoints> scale_points;
112  uint32_t key;
116  float step;
117  float smallstep;
118  float largestep;
123  uint32_t display_priority;
124 };
125 
126 } // namespace ARDOUR
127 
128 #endif // __ardour_parameter_descriptor_h__
GtkImageIconNameData name
Definition: gtkimage.h:6
#define LIBARDOUR_API
std::map< const std::string, const float, CompareNumericallyLess > ScalePoints
bool numerically_less(const char *a, const char *b)
Definition: natsort.h:76
bool operator()(std::string const &a, std::string const &b) const
std::string print_fmt
format string for pretty printing
float to_interface(float v, bool rotary=false) const
static uint8_t midi_note_num(const std::string &name)
float step_enum(float val, bool prev) const
std::shared_ptr< ScalePoints > scale_points
float compute_delta(float from, float to) const
Variant::Type datatype
for properties
std::map< std::string, uint8_t > NameNumMap
float apply_delta(float value, float delta) const
static std::string normalize_note_name(const std::string &name)
static NameNumMap build_midi_name2num()
float from_interface(float v, bool rotary=false) const
uint32_t display_priority
higher is more important http://lv2plug.in/ns/ext/port-props#displayPriority
static std::string midi_note_name(uint8_t, bool translate=true)
ParameterDescriptor(const Evoral::Parameter &parameter)