diff options
author | David Robillard <d@drobilla.net> | 2014-12-01 14:28:03 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2014-12-01 23:35:24 -0500 |
commit | 767c0238a34ef4acc4d345e88cd5ddb0c8a8e421 (patch) | |
tree | fed11fb6f4e4e08a7c35eb45f53aea70dc66e4f8 /libs/evoral/evoral | |
parent | cb8abbe8d2f0e4dfe52bd35613ebba7689628eca (diff) |
Replace half-baked param metadata with descriptor.
Among other things, this means that automation controls/lists have the actual
min/max/normal/toggled of parameters, and not those inferred from the Parameter
ID, which is not correct for things like plugin parameters.
Pushing things down to the Evoral::ParmeterDescriptor may be useful in the
future to have lists do smarter things based on parameter range, but currently
I have just pushed down the above-mentioned currently used attributes.
Diffstat (limited to 'libs/evoral/evoral')
-rw-r--r-- | libs/evoral/evoral/Control.hpp | 9 | ||||
-rw-r--r-- | libs/evoral/evoral/ControlList.hpp | 15 | ||||
-rw-r--r-- | libs/evoral/evoral/Parameter.hpp | 47 | ||||
-rw-r--r-- | libs/evoral/evoral/ParameterDescriptor.hpp | 42 | ||||
-rw-r--r-- | libs/evoral/evoral/Sequence.hpp | 4 | ||||
-rw-r--r-- | libs/evoral/evoral/TypeMap.hpp | 8 |
6 files changed, 68 insertions, 57 deletions
diff --git a/libs/evoral/evoral/Control.hpp b/libs/evoral/evoral/Control.hpp index ea1e9b89e5..d91c89bb74 100644 --- a/libs/evoral/evoral/Control.hpp +++ b/libs/evoral/evoral/Control.hpp @@ -26,11 +26,14 @@ #include "evoral/visibility.h" #include "evoral/Parameter.hpp" +#include "evoral/ParameterDescriptor.hpp" namespace Evoral { class ControlList; +class ParameterDescriptor; class Transport; +class TypeMap; /** Base class representing some kind of (automatable) control; a fader's gain, * for example, or a compressor plugin's threshold. @@ -38,11 +41,13 @@ class Transport; * The class knows the Evoral::Parameter that it is controlling, and has * a list of values for automation. */ - class LIBEVORAL_API Control { public: - Control(const Parameter& parameter, boost::shared_ptr<ControlList>); + Control(const Parameter& parameter, + const ParameterDescriptor& desc, + boost::shared_ptr<ControlList> list); + virtual ~Control() {} virtual void set_double (double val, double frame=0, bool to_list=false); diff --git a/libs/evoral/evoral/ControlList.hpp b/libs/evoral/evoral/ControlList.hpp index d6704c8e43..ed7fc75732 100644 --- a/libs/evoral/evoral/ControlList.hpp +++ b/libs/evoral/evoral/ControlList.hpp @@ -34,10 +34,12 @@ #include "evoral/types.hpp" #include "evoral/Range.hpp" #include "evoral/Parameter.hpp" +#include "evoral/ParameterDescriptor.hpp" namespace Evoral { class Curve; +class TypeMap; /** A single event (time-stamped value) for a control */ @@ -82,12 +84,12 @@ public: typedef EventList::const_iterator const_iterator; typedef EventList::const_reverse_iterator const_reverse_iterator; - ControlList (const Parameter& id); + ControlList (const Parameter& id, const ParameterDescriptor& desc); ControlList (const ControlList&); ControlList (const ControlList&, double start, double end); virtual ~ControlList(); - virtual boost::shared_ptr<ControlList> create(Parameter id); + virtual boost::shared_ptr<ControlList> create(const Parameter& id, const ParameterDescriptor& desc); void dump (std::ostream&); @@ -102,6 +104,9 @@ public: const Parameter& parameter() const { return _parameter; } void set_parameter(const Parameter& p) { _parameter = p; } + const ParameterDescriptor& descriptor() const { return _desc; } + void set_descriptor(const ParameterDescriptor& d) { _desc = d; } + EventList::size_type size() const { return _events.size(); } double length() const { Glib::Threads::Mutex::Lock lm (_lock); @@ -218,7 +223,7 @@ public: }; const EventList& events() const { return _events; } - double default_value() const { return _parameter.normal(); } + double default_value() const { return _default_value; } // FIXME: const violations for Curve Glib::Threads::Mutex& lock() const { return _lock; } @@ -288,10 +293,12 @@ protected: mutable LookupCache _lookup_cache; mutable SearchCache _search_cache; + mutable Glib::Threads::Mutex _lock; + Parameter _parameter; + ParameterDescriptor _desc; InterpolationStyle _interpolation; EventList _events; - mutable Glib::Threads::Mutex _lock; int8_t _frozen; bool _changed_when_thawed; double _min_yval; diff --git a/libs/evoral/evoral/Parameter.hpp b/libs/evoral/evoral/Parameter.hpp index 2164475cf9..c870fa8e99 100644 --- a/libs/evoral/evoral/Parameter.hpp +++ b/libs/evoral/evoral/Parameter.hpp @@ -28,7 +28,6 @@ namespace Evoral { - /** ID of a [play|record|automate]able parameter. * * A parameter is defined by (type, id, channel). Type is an integer which @@ -41,12 +40,10 @@ namespace Evoral { class LIBEVORAL_API Parameter { public: - Parameter(uint32_t type, uint8_t channel=0, uint32_t id=0) + inline Parameter(uint32_t type, uint8_t channel=0, uint32_t id=0) : _type(type), _id(id), _channel(channel) {} - virtual ~Parameter() {} - inline uint32_t type() const { return _type; } inline uint8_t channel() const { return _channel; } inline uint32_t id() const { return _id; } @@ -78,52 +75,12 @@ public: inline operator bool() const { return (_type != 0); } - /** Not used in indentity/comparison */ - struct Metadata { - Metadata(double low=0.0, double high=1.0, double mid=0.0, bool tog=false) - : min(low), max(high), normal(mid), toggled(tog) - {} - double min; - double max; - double normal; - bool toggled; - }; - - inline static void set_range(uint32_t type, double min, double max, double normal, bool toggled) { - _type_metadata[type] = Metadata(min, max, normal, toggled); - } - - inline void set_range(double min, double max, double normal, bool toggled) { - _metadata = boost::shared_ptr<Metadata>(new Metadata(min, max, normal, toggled)); - } - - inline Metadata& metadata() const { - if (_metadata) - return *_metadata.get(); - else - return _type_metadata[_type]; - } - - inline double min() const { return metadata().min; } - inline double max() const { return metadata().max; } - inline double normal() const { return metadata().normal; } - inline double toggled() const { return metadata().toggled; } - -protected: - // Default copy constructor is ok - - // ID (used in comparison) +private: uint32_t _type; uint32_t _id; uint8_t _channel; - - boost::shared_ptr<Metadata> _metadata; - - typedef std::map<uint32_t, Metadata> TypeMetadata; - static TypeMetadata _type_metadata; }; - } // namespace Evoral #endif // EVORAL_PARAMETER_HPP diff --git a/libs/evoral/evoral/ParameterDescriptor.hpp b/libs/evoral/evoral/ParameterDescriptor.hpp new file mode 100644 index 0000000000..0323db1753 --- /dev/null +++ b/libs/evoral/evoral/ParameterDescriptor.hpp @@ -0,0 +1,42 @@ +/* This file is part of Evoral. + * Copyright (C) 2000-2014 Paul Davis + * Author: David Robillard + * + * Evoral is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Evoral is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef EVORAL_PARAMETER_DESCRIPTOR_HPP +#define EVORAL_PARAMETER_DESCRIPTOR_HPP + +namespace Evoral { + +/** Description of the value range of a parameter or control. */ +struct ParameterDescriptor +{ + ParameterDescriptor() + : normal(0.0) + , lower(0.0) + , upper(0.0) + , toggled(false) + {} + + float normal; ///< Default value + float lower; ///< Minimum value (in Hz, for frequencies) + float upper; ///< Maximum value (in Hz, for frequencies) + bool toggled; ///< True iff parameter is boolean +}; + +} // namespace Evoral + +#endif // EVORAL_PARAMETER_DESCRIPTOR_HPP diff --git a/libs/evoral/evoral/Sequence.hpp b/libs/evoral/evoral/Sequence.hpp index e40c4da925..9aded0d9f0 100644 --- a/libs/evoral/evoral/Sequence.hpp +++ b/libs/evoral/evoral/Sequence.hpp @@ -30,13 +30,13 @@ #include "evoral/visibility.h" #include "evoral/types.hpp" #include "evoral/Note.hpp" -#include "evoral/Parameter.hpp" #include "evoral/ControlSet.hpp" #include "evoral/ControlList.hpp" #include "evoral/PatchChange.hpp" namespace Evoral { +class Parameter; class TypeMap; template<typename Time> class EventSink; template<typename Time> class Note; @@ -109,6 +109,8 @@ public: void append(const Event<Time>& ev, Evoral::event_id_t evid); + const TypeMap& type_map() const { return _type_map; } + inline size_t n_notes() const { return _notes.size(); } inline bool empty() const { return _notes.empty() && _sysexes.empty() && _patch_changes.empty() && ControlSet::controls_empty(); } diff --git a/libs/evoral/evoral/TypeMap.hpp b/libs/evoral/evoral/TypeMap.hpp index 987706e541..154cdff613 100644 --- a/libs/evoral/evoral/TypeMap.hpp +++ b/libs/evoral/evoral/TypeMap.hpp @@ -28,6 +28,7 @@ namespace Evoral { class Parameter; +class ParameterDescriptor; /** The applications passes one of these which provide the implementation * with required information about event types in an opaque, type neutral way @@ -50,11 +51,8 @@ public: */ virtual uint32_t midi_event_type(uint8_t status) const = 0; - /** Return true iff parameter should be locked to integer boundaries */ - virtual bool is_integer(const Evoral::Parameter& param) const = 0; - - /** Create a parameter with the given type ID */ - virtual Parameter new_parameter(uint32_t type, uint8_t channel, uint32_t id) const = 0; + /** Return the description of a parameter. */ + virtual const ParameterDescriptor& descriptor(const Parameter& param) const = 0; virtual std::string to_symbol(const Parameter& param) const = 0; }; |