Tempo ramps - more code cleanup, fix cross-marker jumping using tempo dialog bbt

This commit is contained in:
nick_m 2016-05-21 04:48:42 +10:00
parent 6894f468d4
commit d1a075110a
4 changed files with 14 additions and 12 deletions

View file

@ -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);

View file

@ -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));

View file

@ -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);

View file

@ -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();