summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornick_m <mainsbridge@gmail.com>2016-05-21 04:48:42 +1000
committernick_m <mainsbridge@gmail.com>2016-05-27 23:38:17 +1000
commitd1a075110afa8efe1944ba7a9a2ba6be985c8291 (patch)
tree1d39b3d80e15e727e352001d1622eb4ace68742e
parent6894f468d4e5fcd6624368f7a7f820a9fcaa4455 (diff)
Tempo ramps - more code cleanup, fix cross-marker jumping using tempo dialog bbt
-rw-r--r--gtk2_ardour/editor_drag.cc9
-rw-r--r--gtk2_ardour/editor_tempodisplay.cc10
-rw-r--r--libs/ardour/ardour/tempo.h2
-rw-r--r--libs/ardour/tempo.cc5
4 files changed, 14 insertions, 12 deletions
diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc
index f60a8758b0..e8b8d9e3a2 100644
--- a/gtk2_ardour/editor_drag.cc
+++ b/gtk2_ardour/editor_drag.cc
@@ -3142,10 +3142,6 @@ MeterMarkerDrag::setup_pointer_frame_offset ()
void
MeterMarkerDrag::motion (GdkEvent* event, bool first_move)
{
- if (!_marker->meter().movable()) {
- //return;
- }
-
if (first_move) {
// create a dummy marker to catch events, then hide it.
@@ -3281,6 +3277,7 @@ TempoMarkerDrag::motion (GdkEvent* event, bool first_move)
if (!_real_section->active()) {
return;
}
+
if (first_move) {
// mvc drag - create a dummy marker to catch events, hide it.
@@ -3342,7 +3339,7 @@ TempoMarkerDrag::motion (GdkEvent* event, bool first_move)
} else if (use_snap) {
map.round_bbt (bbt, _editor->get_grid_beat_divisions (0), RoundNearest);
}
- double const pulse = map.predict_tempo_pulse (_real_section, map.frame_time (bbt));
+ double const pulse = map.predict_tempo_pulse (_real_section, bbt);
_real_section = map.add_tempo (_marker->tempo(), pulse, 0, _real_section->type(), MusicTime);
} else {
if (use_snap && _editor->snap_type() == SnapToBar) {
@@ -3400,7 +3397,7 @@ TempoMarkerDrag::motion (GdkEvent* event, bool first_move)
if (_real_section->position_lock_style() == MusicTime) {
- const double pulse = map.predict_tempo_pulse (_real_section, pf);
+ const double pulse = map.predict_tempo_pulse (_real_section, when);
when = map.pulse_to_bbt (pulse);
if (use_snap && _editor->snap_type() == SnapToBar) {
map.round_bbt (when, -1, (pf > _real_section->frame()) ? RoundUpMaybe : RoundDownMaybe);
diff --git a/gtk2_ardour/editor_tempodisplay.cc b/gtk2_ardour/editor_tempodisplay.cc
index ad9551b87f..e2540ddfd0 100644
--- a/gtk2_ardour/editor_tempodisplay.cc
+++ b/gtk2_ardour/editor_tempodisplay.cc
@@ -425,9 +425,13 @@ Editor::edit_tempo_section (TempoSection* section)
begin_reversible_command (_("replace tempo mark"));
XMLNode &before = _session->tempo_map().get_state();
- framepos_t const f = _session->tempo_map().predict_tempo_frame (section, when);
- double const p = _session->tempo_map().predict_tempo_pulse (section, f);
- _session->tempo_map().replace_tempo (*section, Tempo (bpm, nt), p, f, tempo_dialog.get_tempo_type(), tempo_dialog.get_lock_style());
+ if (tempo_dialog.get_lock_style() == AudioTime) {
+ framepos_t const f = _session->tempo_map().predict_tempo_frame (section, when);
+ _session->tempo_map().replace_tempo (*section, Tempo (bpm, nt), 0.0, f, tempo_dialog.get_tempo_type(), AudioTime);
+ } else {
+ double const p = _session->tempo_map().predict_tempo_pulse (section, when);
+ _session->tempo_map().replace_tempo (*section, Tempo (bpm, nt), p, 0, tempo_dialog.get_tempo_type(), MusicTime);
+ }
XMLNode &after = _session->tempo_map().get_state();
_session->add_command (new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
diff --git a/libs/ardour/ardour/tempo.h b/libs/ardour/ardour/tempo.h
index e436f9dbde..f3b94e05ee 100644
--- a/libs/ardour/ardour/tempo.h
+++ b/libs/ardour/ardour/tempo.h
@@ -392,7 +392,7 @@ class LIBARDOUR_API TempoMap : public PBD::StatefulDestructible
void remove_meter (const MeterSection&, bool send_signal);
framepos_t predict_tempo_frame (TempoSection* section, const Timecode::BBT_Time& bbt);
- double predict_tempo_pulse (TempoSection* section, const framepos_t& frame);
+ double predict_tempo_pulse (TempoSection* section, const Timecode::BBT_Time& bbt);
void replace_tempo (const TempoSection&, const Tempo&, const double& pulse, const framepos_t& frame
, TempoSection::Type type, PositionLockStyle pls);
diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc
index dafb7f71c3..874c42e8f0 100644
--- a/libs/ardour/tempo.cc
+++ b/libs/ardour/tempo.cc
@@ -2339,14 +2339,15 @@ TempoMap::predict_tempo_frame (TempoSection* section, const BBT_Time& bbt)
}
double
-TempoMap::predict_tempo_pulse (TempoSection* section, const framepos_t& frame)
+TempoMap::predict_tempo_pulse (TempoSection* section, const BBT_Time& bbt)
{
Glib::Threads::RWLock::ReaderLock lm (lock);
Metrics future_map;
double ret = 0.0;
TempoSection* tempo_copy = copy_metrics_and_point (_metrics, future_map, section);
+ const double beat = bbt_to_beats_locked (future_map, bbt);
- if (solve_map_frame (future_map, tempo_copy, frame)) {
+ if (solve_map_pulse (future_map, tempo_copy, pulse_at_beat_locked (future_map, beat))) {
ret = tempo_copy->pulse();
} else {
ret = section->pulse();