summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk2_ardour/editor_drag.cc8
-rw-r--r--gtk2_ardour/editor_tempodisplay.cc4
-rw-r--r--libs/ardour/ardour/tempo.h9
-rw-r--r--libs/ardour/tempo.cc60
4 files changed, 30 insertions, 51 deletions
diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc
index e8b8d9e3a2..d60df1c896 100644
--- a/gtk2_ardour/editor_drag.cc
+++ b/gtk2_ardour/editor_drag.cc
@@ -3339,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, bbt);
+ double const pulse = map.predict_tempo (_real_section, bbt).first;
_real_section = map.add_tempo (_marker->tempo(), pulse, 0, _real_section->type(), MusicTime);
} else {
if (use_snap && _editor->snap_type() == SnapToBar) {
@@ -3348,7 +3348,7 @@ TempoMarkerDrag::motion (GdkEvent* event, bool first_move)
map.round_bbt (bbt, _editor->get_grid_beat_divisions (0), RoundNearest);
}
if (use_snap) {
- frame = map.predict_tempo_frame (_real_section, bbt);
+ frame = map.predict_tempo (_real_section, bbt).second;
}
_real_section = map.add_tempo (_marker->tempo(), 0.0, frame, _real_section->type(), AudioTime);
}
@@ -3397,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, when);
+ const double pulse = map.predict_tempo (_real_section, when).first;
when = map.pulse_to_bbt (pulse);
if (use_snap && _editor->snap_type() == SnapToBar) {
map.round_bbt (when, -1, (pf > _real_section->frame()) ? RoundUpMaybe : RoundDownMaybe);
@@ -3414,7 +3414,7 @@ TempoMarkerDrag::motion (GdkEvent* event, bool first_move)
map.round_bbt (when, _editor->get_grid_beat_divisions (0), RoundNearest);
}
if (use_snap) {
- pf = map.predict_tempo_frame (_real_section, when);
+ pf = map.predict_tempo (_real_section, when).second;
}
map.gui_move_tempo_frame (_real_section, pf);
}
diff --git a/gtk2_ardour/editor_tempodisplay.cc b/gtk2_ardour/editor_tempodisplay.cc
index e2540ddfd0..9fdae28b30 100644
--- a/gtk2_ardour/editor_tempodisplay.cc
+++ b/gtk2_ardour/editor_tempodisplay.cc
@@ -426,10 +426,10 @@ Editor::edit_tempo_section (TempoSection* section)
XMLNode &before = _session->tempo_map().get_state();
if (tempo_dialog.get_lock_style() == AudioTime) {
- framepos_t const f = _session->tempo_map().predict_tempo_frame (section, when);
+ framepos_t const f = _session->tempo_map().predict_tempo (section, when).second;
_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);
+ double const p = _session->tempo_map().predict_tempo (section, when).first;
_session->tempo_map().replace_tempo (*section, Tempo (bpm, nt), p, 0, tempo_dialog.get_tempo_type(), MusicTime);
}
diff --git a/libs/ardour/ardour/tempo.h b/libs/ardour/ardour/tempo.h
index f3b94e05ee..a3eec81bb9 100644
--- a/libs/ardour/ardour/tempo.h
+++ b/libs/ardour/ardour/tempo.h
@@ -374,14 +374,14 @@ class LIBARDOUR_API TempoMap : public PBD::StatefulDestructible
const MeterSection& meter_section_at_beat (double beat) const;
- /** add a tempo section locked to pls. ignored values are set in recompute_tempos()
+ /** add a tempo section locked to pls. ignored values will be set in recompute_tempos()
* @param pulse pulse position of new section. ignored if pls == AudioTime
* @param frame frame position of new section. ignored if pls == MusicTime
* @param type type of new tempo section (Ramp, Constant)
*/
TempoSection* add_tempo (const Tempo&, const double& pulse, const framepos_t& frame, TempoSection::Type type, PositionLockStyle pls);
- /** add an meter section locked to pls.. ignored values are set in recompute_meters()
+ /** add an meter section locked to pls.. ignored values will be set in recompute_meters()
* @param beat beat position of new section
* @param where bbt position of new section
* @param frame frame position of new section. ignored if pls == MusicTime
@@ -391,15 +391,14 @@ class LIBARDOUR_API TempoMap : public PBD::StatefulDestructible
void remove_tempo (const TempoSection&, bool send_signal);
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 Timecode::BBT_Time& bbt);
-
void replace_tempo (const TempoSection&, const Tempo&, const double& pulse, const framepos_t& frame
, TempoSection::Type type, PositionLockStyle pls);
void replace_meter (const MeterSection&, const Meter&, const Timecode::BBT_Time& where, const framepos_t& frame
, PositionLockStyle pls);
+ std::pair<double, framepos_t> predict_tempo (TempoSection* section, const Timecode::BBT_Time& bbt);
+
void gui_move_tempo_frame (TempoSection*, const framepos_t& frame);
void gui_move_tempo_beat (TempoSection*, const double& beat);
void gui_move_meter_frame (MeterSection*, const framepos_t& frame);
diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc
index 874c42e8f0..87e1620425 100644
--- a/libs/ardour/tempo.cc
+++ b/libs/ardour/tempo.cc
@@ -2005,6 +2005,7 @@ TempoMap::solve_map_frame (Metrics& imaginary, MeterSection* section, const fram
MeterSection* prev_m = 0;
Metrics future_map;
+ TempoSection* tempo_copy = copy_metrics_and_point (imaginary, future_map, meter_locked_tempo);
bool solved = false;
for (Metrics::iterator i = imaginary.begin(); i != imaginary.end(); ++i) {
@@ -2017,11 +2018,11 @@ TempoMap::solve_map_frame (Metrics& imaginary, MeterSection* section, const fram
/* set the frame/pulse corresponding to its musical position,
* as an earlier time than this has been requested.
*/
-
- TempoSection* tempo_copy = copy_metrics_and_point (imaginary, future_map, meter_locked_tempo);
const double new_pulse = ((section->beat() - prev_m->beat())
/ prev_m->note_divisor()) + prev_m->pulse();
+
const framepos_t smallest_frame = frame_at_pulse_locked (future_map, new_pulse);
+
if ((solved = solve_map_frame (future_map, tempo_copy, smallest_frame))) {
meter_locked_tempo->set_pulse (new_pulse);
solve_map_frame (imaginary, meter_locked_tempo, smallest_frame);
@@ -2041,8 +2042,7 @@ TempoMap::solve_map_frame (Metrics& imaginary, MeterSection* section, const fram
return false;
}
} else {
-
- TempoSection* tempo_copy = copy_metrics_and_point (imaginary, future_map, meter_locked_tempo);
+ /* all is ok. set section's tempo */
MeterSection* meter_copy = const_cast<MeterSection*> (&meter_section_at_locked (future_map, section->frame()));
meter_copy->set_frame (frame);
@@ -2068,8 +2068,6 @@ TempoMap::solve_map_frame (Metrics& imaginary, MeterSection* section, const fram
} else {
/* not movable (first meter atm) */
- TempoSection* tempo_copy = copy_metrics_and_point (imaginary, future_map, meter_locked_tempo);
-
tempo_copy->set_frame (frame);
tempo_copy->set_pulse (0.0);
@@ -2149,6 +2147,7 @@ TempoMap::solve_map_bbt (Metrics& imaginary, MeterSection* section, const BBT_Ti
if (m->position_lock_style() == AudioTime) {
TempoSection* meter_locked_tempo = 0;
+
for (Metrics::const_iterator ii = imaginary.begin(); ii != imaginary.end(); ++ii) {
TempoSection* t;
if ((t = dynamic_cast<TempoSection*> (*ii)) != 0) {
@@ -2159,6 +2158,10 @@ TempoMap::solve_map_bbt (Metrics& imaginary, MeterSection* section, const BBT_Ti
}
}
+ if (!meter_locked_tempo) {
+ return false;
+ }
+
if (prev_m) {
const double beats = ((m->bbt().bars - prev_m->bbt().bars) * prev_m->divisions_per_bar());
@@ -2174,10 +2177,8 @@ TempoMap::solve_map_bbt (Metrics& imaginary, MeterSection* section, const BBT_Ti
} else {
b_bbt = make_pair (0.0, BBT_Time (1, 1, 0));
}
- if (meter_locked_tempo) {
- meter_locked_tempo->set_pulse (new_pulse);
- recompute_tempos (imaginary);
- }
+
+ meter_locked_tempo->set_pulse (new_pulse);
m->set_beat (b_bbt);
m->set_pulse (new_pulse);
@@ -2312,45 +2313,24 @@ TempoMap::can_solve_bbt (TempoSection* ts, const BBT_Time& bbt)
* @param bbt - the bbt where the altered tempo will fall
* @return returns - the position in frames where the new tempo section will lie.
*/
-framepos_t
-TempoMap::predict_tempo_frame (TempoSection* section, const BBT_Time& bbt)
+pair<double, framepos_t>
+TempoMap::predict_tempo (TempoSection* section, const BBT_Time& bbt)
{
- Glib::Threads::RWLock::ReaderLock lm (lock);
Metrics future_map;
- framepos_t ret = 0;
- TempoSection* tempo_copy = copy_metrics_and_point (_metrics, future_map, section);
- if (!tempo_copy) {
- return 0;
- }
- const double beat = bbt_to_beats_locked (future_map, bbt);
+ pair<double, framepos_t> ret = make_pair (0.0, 0);
- if (solve_map_pulse (future_map, tempo_copy, pulse_at_beat_locked (future_map, beat))) {
- ret = tempo_copy->frame();
- } else {
- ret = section->frame();
- }
-
- Metrics::const_iterator d = future_map.begin();
- while (d != future_map.end()) {
- delete (*d);
- ++d;
- }
- return ret;
-}
-
-double
-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_pulse (future_map, tempo_copy, pulse_at_beat_locked (future_map, beat))) {
- ret = tempo_copy->pulse();
+ ret.first = tempo_copy->pulse();
+ ret.second = tempo_copy->frame();
} else {
- ret = section->pulse();
+ ret.first = section->pulse();
+ ret.second = section->frame();
}
Metrics::const_iterator d = future_map.begin();