27 #include <glibmm/threads.h>
60 vector<double> x(npoints);
61 vector<double> y(npoints);
63 ControlList::EventList::const_iterator xx;
66 x[i] = (double) (*xx)->when;
67 y[i] = (
double) (*xx)->value;
70 double lp0, lp1, fpone;
72 lp0 = (x[1] - x[0])/(y[1] - y[0]);
73 lp1 = (x[2] - x[1])/(y[2] - y[1]);
78 fpone = 2 / (lp1 + lp0);
92 xdelta = x[i] - x[i-1];
93 xdelta2 = xdelta * xdelta;
94 ydelta = y[i] - y[i-1];
103 fplast = ((3 * (y[1] - y[0]) / (2 * (x[1] - x[0]))) - (fpone * 0.5));
109 }
else if (i == npoints - 1) {
113 fpi = ((3 * ydelta) / (2 * xdelta)) - (fplast * 0.5);
119 double slope_before = ((x[i+1] - x[i]) / (y[i+1] - y[i]));
120 double slope_after = (xdelta / ydelta);
122 if (slope_after * slope_before < 0.0) {
126 fpi = 2 / (slope_before + slope_after);
132 fppL = (((-2 * (fpi + (2 * fplast))) / (xdelta))) +
133 ((6 * ydelta) / xdelta2);
135 fppR = (2 * ((2 * fpi) + fplast) / xdelta) -
136 ((6 * ydelta) / xdelta2);
142 d = (fppR - fppL) / (6 * xdelta);
143 c = ((x[i] * fppL) - (x[i-1] * fppR))/(2 * xdelta);
148 xim12 = x[i-1] * x[i-1];
149 xim13 = xim12 * x[i-1];
153 b = (ydelta - (c * (xi2 - xim12)) - (d * (xi3 - xim13))) / xdelta;
157 (*xx)->create_coeffs();
158 (*xx)->coeff[0] = y[i-1] - (b * x[i-1]) - (c * xim12) - (d * xim13);
174 Glib::Threads::RWLock::ReaderLock lm(
_list.
lock(), Glib::Threads::TRY_LOCK);
187 Glib::Threads::RWLock::ReaderLock lm(
_list.
lock());
194 double rx, lx, hx, max_x, min_x;
196 int32_t original_veclen;
205 for (int32_t i = 0; i < veclen; ++i) {
212 for (int32_t i = 0; i < veclen; ++i) {
225 for (int32_t i = 0; i < veclen; ++i) {
235 for (int32_t i = 0; i < veclen; ++i) {
241 original_veclen = veclen;
249 double frac = (min_x - x0) / (x1 - x0);
250 int64_t fill_len = (int64_t) floor (veclen * frac);
252 fill_len = min (fill_len, (int64_t)veclen);
254 for (i = 0; i < fill_len; ++i) {
262 if (veclen && x1 > max_x) {
266 double frac = (x1 - max_x) / (x1 - x0);
267 int64_t fill_len = (int64_t) floor (original_veclen * frac);
270 fill_len = min (fill_len, (int64_t)veclen);
273 for (i = veclen - fill_len; i < veclen; ++i) {
280 lx = max (min_x, x0);
281 hx = min (max_x, x1);
305 for (
int i = 0; i < veclen; ++i) {
306 vec[i] = (lx * (m_num / m_den) + m_num * i * dx_num / (m_den * dx_den)) + c;
309 vec[0] = lx * (m_num / m_den) + c;
323 dx = (hx - lx) / (veclen - 1);
326 for (i = 0; i < veclen; ++i, rx += dx) {
346 pair<ControlList::EventList::const_iterator,ControlList::EventList::const_iterator> range;
350 if ((lookup_cache.
left < 0) ||
351 ((lookup_cache.
left > x) ||
353 ((*lookup_cache.
range.second)->when < x))) {
360 range = lookup_cache.
range;
373 if (range.first == range.second) {
377 lookup_cache.
left = x;
397 return before->
value;
400 double tdelta = x - before->
when;
401 double trange = after->
when - before->
when;
408 return before->
value + (vdelta * (tdelta / trange));
414 lookup_cache.
left = -1;
415 return (*range.first)->value;
425 static_cast<Evoral::Curve*
>(arg)->get_vector (x0, x1, vec, vecsize);
double unlocked_eval(double where)
bool rt_safe_get_vector(double x0, double x1, float *arg, int32_t veclen)
double default_value() const
const ControlList & _list
void get_vector(double x0, double x1, float *arg, int32_t veclen)
LookupCache & lookup_cache() const
double unlocked_eval(double x) const
double multipoint_eval(double x)
InterpolationStyle interpolation() const
std::pair< ControlList::const_iterator, ControlList::const_iterator > range
void curve_get_vector_from_c(void *arg, double x0, double x1, float *vec, int32_t vecsize)
Glib::Threads::RWLock & lock() const
void _get_vector(double x0, double x1, float *arg, int32_t veclen)
static bool time_comparator(const ControlEvent *a, const ControlEvent *b)
double * coeff
double[4] allocated by Curve as needed
const EventList & events() const