From 6894f468d4e5fcd6624368f7a7f820a9fcaa4455 Mon Sep 17 00:00:00 2001 From: nick_m Date: Sat, 21 May 2016 03:54:29 +1000 Subject: Tempo ramps - no more tempo dilation on meter drag. - its now a bbt ruler / marker lane thing with the constraint modifier. --- gtk2_ardour/editor_drag.cc | 19 +++---- libs/ardour/ardour/tempo.h | 1 - libs/ardour/tempo.cc | 128 --------------------------------------------- 3 files changed, 6 insertions(+), 142 deletions(-) diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index f5de16460d..f60a8758b0 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -3197,24 +3197,16 @@ MeterMarkerDrag::motion (GdkEvent* event, bool first_move) /* round bbt to bars */ map.round_bbt (bbt, -1, RoundNearest); - if (Keyboard::modifier_state_contains (event->button.state, ArdourKeyboard::constraint_modifier ())) { - /* adjust previous tempo to match meter frame */ - _editor->session()->tempo_map().gui_dilate_tempo (_real_section, pf); - } else if ((bbt.bars != _real_section->bbt().bars && pf > last_pointer_frame()) - || (bbt.bars < _real_section->bbt().bars && pf < last_pointer_frame())) { + if ((bbt.bars != _real_section->bbt().bars && pf > last_pointer_frame()) + || (bbt.bars < _real_section->bbt().bars && pf < last_pointer_frame())) { + /* move meter beat-based */ _editor->session()->tempo_map().gui_move_meter_bbt (_real_section, bbt); } } else { /* AudioTime */ - if (Keyboard::modifier_state_contains (event->button.state, ArdourKeyboard::constraint_modifier ())) { - /* currently disabled in the lib for AudioTime */ - if (_real_section->movable()) { - _editor->session()->tempo_map().gui_dilate_tempo (_real_section, pf); - } - } else { - _editor->session()->tempo_map().gui_move_meter_frame (_real_section, pf); - } + /* move meter frame-based */ + _editor->session()->tempo_map().gui_move_meter_frame (_real_section, pf); } _marker->set_position (pf); show_verbose_cursor_time (_real_section->frame()); @@ -3415,6 +3407,7 @@ TempoMarkerDrag::motion (GdkEvent* event, bool first_move) } else if (use_snap) { map.round_bbt (when, _editor->get_grid_beat_divisions (0), RoundNearest); } + const double beat = map.bbt_to_beats (when); map.gui_move_tempo_beat (_real_section, beat); } else { diff --git a/libs/ardour/ardour/tempo.h b/libs/ardour/ardour/tempo.h index a570096b45..e436f9dbde 100644 --- a/libs/ardour/ardour/tempo.h +++ b/libs/ardour/ardour/tempo.h @@ -405,7 +405,6 @@ class LIBARDOUR_API TempoMap : public PBD::StatefulDestructible void gui_move_meter_frame (MeterSection*, const framepos_t& frame); void gui_move_meter_bbt (MeterSection*, const Timecode::BBT_Time& bbt); bool gui_change_tempo (TempoSection*, const Tempo& bpm); - void gui_dilate_tempo (MeterSection*, const framepos_t& frame); void gui_dilate_tempo (TempoSection* tempo, const framepos_t& frame, const framepos_t& end_frame, const double& pulse); bool can_solve_bbt (TempoSection* section, const Timecode::BBT_Time& bbt); diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc index a4f626d829..dafb7f71c3 100644 --- a/libs/ardour/tempo.cc +++ b/libs/ardour/tempo.cc @@ -2477,134 +2477,6 @@ TempoMap::gui_change_tempo (TempoSection* ts, const Tempo& bpm) return can_solve; } -void -TempoMap::gui_dilate_tempo (MeterSection* ms, const framepos_t& frame) -{ - Metrics future_map; - TempoSection* ts = 0; - - if (frame <= first_meter().frame()) { - return; - } - - if (ms->position_lock_style() == AudioTime) { - /* disabled for now due to faked tempo locked to meter pulse */ - return; - } - - { - Glib::Threads::RWLock::WriterLock lm (lock); - ts = const_cast(&tempo_section_at_locked (_metrics, ms->frame() - 1)); - if (!ts) { - return; - } - TempoSection* prev_t = copy_metrics_and_point (_metrics, future_map, ts); - TempoSection* prev_to_prev_t = 0; - const frameoffset_t fr_off = frame - ms->frame(); - double new_bpm = 0.0; - - if (prev_t && prev_t->pulse() > 0.0) { - prev_to_prev_t = const_cast(&tempo_section_at_locked (future_map, prev_t->frame() - 1)); - } - - /* the change in frames is the result of changing the slope of at most 2 previous tempo sections. - constant to constant is straightforward, as the tempo prev to prev_t has constant slope. - */ - double contribution = 0.0; - frameoffset_t frame_contribution = 0; - frameoffset_t prev_t_frame_contribution = fr_off; - - if (prev_to_prev_t && prev_to_prev_t->type() == TempoSection::Ramp) { - /* prev to prev_t's position will remain constant in terms of frame and pulse. lets use frames. */ - contribution = (prev_t->frame() - prev_to_prev_t->frame()) / (double) (ms->frame() - prev_to_prev_t->frame()); - frame_contribution = contribution * (double) fr_off; - prev_t_frame_contribution = fr_off - frame_contribution; - } - - if (prev_t->type() == TempoSection::Constant || prev_t->c_func() == 0.0) { - - if (prev_t->position_lock_style() == MusicTime) { - if (prev_to_prev_t && prev_to_prev_t->type() == TempoSection::Ramp) { - new_bpm = prev_t->beats_per_minute() * ((ms->frame() - prev_t->frame()) - / (double) (ms->frame() + prev_t_frame_contribution - prev_t->frame())); - - } else { - /* prev to prev is irrelevant */ - const double meter_pulse = prev_t->pulse_at_frame (ms->frame(), _frame_rate); - const double frame_pulse = prev_t->pulse_at_frame (frame, _frame_rate); - - if (frame_pulse != prev_t->pulse()) { - new_bpm = prev_t->beats_per_minute() * ((meter_pulse - prev_t->pulse()) / (frame_pulse - prev_t->pulse())); - } else { - new_bpm = prev_t->beats_per_minute(); - } - } - } else { - /* AudioTime */ - if (prev_to_prev_t && prev_to_prev_t->type() == TempoSection::Ramp) { - new_bpm = prev_t->beats_per_minute() * ((ms->frame() - prev_t->frame()) - / (double) (ms->frame() + prev_t_frame_contribution - prev_t->frame())); - } else { - /* prev_to_prev_t is irrelevant */ - - if (frame != prev_t->frame()) { - new_bpm = prev_t->beats_per_minute() * ((ms->frame() - prev_t->frame()) / (double) (frame - prev_t->frame())); - } else { - new_bpm = prev_t->beats_per_minute(); - } - } - } - } else if (prev_t->c_func() < 0.0) { - if (prev_to_prev_t && prev_to_prev_t->type() == TempoSection::Ramp) { - new_bpm = prev_t->tempo_at_frame (prev_t->frame() + frame_contribution, _frame_rate) * (double) prev_t->note_type(); - } else { - /* prev_to_prev_t is irrelevant */ - new_bpm = prev_t->tempo_at_frame (prev_t->frame() + fr_off, _frame_rate) * (double) prev_t->note_type(); - } - - } else if (prev_t->c_func() > 0.0) { - if (prev_to_prev_t && prev_to_prev_t->type() == TempoSection::Ramp) { - new_bpm = prev_t->tempo_at_frame (prev_t->frame() - frame_contribution, _frame_rate) * (double) prev_t->note_type(); - } else { - /* prev_to_prev_t is irrelevant */ - new_bpm = prev_t->tempo_at_frame (prev_t->frame() - fr_off, _frame_rate) * (double) prev_t->note_type(); - } - } - - /* limits - a bit clunky, but meh */ - const double diff = (prev_t->tempo_at_frame (frame, _frame_rate) * prev_t->note_type()) - prev_t->beats_per_minute(); - if (diff > -1.0 && diff < 1.0) { - new_bpm = prev_t->beats_per_minute() * ((ms->frame() - prev_t->frame()) - / (double) ((ms->frame() + prev_t_frame_contribution) - prev_t->frame())); - } - - prev_t->set_beats_per_minute (new_bpm); - recompute_tempos (future_map); - recompute_meters (future_map); - - if (check_solved (future_map)) { - - prev_t = const_cast(&tempo_section_at_locked (_metrics, ms->frame() - 1)); - prev_t->set_beats_per_minute (new_bpm); - recompute_tempos (_metrics); - - if (ms->position_lock_style() == AudioTime) { - ms->set_frame (frame); - } - - recompute_meters (_metrics); - } - } - - Metrics::const_iterator d = future_map.begin(); - while (d != future_map.end()) { - delete (*d); - ++d; - } - - MetricPositionChanged (); // Emit Signal -} - void TempoMap::gui_dilate_tempo (TempoSection* ts, const framepos_t& frame, const framepos_t& end_frame, const double& pulse) { -- cgit v1.2.3