remove debugging output; properly handle cases in Curve::_get_vector() where the entire requested range for the vector is either before the first point in the curve (unlikely to happen because we typically add a guard point at zero) or entire after the last point in the curve
git-svn-id: svn://localhost/ardour2/branches/3.0@13582 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
9e84a2f931
commit
8ecabd0d37
@ -195,34 +195,50 @@ Curve::_get_vector (double x0, double x1, float *vec, int32_t veclen)
|
||||
int32_t original_veclen;
|
||||
int32_t npoints;
|
||||
|
||||
cerr << "Check1: veclen = " << veclen << endl;
|
||||
if (veclen == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((npoints = _list.events().size()) == 0) {
|
||||
for (i = 0; i < veclen; ++i) {
|
||||
/* no events in list, so just fill the entire array with the default value */
|
||||
for (int32_t i = 0; i < veclen; ++i) {
|
||||
vec[i] = _list.default_value();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
cerr << "Check2: veclen = " << veclen << endl;
|
||||
if (npoints == 1) {
|
||||
for (int32_t i = 0; i < veclen; ++i) {
|
||||
vec[i] = _list.events().front()->value;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* events is now known not to be empty */
|
||||
|
||||
max_x = _list.events().back()->when;
|
||||
min_x = _list.events().front()->when;
|
||||
|
||||
lx = max (min_x, x0);
|
||||
|
||||
if (x1 < 0) {
|
||||
x1 = _list.events().back()->when;
|
||||
if (x0 > max_x) {
|
||||
/* totally past the end - just fill the entire array with the final value */
|
||||
for (int32_t i = 0; i < veclen; ++i) {
|
||||
vec[i] = _list.events().back()->value;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
hx = min (max_x, x1);
|
||||
if (x1 < min_x) {
|
||||
/* totally before the first event - fill the entire array with
|
||||
* the initial value.
|
||||
*/
|
||||
for (int32_t i = 0; i < veclen; ++i) {
|
||||
vec[i] = _list.events().front()->value;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
original_veclen = veclen;
|
||||
|
||||
cerr << "Check3: veclen = " << veclen << endl;
|
||||
|
||||
if (x0 < min_x) {
|
||||
|
||||
/* fill some beginning section of the array with the
|
||||
@ -232,71 +248,36 @@ Curve::_get_vector (double x0, double x1, float *vec, int32_t veclen)
|
||||
double frac = (min_x - x0) / (x1 - x0);
|
||||
int64_t fill_len = (int64_t) floor (veclen * frac);
|
||||
|
||||
cerr << "fill_len = " << fill_len << endl;
|
||||
|
||||
fill_len = min (fill_len, (int64_t)veclen);
|
||||
|
||||
cerr << "fill_len2 = " << fill_len << endl;
|
||||
|
||||
for (i = 0; i < fill_len; ++i) {
|
||||
vec[i] = _list.events().front()->value;
|
||||
}
|
||||
|
||||
cerr << "adjust veclen from " << veclen << " to ";
|
||||
veclen -= fill_len;
|
||||
cerr << veclen << endl;
|
||||
vec += fill_len;
|
||||
}
|
||||
|
||||
cerr << "Check4: veclen = " << veclen << endl;
|
||||
|
||||
if (veclen && x1 > max_x) {
|
||||
|
||||
/* fill some end section of the array with the default or final value */
|
||||
|
||||
double frac = (x1 - max_x) / (x1 - x0);
|
||||
|
||||
cerr << "compute fill_len from " << original_veclen << " * " << frac
|
||||
<< " taken from " << (int64_t) x0 << " .. " << (int64_t) x0
|
||||
<< " min_x = " << (int64_t) min_x << " max_x = " << (int64_t) max_x
|
||||
<< endl;
|
||||
|
||||
int64_t fill_len = (int64_t) floor (original_veclen * frac);
|
||||
|
||||
float val;
|
||||
|
||||
cerr << "fill_len3 = " << fill_len << endl;
|
||||
fill_len = min (fill_len, (int64_t)veclen);
|
||||
|
||||
cerr << "fill_len4 = " << fill_len << endl;
|
||||
val = _list.events().back()->value;
|
||||
|
||||
i = veclen - fill_len;
|
||||
|
||||
for (i = veclen - fill_len; i < veclen; ++i) {
|
||||
vec[i] = val;
|
||||
}
|
||||
|
||||
cerr << "adjust veclen2 from " << veclen << " to ";
|
||||
veclen -= fill_len;
|
||||
cerr << veclen << endl;
|
||||
}
|
||||
|
||||
cerr << "Check5: veclen = " << veclen << endl;
|
||||
|
||||
if (veclen == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (npoints == 1) {
|
||||
|
||||
for (i = 0; i < veclen; ++i) {
|
||||
vec[i] = _list.events().front()->value;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
cerr << "Check6: veclen = " << veclen << endl;
|
||||
lx = max (min_x, x0);
|
||||
hx = min (max_x, x1);
|
||||
|
||||
if (npoints == 2) {
|
||||
|
||||
@ -333,14 +314,10 @@ Curve::_get_vector (double x0, double x1, float *vec, int32_t veclen)
|
||||
return;
|
||||
}
|
||||
|
||||
cerr << "Check7: veclen = " << veclen << endl;
|
||||
|
||||
if (_dirty) {
|
||||
solve ();
|
||||
}
|
||||
|
||||
cerr << "Check8: veclen = " << veclen << endl;
|
||||
|
||||
rx = lx;
|
||||
|
||||
double dx = 0;
|
||||
@ -348,8 +325,6 @@ Curve::_get_vector (double x0, double x1, float *vec, int32_t veclen)
|
||||
dx = (hx - lx) / (veclen - 1);
|
||||
}
|
||||
|
||||
cerr << "Check9: veclen = " << veclen << endl;
|
||||
|
||||
for (i = 0; i < veclen; ++i, rx += dx) {
|
||||
vec[i] = multipoint_eval (rx);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user