X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fevoral%2Fevoral%2FControlList.hpp;h=16d0400145b239d8fa87caa3615baafc6ddfefd1;hb=b83f21c3cf6f9385697ce4b2ca2b0f840a8438aa;hp=ce5a98261b4b9c252efe5b2a6c859937628f35a5;hpb=63189be1df97d5a8659af8b76d1ca6b10d0e9627;p=ardour.git diff --git a/libs/evoral/evoral/ControlList.hpp b/libs/evoral/evoral/ControlList.hpp index ce5a98261b..16d0400145 100644 --- a/libs/evoral/evoral/ControlList.hpp +++ b/libs/evoral/evoral/ControlList.hpp @@ -1,16 +1,16 @@ /* This file is part of Evoral. * Copyright (C) 2008 Dave Robillard * Copyright (C) 2000-2008 Paul Davis - * + * * 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 @@ -24,6 +24,7 @@ #include #include #include +#include "pbd/signals.h" #include "evoral/types.hpp" #include "evoral/Parameter.hpp" @@ -38,7 +39,7 @@ struct ControlEvent { : when (w), value (v), coeff (0) {} - ControlEvent (const ControlEvent& other) + ControlEvent (const ControlEvent& other) : when (other.when), value (other.value), coeff (0) { if (other.coeff) { @@ -49,11 +50,11 @@ struct ControlEvent { } ~ControlEvent() { if (coeff) delete[] coeff; } - + void create_coeffs() { if (!coeff) coeff = new double[4]; - + coeff[0] = coeff[1] = coeff[2] = coeff[3] = 0.0; } @@ -88,14 +89,15 @@ public: ControlList (const ControlList&); ControlList (const ControlList&, double start, double end); virtual ~ControlList(); - + virtual boost::shared_ptr create(Parameter id); - + ControlList& operator= (const ControlList&); bool operator== (const ControlList&); - - void freeze(); - void thaw (); + + virtual void freeze(); + virtual void thaw (); + bool frozen() const { return _frozen; } const Parameter& parameter() const { return _parameter; } void set_parameter(const Parameter& p) { _parameter = p; } @@ -111,29 +113,26 @@ public: void x_scale (double factor); bool extend_to (double); void slide (iterator before, double distance); + void shift (double before, double distance); - void reposition_for_rt_add (double when); void rt_add (double when, double value); void add (double when, double value); void fast_simple_add (double when, double value); + void merge_nascent (double when); void reset_range (double start, double end); void erase_range (double start, double end); void erase (iterator); void erase (iterator, iterator); - void move_ranges (std::list< RangeMove > const &); + bool move_ranges (std::list< RangeMove > const &); void modify (iterator, double, double); boost::shared_ptr cut (double, double); boost::shared_ptr copy (double, double); void clear (double, double); - boost::shared_ptr cut (iterator, iterator); - boost::shared_ptr copy (iterator, iterator); - void clear (iterator, iterator); - bool paste (ControlList&, double position, float times); - + void set_yrange (double min, double max) { _min_yval = min; _max_yval = max; @@ -180,7 +179,7 @@ public: } } - static inline bool time_comparator (const ControlEvent* a, const ControlEvent* b) { + static inline bool time_comparator (const ControlEvent* a, const ControlEvent* b) { return a->when < b->when; } @@ -191,12 +190,11 @@ public: std::pair range; }; - /** Lookup cache for point finding, range contains points between left and right */ + /** Lookup cache for point finding, range contains points after left */ struct SearchCache { - SearchCache() : left(-1), right(-1) {} - double left; /* leftmost x coordinate used when finding "range" */ - double right; /* rightmost x coordinate used when finding "range" */ - std::pair range; + SearchCache () : left(-1) {} + double left; /* leftmost x coordinate used when finding "first" */ + ControlList::const_iterator first; }; const EventList& events() const { return _events; } @@ -209,21 +207,23 @@ public: /** Called by locked entry point and various private * locations where we already hold the lock. - * + * * FIXME: Should this be private? Curve needs it.. */ double unlocked_eval (double x) const; - bool rt_safe_earliest_event (double start, double end, double& x, double& y, bool start_inclusive=false) const; - bool rt_safe_earliest_event_unlocked (double start, double end, double& x, double& y, bool start_inclusive=false) const; + bool rt_safe_earliest_event (double start, double& x, double& y, bool start_inclusive=false) const; + bool rt_safe_earliest_event_unlocked (double start, double& x, double& y, bool start_inclusive=false) const; + bool rt_safe_earliest_event_linear_unlocked (double start, double& x, double& y, bool inclusive) const; + bool rt_safe_earliest_event_discrete_unlocked (double start, double& x, double& y, bool inclusive) const; void create_curve(); void destroy_curve(); Curve& curve() { assert(_curve); return *_curve; } const Curve& curve() const { assert(_curve); return *_curve; } - - virtual void mark_dirty () const; + + void mark_dirty () const; enum InterpolationStyle { Discrete, @@ -232,44 +232,63 @@ public: }; InterpolationStyle interpolation() const { return _interpolation; } - void set_interpolation(InterpolationStyle style) { _interpolation = style; } + void set_interpolation (InterpolationStyle); + + virtual bool touching() const { return false; } + virtual bool writing() const { return false; } + virtual bool touch_enabled() const { return false; } + void write_pass_finished (double when); + /** Emitted when mark_dirty() is called on this object */ + mutable PBD::Signal0 Dirty; + /** Emitted when our interpolation style changes */ + PBD::Signal1 InterpolationChanged; + protected: /** Called by unlocked_eval() to handle cases of 3 or more control points. */ - double multipoint_eval (double x) const; - - void build_search_cache_if_necessary(double start, double end) const; + double multipoint_eval (double x) const; - bool rt_safe_earliest_event_discrete_unlocked (double start, double end, double& x, double& y, bool inclusive) const; - bool rt_safe_earliest_event_linear_unlocked (double start, double end, double& x, double& y, bool inclusive) const; + void build_search_cache_if_necessary (double start) const; boost::shared_ptr cut_copy_clear (double, double, int op); bool erase_range_internal (double start, double end, EventList &); virtual void maybe_signal_changed (); - + void _x_scale (double factor); - mutable LookupCache _lookup_cache; - mutable SearchCache _search_cache; - - Parameter _parameter; - InterpolationStyle _interpolation; - EventList _events; - mutable Glib::Mutex _lock; - int8_t _frozen; - bool _changed_when_thawed; - bool _new_value; - double _max_xval; - double _min_yval; - double _max_yval; - double _default_value; - bool _sort_pending; - iterator _rt_insertion_point; - double _rt_pos; + mutable LookupCache _lookup_cache; + mutable SearchCache _search_cache; + + Parameter _parameter; + InterpolationStyle _interpolation; + EventList _events; + mutable Glib::Mutex _lock; + int8_t _frozen; + bool _changed_when_thawed; + double _max_xval; + double _min_yval; + double _max_yval; + double _default_value; + bool _sort_pending; Curve* _curve; + + struct NascentInfo { + EventList events; + bool is_touch; + double start_time; + double end_time; + + NascentInfo (bool touching, double start = -1.0) + : is_touch (touching) + , start_time (start) + , end_time (-1.0) + {} + }; + + std::list nascent; }; } // namespace Evoral