19 #ifndef EVORAL_CONTROL_LIST_HPP
20 #define EVORAL_CONTROL_LIST_HPP
26 #include <boost/pool/pool.hpp>
27 #include <boost/pool/pool_alloc.hpp>
29 #include <glibmm/threads.h>
49 : when (w), value (v), coeff (0)
53 : when (other.when), value (other.value), coeff (0)
57 for (
size_t i = 0; i < 4; ++i)
58 coeff[i] = other.
coeff[i];
66 coeff =
new double[4];
68 coeff[0] = coeff[1] = coeff[2] = coeff[3] = 0.0;
94 void dump (std::ostream&);
100 virtual void freeze();
101 virtual void thaw ();
110 EventList::size_type
size()
const {
return _events.size(); }
112 Glib::Threads::RWLock::ReaderLock lm (_lock);
113 return _events.empty() ? 0.0 : _events.back()->when;
115 bool empty()
const {
return _events.empty(); }
118 _default_value = val;
122 void x_scale (
double factor);
123 bool extend_to (
double);
124 void slide (iterator before,
double distance);
125 void shift (
double before,
double distance);
127 virtual void add (
double when,
double value,
bool with_guards=
true,
bool with_default=
true);
128 virtual void editor_add (
double when,
double value);
130 void fast_simple_add (
double when,
double value);
132 void erase_range (
double start,
double end);
133 void erase (iterator);
134 void erase (iterator, iterator);
135 void erase (
double,
double);
137 void modify (iterator,
double,
double);
152 void thin (
double thinning_factor);
156 void clear (
double,
double);
168 void truncate_end (
double length);
169 void truncate_start (
double length);
171 iterator
begin() {
return _events.begin(); }
172 const_iterator
begin()
const {
return _events.begin(); }
173 iterator
end() {
return _events.end(); }
174 const_iterator
end()
const {
return _events.end(); }
175 reverse_iterator
rbegin() {
return _events.rbegin(); }
176 const_reverse_iterator
rbegin()
const {
return _events.rbegin(); }
177 reverse_iterator
rend() {
return _events.rend(); }
178 const_reverse_iterator
rend()
const {
return _events.rend(); }
184 std::pair<ControlList::iterator,ControlList::iterator> control_points_adjacent (
double when);
187 Glib::Threads::RWLock::WriterLock lm (_lock);
188 (obj.*method)(*
this);
192 Glib::Threads::RWLock::ReaderLock lm (_lock);
193 return unlocked_eval (where);
198 Glib::Threads::RWLock::ReaderLock lm (_lock, Glib::Threads::TRY_LOCK);
200 if ((ok = lm.locked())) {
201 return unlocked_eval (where);
215 std::pair<ControlList::const_iterator,ControlList::const_iterator>
range;
225 const EventList&
events()
const {
return _events; }
229 Glib::Threads::RWLock&
lock()
const {
return _lock; }
238 double unlocked_eval (
double x)
const;
240 bool rt_safe_earliest_event (
double start,
double& x,
double& y,
bool start_inclusive=
false)
const;
241 bool rt_safe_earliest_event_unlocked (
double start,
double& x,
double& y,
bool start_inclusive=
false)
const;
242 bool rt_safe_earliest_event_linear_unlocked (
double start,
double& x,
double& y,
bool inclusive)
const;
243 bool rt_safe_earliest_event_discrete_unlocked (
double start,
double& x,
double& y,
bool inclusive)
const;
246 void destroy_curve();
249 const Curve&
curve()
const { assert(_curve);
return *_curve; }
251 void mark_dirty ()
const;
260 void set_interpolation (InterpolationStyle);
263 virtual bool writing()
const {
return false; }
265 void start_write_pass (
double time);
266 void write_pass_finished (
double when,
double thinning_factor=0.0);
267 void set_in_write_pass (
bool,
bool add_point =
false,
double when = 0.0);
268 bool in_write_pass ()
const;
277 void invalidate_insert_iterator ();
282 double multipoint_eval (
double x)
const;
284 void build_search_cache_if_necessary (
double start)
const;
287 bool erase_range_internal (
double start,
double end, EventList &);
289 void maybe_add_insert_guard (
double when);
290 iterator erase_from_iterator_to (iterator iter,
double when);
291 bool maybe_insert_straight_line (
double when,
double value);
293 virtual void maybe_signal_changed ();
295 void _x_scale (
double factor);
300 mutable Glib::Threads::RWLock
_lock;
321 void unlocked_invalidate_insert_iterator ();
322 void add_guard_point (
double when);
327 #endif // EVORAL_CONTROL_LIST_HPP
const ControlEvent * front() const
const ParameterDescriptor & descriptor() const
void set_yrange(double min, double max)
bool operator!=(shared_ptr< T > const &a, shared_ptr< U > const &b)
double rt_safe_eval(double where, bool &ok)
Glib::Threads::RWLock _lock
std::list< ControlEvent * > EventList
ControlList::const_iterator first
double default_value() const
LIBARDOUR_API GQuark paste
EventList::const_reverse_iterator const_reverse_iterator
LIBARDOUR_API PBD::PropertyDescriptor< framepos_t > start
PBD::Signal0< void > Dirty
LookupCache & lookup_cache() const
bool did_write_during_pass
const_reverse_iterator rend() const
ParameterDescriptor _desc
SearchCache & search_cache() const
virtual bool writing() const
virtual bool touch_enabled() const
LIBARDOUR_API PBD::PropertyDescriptor< float > shift
double eval(double where)
void apply_to_points(T &obj, void(T::*method)(const ControlList &))
EventList::size_type size() const
PBD::Signal1< void, InterpolationStyle > InterpolationChanged
const Parameter & parameter() const
const_iterator begin() const
bool _changed_when_thawed
ControlEvent(const ControlEvent &other)
void set_parameter(const Parameter &p)
iterator most_recent_insert_iterator
InterpolationStyle interpolation() const
SearchCache _search_cache
std::pair< ControlList::const_iterator, ControlList::const_iterator > range
void reset_default(double val)
LIBEVORAL_API uint64_t ControlList
LIBARDOUR_API PBD::PropertyDescriptor< framepos_t > position
bool operator==(Range< T > a, Range< T > b)
Glib::Threads::RWLock & lock() const
EventList::const_iterator const_iterator
EventList::reverse_iterator reverse_iterator
ControlEvent(double w, double v)
const Curve & curve() const
LookupCache _lookup_cache
const_reverse_iterator rbegin() const
const ControlEvent * back() const
const_iterator end() const
virtual bool touching() const
void set_descriptor(const ParameterDescriptor &d)
static bool time_comparator(const ControlEvent *a, const ControlEvent *b)
EventList::iterator iterator
reverse_iterator rbegin()
double * coeff
double[4] allocated by Curve as needed
LIBARDOUR_API PBD::PropertyDescriptor< framecnt_t > length
const EventList & events() const
InterpolationStyle _interpolation