1 /* This file is part of Evoral.
2 * Copyright (C) 2000-2014 Paul Davis
3 * Author: David Robillard
5 * Evoral is free software; you can redistribute it and/or modify it under the
6 * terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 2 of the License, or (at your option) any later
10 * Evoral is distributed in the hope that it will be useful, but WITHOUT ANY
11 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 #include "evoral/ParameterDescriptor.hpp"
23 ParameterDescriptor::ParameterDescriptor()
25 , datatype(Variant::NOTHING)
42 /* Set step, smallstep, and largestep, based on current description */
44 ParameterDescriptor::update_steps()
46 if (unit == ParameterDescriptor::MIDI_NOTE) {
47 step = smallstep = 1; // semitone
48 largestep = 12; // octave
49 } else if (integer_step) {
50 const float delta = upper - lower;
52 smallstep = delta / 10000.0f;
53 step = delta / 1000.0f;
54 largestep = delta / 40.0f;
56 smallstep = std::max(1.0, rint(smallstep));
57 step = std::max(1.0, rint(step));
58 largestep = std::max(1.0, rint(largestep));
60 /* else: leave all others as default '0'
61 * in that case the UI (eg. AutomationController::create)
62 * uses internal_to_interface() to map the value
63 * to an appropriate interface range