summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authornick_m <mainsbridge@gmail.com>2016-10-30 23:21:42 +1100
committernick_m <mainsbridge@gmail.com>2016-11-11 03:37:08 +1100
commit0e867b544b6d1b5f82f46cec7171998b2f2ca3bc (patch)
treecc9605fbd8ed505aedb3e1d04cfa301a84ad8b33 /gtk2_ardour
parentae63243bf3af8ab4dad8535ac2811df399c9a34a (diff)
Refactor tempo api, include quarter-note distance in frames method.
- moves frame rounding up to TempoMap, which is needed in order to calculate pulse distance without frame rounding. - the time unit for tempo is still minute, but this now also applies to meter sections. (new audio locked meter sections no longer require a frame position). - there is no longer a discontinuity in the pulse for audio-locked meter/tempi. - temporarily add debugging output in Region::set_position() to test for region beat not matching region frame.
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/editor_drag.cc5
-rw-r--r--gtk2_ardour/editor_markers.cc3
-rw-r--r--gtk2_ardour/editor_tempodisplay.cc7
-rw-r--r--gtk2_ardour/tempo_curve.cc4
4 files changed, 9 insertions, 10 deletions
diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc
index 5ed00274dc..c32b2932ae 100644
--- a/gtk2_ardour/editor_drag.cc
+++ b/gtk2_ardour/editor_drag.cc
@@ -3198,7 +3198,7 @@ MeterMarkerDrag::motion (GdkEvent* event, bool first_move)
}
const double beat = map.beat_at_bbt (bbt);
_real_section = map.add_meter (Meter (_marker->meter().divisions_per_bar(), _marker->meter().note_divisor())
- , beat, bbt, map.frame_at_bbt (bbt), _real_section->position_lock_style());
+ , beat, bbt, _real_section->position_lock_style());
if (!_real_section) {
aborted (true);
return;
@@ -3341,7 +3341,8 @@ TempoMarkerDrag::motion (GdkEvent* event, bool first_move)
_editor->begin_reversible_command (_("copy tempo mark"));
if (_real_section->position_lock_style() == MusicTime) {
- _real_section = map.add_tempo (tempo, map.pulse_at_frame (frame), 0, type, MusicTime);
+ const int32_t divisions = _editor->get_grid_music_divisions (event->button.state);
+ _real_section = map.add_tempo (tempo, map.exact_qn_at_frame (frame, divisions), 0, type, MusicTime);
} else {
_real_section = map.add_tempo (tempo, 0.0, frame, type, AudioTime);
}
diff --git a/gtk2_ardour/editor_markers.cc b/gtk2_ardour/editor_markers.cc
index d20404916a..351ba31126 100644
--- a/gtk2_ardour/editor_markers.cc
+++ b/gtk2_ardour/editor_markers.cc
@@ -1394,10 +1394,9 @@ Editor::toggle_marker_lock_style ()
const Meter meter (msp->divisions_per_bar(), msp->note_divisor());
const Timecode::BBT_Time bbt (msp->bbt());
- const framepos_t frame = msp->frame();
const PositionLockStyle pls = (msp->position_lock_style() == AudioTime) ? MusicTime : AudioTime;
- _session->tempo_map().replace_meter (*msp, meter, bbt, frame, pls);
+ _session->tempo_map().replace_meter (*msp, meter, bbt, pls);
XMLNode &after = _session->tempo_map().get_state();
_session->add_command(new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
diff --git a/gtk2_ardour/editor_tempodisplay.cc b/gtk2_ardour/editor_tempodisplay.cc
index 41d19ca794..cd12a4e872 100644
--- a/gtk2_ardour/editor_tempodisplay.cc
+++ b/gtk2_ardour/editor_tempodisplay.cc
@@ -409,9 +409,9 @@ Editor::mouse_add_new_meter_event (framepos_t frame)
XMLNode &before = map.get_state();
if (meter_dialog.get_lock_style() == MusicTime) {
- map.add_meter (Meter (bpb, note_type), beat, requested, map.frame_at_beat (beat), MusicTime);
+ map.add_meter (Meter (bpb, note_type), beat, requested, MusicTime);
} else {
- map.add_meter (Meter (bpb, note_type), beat, requested, map.frame_at_beat (beat), AudioTime);
+ map.add_meter (Meter (bpb, note_type), beat, requested, AudioTime);
}
_session->add_command(new MementoCommand<TempoMap>(map, &before, &map.get_state()));
@@ -462,13 +462,12 @@ Editor::edit_meter_section (MeterSection* section)
Timecode::BBT_Time when;
meter_dialog.get_bbt_time (when);
- framepos_t const frame = _session->tempo_map().frame_at_bbt (when);
const PositionLockStyle pls = (meter_dialog.get_lock_style() == AudioTime) ? AudioTime : MusicTime;
begin_reversible_command (_("replace meter mark"));
XMLNode &before = _session->tempo_map().get_state();
- _session->tempo_map().replace_meter (*section, meter, when, frame, pls);
+ _session->tempo_map().replace_meter (*section, meter, when, pls);
XMLNode &after = _session->tempo_map().get_state();
_session->add_command(new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
diff --git a/gtk2_ardour/tempo_curve.cc b/gtk2_ardour/tempo_curve.cc
index 358457e505..7330e8c129 100644
--- a/gtk2_ardour/tempo_curve.cc
+++ b/gtk2_ardour/tempo_curve.cc
@@ -131,7 +131,7 @@ TempoCurve::set_position (framepos_t frame, framepos_t end_frame)
framepos_t current_frame = frame;
while (current_frame < (end_frame - frame_step)) {
- const double tempo_at = _tempo.tempo_at_frame (current_frame, editor.session()->frame_rate());
+ const double tempo_at = _tempo.tempo_at_minute (_tempo.minute_at_frame (current_frame));
const double y_pos = max ((curve_height) - (((tempo_at - _min_tempo) / (_max_tempo - _min_tempo)) * curve_height), 0.0);
points->push_back (ArdourCanvas::Duple (editor.sample_to_pixel (current_frame - frame), min (y_pos, curve_height)));
@@ -139,7 +139,7 @@ TempoCurve::set_position (framepos_t frame, framepos_t end_frame)
current_frame += frame_step;
}
- const double tempo_at = _tempo.tempo_at_frame (end_frame, editor.session()->frame_rate());
+ const double tempo_at = _tempo.tempo_at_minute (_tempo.minute_at_frame (end_frame));
const double y_pos = max ((curve_height) - (((tempo_at - _min_tempo) / (_max_tempo - _min_tempo)) * curve_height), 0.0);
points->push_back (ArdourCanvas::Duple (editor.sample_to_pixel ((end_frame - 1) - frame), min (y_pos, curve_height)));