+ if (ts->type() == TempoSection::Constant) {
+ ts->set_end_note_types_per_minute (new_bpm);
+ }
+
+ recompute_map (_metrics);
+
+ can_solve = true;
+ }
+
+ if (next_t->type() == TempoSection::Constant || next_t->c() == 0.0) {
+ if (frame > tempo_copy->frame() + min_dframe && end_frame > tempo_copy->frame() + min_dframe) {
+
+ new_next_bpm = next_t->note_types_per_minute() * ((next_to_next_t->minute() - old_next_minute)
+ / (double) ((old_next_to_next_minute) - old_next_minute));
+
+ } else {
+ new_next_bpm = next_t->note_types_per_minute();
+ }
+
+ next_t->set_note_types_per_minute (new_next_bpm);
+ recompute_tempi (future_map);
+
+ if (check_solved (future_map)) {
+ for (Metrics::const_iterator i = _metrics.begin(); i != _metrics.end(); ++i) {
+ if ((*i)->is_tempo() && (*i)->minute() > ts->minute()) {
+ next_t = static_cast<TempoSection*> (*i);
+ break;
+ }
+ }
+
+ if (!next_t) {
+ return false;
+ }
+ next_t->set_note_types_per_minute (new_next_bpm);
+ recompute_map (_metrics);
+ can_solve = true;
+ }
+ } else {
+ double next_frame_ratio = 1.0;
+ double copy_frame_ratio = 1.0;
+
+ if (next_to_next_t) {
+ next_frame_ratio = (next_to_next_t->minute() - old_next_minute) / (old_next_to_next_minute - old_next_minute);
+
+ copy_frame_ratio = ((old_tc_minute - next_t->minute()) / (double) (old_tc_minute - old_next_minute));
+ }
+
+ new_next_bpm = next_t->note_types_per_minute() * next_frame_ratio;
+ new_copy_end_bpm = tempo_copy->end_note_types_per_minute() * copy_frame_ratio;
+
+ tempo_copy->set_end_note_types_per_minute (new_copy_end_bpm);
+
+ if (next_t->clamped()) {
+ next_t->set_note_types_per_minute (new_copy_end_bpm);
+ } else {
+ next_t->set_note_types_per_minute (new_next_bpm);
+ }
+
+ recompute_tempi (future_map);
+
+ if (check_solved (future_map)) {
+ for (Metrics::const_iterator i = _metrics.begin(); i != _metrics.end(); ++i) {
+ if ((*i)->is_tempo() && (*i)->minute() > ts->minute()) {
+ next_t = static_cast<TempoSection*> (*i);
+ break;
+ }
+ }
+
+ if (!next_t) {
+ return false;
+ }
+
+ if (next_t->clamped()) {
+ next_t->set_note_types_per_minute (new_copy_end_bpm);
+ } else {
+ next_t->set_note_types_per_minute (new_next_bpm);
+ }
+
+ ts->set_end_note_types_per_minute (new_copy_end_bpm);
+ recompute_map (_metrics);
+ can_solve = true;
+ }