Ardour  9.0-pre0-582-g084a23a80d
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 #pragma once
21 
22 #include "pbd/natsort.h"
23 #include "ardour/types.h"
24 #include "ardour/variant.h"
25 
26 #include "evoral/Parameter.h"
28 
29 namespace ARDOUR {
30 
32  bool operator() (std::string const& a, std::string const& b) const {
33  return PBD::numerically_less (a.c_str(), b.c_str());
34  }
35 };
36 
37 typedef std::map<const std::string, const float, CompareNumericallyLess> ScalePoints;
38 
44 {
45  enum Unit {
46  NONE,
47  DB,
49  HZ,
50  };
51 
52  static std::string midi_note_name (uint8_t, bool translate=true);
53 
55  typedef std::map<std::string, uint8_t> NameNumMap;
56  static std::string normalize_note_name(const std::string& name);
58  static uint8_t midi_note_num (const std::string& name);
59 
61 
63 
75  float to_interface (float v, bool rotary = false) const;
76 
88  float from_interface (float v, bool rotary = false) const;
89 
90  bool is_linear () const;
91  float compute_delta (float from, float to) const;
92  float apply_delta (float value, float delta) const;
93 
94  /* find the closest scale-point, return the internal value of
95  * the prev/next scale-point (no wrap-around)
96  *
97  * If the given parameter is not en enum, the given val is returned.
98  *
99  * @param val internal (not interface) value
100  * @param prev if true, step to prev scale-point, otherwise next
101  * @return internal value, suitable for set_value()
102  */
103  float step_enum (float val, bool prev) const;
104 
106  void update_steps();
107 
108  std::string label;
109  std::string print_fmt;
110  std::shared_ptr<ScalePoints> scale_points;
111  uint32_t key;
115  float step;
116  float smallstep;
117  float largestep;
122  uint32_t display_priority;
123 };
124 
125 } // namespace ARDOUR
126 
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)