summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornick_m <mainsbridge@gmail.com>2016-05-28 06:50:22 +1000
committernick_m <mainsbridge@gmail.com>2016-05-28 06:50:22 +1000
commita924e938aa282a03d7ce146419652187d5e92774 (patch)
tree0c33cb190870cbcdbd4c9214e928daf202fd2add
parent0d17c21410bc4b4333ec4d8e50d603dde692dce9 (diff)
Allow non-musical snap when dragging bbt ruler.
- probably not what the user wants, unless snapping beats to timecode frames.
-rw-r--r--gtk2_ardour/editor_drag.cc25
-rw-r--r--gtk2_ardour/editor_drag.h1
-rw-r--r--libs/ardour/tempo.cc8
3 files changed, 22 insertions, 12 deletions
diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc
index ca07c5ffbb..f209aed59d 100644
--- a/gtk2_ardour/editor_drag.cc
+++ b/gtk2_ardour/editor_drag.cc
@@ -3415,7 +3415,6 @@ TempoMarkerDrag::aborted (bool moved)
BBTRulerDrag::BBTRulerDrag (Editor* e, ArdourCanvas::Item* i)
: Drag (e, i)
, _pulse (0.0)
- , _beat (0.0)
, _tempo (0)
, before_state (0)
{
@@ -3427,11 +3426,10 @@ void
BBTRulerDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
{
Drag::start_grab (event, cursor);
-
TempoMap& map (_editor->session()->tempo_map());
+ _tempo = const_cast<TempoSection*> (&map.tempo_section_at_frame (raw_grab_frame()));
ostringstream sstr;
- _tempo = const_cast<TempoSection*> (&map.tempo_section_at_frame (raw_grab_frame()));
sstr << "^" << fixed << setprecision(3) << map.tempo_at_frame (adjusted_current_frame (event)).beats_per_minute() << "\n";
sstr << "<" << fixed << setprecision(3) << _tempo->beats_per_minute();
show_verbose_cursor_text (sstr.str());
@@ -3444,17 +3442,22 @@ BBTRulerDrag::setup_pointer_frame_offset ()
TempoMap& map (_editor->session()->tempo_map());
const double beat_at_frame = map.beat_at_frame (raw_grab_frame());
const uint32_t divisions = _editor->get_grid_beat_divisions (0);
+ double beat = 0.0;
+
if (divisions > 0) {
- _beat = floor (beat_at_frame) + (floor (((beat_at_frame - floor (beat_at_frame)) * divisions)) / divisions);
+ beat = floor (beat_at_frame) + (floor (((beat_at_frame - floor (beat_at_frame)) * divisions)) / divisions);
} else {
/* while it makes some sense for the user to determine the division to 'grab',
grabbing a bar often leads to confusing results wrt the actual tempo section being altered
and the result over steep tempo curves. Use sixteenths.
*/
- _beat = floor (beat_at_frame) + (floor (((beat_at_frame - floor (beat_at_frame)) * 4)) / 4);
+ beat = floor (beat_at_frame) + (floor (((beat_at_frame - floor (beat_at_frame)) * 4)) / 4);
}
- _pulse = map.pulse_at_beat (_beat);
- _pointer_frame_offset = raw_grab_frame() - map.frame_at_beat (_beat);
+
+ _pulse = map.pulse_at_beat (beat);
+
+ _pointer_frame_offset = raw_grab_frame() - map.frame_at_pulse (_pulse);
+
}
void
@@ -3468,7 +3471,13 @@ BBTRulerDrag::motion (GdkEvent* event, bool first_move)
_editor->begin_reversible_command (_("dilate tempo"));
}
- framepos_t const pf = adjusted_current_frame (event, false);
+ framepos_t pf;
+
+ if (_editor->snap_musical()) {
+ pf = adjusted_current_frame (event, false);
+ } else {
+ pf = adjusted_current_frame (event);
+ }
if (Keyboard::modifier_state_contains (event->button.state, ArdourKeyboard::constraint_modifier())) {
/* adjust previous tempo to match pointer frame */
diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h
index 9ed07b32df..196bd37123 100644
--- a/gtk2_ardour/editor_drag.h
+++ b/gtk2_ardour/editor_drag.h
@@ -767,7 +767,6 @@ public:
private:
double _pulse;
- double _beat;
ARDOUR::TempoSection* _tempo;
XMLNode* before_state;
};
diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc
index a4744dc445..e01aa52a76 100644
--- a/libs/ardour/tempo.cc
+++ b/libs/ardour/tempo.cc
@@ -2673,14 +2673,16 @@ TempoMap::gui_dilate_tempo (TempoSection* ts, const framepos_t& frame, const fra
constant to constant is straightforward, as the tempo prev to prev_t has constant slope.
*/
double contribution = 0.0;
- double start_pulse = prev_t->pulse_at_frame (frame, _frame_rate);
if (next_t && prev_to_prev_t && prev_to_prev_t->type() == TempoSection::Ramp) {
contribution = (prev_t->frame() - prev_to_prev_t->frame()) / (double) (next_t->frame() - prev_to_prev_t->frame());
}
- frameoffset_t prev_t_frame_contribution = fr_off - (contribution * (double) fr_off);
- double end_pulse = prev_t->pulse_at_frame (end_frame, _frame_rate);
+ const frameoffset_t prev_t_frame_contribution = fr_off - (contribution * (double) fr_off);
+
+ const double start_pulse = prev_t->pulse_at_frame (frame, _frame_rate);
+ const double end_pulse = prev_t->pulse_at_frame (end_frame, _frame_rate);
+
double new_bpm;
if (prev_t->type() == TempoSection::Constant || prev_t->c_func() == 0.0) {