}
}
+void FloatAutos::set_proxy(int orig_scale, int new_scale)
+{
+ float orig_value;
+ orig_value = ((FloatAuto*)default_auto)->value * orig_scale;
+ ((FloatAuto*)default_auto)->value = orig_value / new_scale;
+
+ for( FloatAuto *current= (FloatAuto*)first; current; current=(FloatAuto*)NEXT ) {
+ orig_value = current->value * orig_scale;
+ current->value = orig_value / new_scale;
+ orig_value = current->control_in_value * orig_scale;
+ current->control_in_value = orig_value / new_scale;
+ orig_value = current->control_out_value * orig_scale;
+ current->control_out_value = orig_value / new_scale;
+ }
+}
+
void FloatAutos::dump()
{
printf(" FloatAutos::dump %p\n", this);
length += start;
start = 0;
}
- int64_t end = start + length;
- double value = 0, track_length = track->get_length();
- int64_t pos = start, len = track->to_units(track_length,0);
- if( end > len ) end = len;
+ double value = 0;
+ int64_t pos = start, len = length, end = pos + len;
while( pos < end ) {
- int64_t prev_pos = 0, next_pos = len;
- FloatAuto *prev = 0, *next = 0;
- prev = (FloatAuto*)get_prev_auto(pos, direction, (Auto* &)prev, 0);
+ int64_t prev_pos = 0, next_pos = end;
+ Auto *zprev = 0, *znext = 0;
+ FloatAuto *prev = (FloatAuto*)get_prev_auto(pos, direction, zprev, 0);
if( prev ) prev_pos = prev->position;
- next = (FloatAuto*)get_next_auto(pos, direction, (Auto* &)next, 0);
+ FloatAuto *next = (FloatAuto*)get_next_auto(pos, direction, znext, 0);
if( next ) next_pos = next->position;
if( !prev && !next ) prev = next = (FloatAuto*)default_auto;
else if( !prev ) prev = next;
return value + 1e-6;
}
+int64_t FloatAutos::speed_position(double pos)
+{
+ double length = track->get_length();
+ int64_t l = -1, r = track->to_units(length, 1);
+ if( r < 1 ) r = 1;
+ for( int i=32; --i >= 0 && automation_integral(0,r,PLAY_FORWARD) <= pos; r*=2 );
+ for( int i=64; --i >= 0 && (r-l)>1; ) {
+ int64_t m = (l + r) / 2;
+ double t = automation_integral(0,m,PLAY_FORWARD) - pos;
+ *(t >= 0 ? &r : &l) = m;
+ }
+ return r;
+}
+