if (!loc->tempo().initial()) {
if (loc->tempo().clamped()) {
- items.push_back (MenuElem (_("Unlock Continue"), sigc::mem_fun(*this, &Editor::toggle_tempo_clamped)));
+ items.push_back (MenuElem (_("Don't Continue"), sigc::mem_fun(*this, &Editor::toggle_tempo_clamped)));
} else {
- items.push_back (MenuElem (_("Lock Continue"), sigc::mem_fun(*this, &Editor::toggle_tempo_clamped)));
+ items.push_back (MenuElem (_("Continue"), sigc::mem_fun(*this, &Editor::toggle_tempo_clamped)));
}
+ }
- TempoSection* prev_ts = _session->tempo_map().previous_tempo_section (&loc->tempo());
- if (prev_ts && prev_ts->end_note_types_per_minute() != loc->tempo().note_types_per_minute()) {
- items.push_back (MenuElem (_("Continue"), sigc::mem_fun(*this, &Editor::continue_previous_tempo)));
- }
+ if (loc->tempo().type() == TempoSection::Ramp) {
+ items.push_back (MenuElem (_("Set Constant"), sigc::mem_fun(*this, &Editor::toggle_tempo_type)));
}
TempoSection* next_ts = _session->tempo_map().next_tempo_section (&loc->tempo());
items.push_back (MenuElem (_("Ramp to Next"), sigc::mem_fun(*this, &Editor::ramp_to_next_tempo)));
}
- if (loc->tempo().type() == TempoSection::Ramp) {
- items.push_back (MenuElem (_("Set Constant"), sigc::mem_fun(*this, &Editor::toggle_tempo_type)));
- }
-
if (loc->tempo().position_lock_style() == AudioTime && can_remove) {
+ items.push_back (SeparatorElem());
items.push_back (MenuElem (_("Lock to Music"), sigc::mem_fun(*this, &Editor::toggle_marker_lock_style)));
} else if (can_remove) {
+ items.push_back (SeparatorElem());
items.push_back (MenuElem (_("Lock to Audio"), sigc::mem_fun(*this, &Editor::toggle_marker_lock_style)));
}
+ items.push_back (SeparatorElem());
+
items.push_back (MenuElem (_("Edit..."), sigc::mem_fun(*this, &Editor::marker_menu_edit)));
items.push_back (MenuElem (_("Remove"), sigc::mem_fun(*this, &Editor::marker_menu_remove)));
items.back().set_sensitive (can_remove);
}
}
-void
-Editor::continue_previous_tempo ()
-{
- TempoMarker* tm;
- MeterMarker* mm;
- dynamic_cast_marker_object (marker_menu_item->get_data ("marker"), &mm, &tm);
-
- if (tm) {
- TempoMap& tmap (_session->tempo_map());
- TempoSection* tsp = &tm->tempo();
- TempoSection* prev_ts = tmap.previous_tempo_section (&tm->tempo());
- if (prev_ts) {
- const Tempo tempo (prev_ts->end_note_types_per_minute(), tsp->note_type(), tsp->end_note_types_per_minute());
- const double pulse = tsp->pulse();
- const framepos_t frame = tsp->frame();
- const PositionLockStyle pls = tsp->position_lock_style();
-
- begin_reversible_command (_("continue previous tempo"));
- XMLNode &before = _session->tempo_map().get_state();
-
- tmap.replace_tempo (*tsp, tempo, pulse, frame, pls);
-
- XMLNode &after = _session->tempo_map().get_state();
- _session->add_command(new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
- commit_reversible_command ();
- }
- }
-}
-
void
Editor::ramp_to_next_tempo ()
{
TempoSection* ts = 0;
{
Glib::Threads::RWLock::WriterLock lm (lock);
- ts = add_tempo_locked (tempo, pulse, minute_at_frame (frame), pls, true, false);
+ /* here we default to not clamped for a new tempo section. preference? */
+ ts = add_tempo_locked (tempo, pulse, minute_at_frame (frame), pls, true, false, false);
recompute_map (_metrics);
}
}
} else {
remove_tempo_locked (ts);
- new_ts = add_tempo_locked (tempo, pulse, minute_at_frame (frame), pls, true, locked_to_meter);
- new_ts->set_clamped (ts_clamped);
-
- if (new_ts && new_ts->type() == TempoSection::Constant) {
- new_ts->set_end_note_types_per_minute (new_ts->note_types_per_minute());
+ new_ts = add_tempo_locked (tempo, pulse, minute_at_frame (frame), pls, true, locked_to_meter, ts_clamped);
+ /* enforce clampedness of next tempo section */
+ TempoSection* next_t = next_tempo_section_locked (_metrics, new_ts);
+ if (next_t && next_t->clamped()) {
+ next_t->set_note_types_per_minute (new_ts->end_note_types_per_minute());
}
}
TempoSection*
TempoMap::add_tempo_locked (const Tempo& tempo, double pulse, double minute
- , PositionLockStyle pls, bool recompute, bool locked_to_meter)
+ , PositionLockStyle pls, bool recompute, bool locked_to_meter, bool clamped)
{
TempoSection* t = new TempoSection (pulse, minute, tempo, pls, _frame_rate);
t->set_locked_to_meter (locked_to_meter);
+ t->set_clamped (clamped);
do_insert (t);
for (Metrics::iterator i = _metrics.begin(); i != _metrics.end(); ++i) {
TempoSection* const this_t = dynamic_cast<TempoSection*>(*i);
if (this_t) {
- bool const ipm = t->position_lock_style() == MusicTime;
- bool const lm = t->locked_to_meter();
-
- if ((ipm && this_t->pulse() == t->pulse()) || (!ipm && this_t->frame() == t->frame())
- || (lm && this_t->pulse() == t->pulse())) {
+ if (this_t == t) {
if (prev_tempo && prev_tempo->type() == TempoSection::Ramp) {
prev_tempo->set_end_note_types_per_minute (t->note_types_per_minute());
}
if (pls == AudioTime) {
/* add meter-locked tempo at the natural time in the current map (frame may differ). */
Tempo const tempo_at_time = tempo_at_minute_locked (_metrics, time_minutes);
- TempoSection* mlt = add_tempo_locked (tempo_at_time, pulse, time_minutes, AudioTime, true, true);
+ TempoSection* mlt = add_tempo_locked (tempo_at_time, pulse, time_minutes, AudioTime, true, true, false);
if (!mlt) {
return 0;
continue;
}
}
+
if (prev_t) {
if (t->position_lock_style() == AudioTime) {
prev_t->set_c (prev_t->compute_c_minute (prev_t->end_note_types_per_minute(), t->minute()));
return;
}
- TempoSection* prev_t = copy_metrics_and_point (_metrics, future_map, ts);
+ TempoSection* ts_copy = copy_metrics_and_point (_metrics, future_map, ts);
- if (!prev_t) {
+ if (!ts_copy) {
return;
}
framepos_t const min_dframe = 2;
double new_bpm;
- if (prev_t->clamped()) {
- TempoSection* next_t = next_tempo_section_locked (future_map, prev_t);
- TempoSection* prev_to_prev_t = previous_tempo_section_locked (future_map, prev_t);
- /* the change in frames is the result of changing the slope of at most 2 previous tempo sections.
- constant to constant is straightforward, as the tempo prev to prev_t has constant slope.
- */
- double contribution = 0.0;
- if (next_t && prev_to_prev_t && prev_to_prev_t->type() == TempoSection::Ramp) {
- contribution = (prev_t->pulse() - prev_to_prev_t->pulse()) / (double) (next_t->pulse() - prev_to_prev_t->pulse());
+ if (ts_copy->clamped()) {
+ TempoSection* next_t = next_tempo_section_locked (future_map, ts_copy);
+ TempoSection* prev_to_ts_copy = previous_tempo_section_locked (future_map, ts_copy);
+ /* the change in frames is the result of changing the slope of at most 2 previous tempo sections.
+ constant to constant is straightforward, as the tempo prev to ts_copy has constant slope.
+ */ double contribution = 0.0;
+ if (next_t && prev_to_ts_copy && prev_to_ts_copy->type() == TempoSection::Ramp) {
+ contribution = (ts_copy->pulse() - prev_to_ts_copy->pulse()) / (double) (next_t->pulse() - prev_to_ts_copy->pulse());
}
framepos_t const fr_off = end_frame - frame;
- frameoffset_t const prev_t_frame_contribution = fr_off - (contribution * (double) fr_off);
+ frameoffset_t const ts_copy_frame_contribution = fr_off - (contribution * (double) fr_off);
- if (frame > prev_to_prev_t->frame() + min_dframe && (frame + prev_t_frame_contribution) > prev_to_prev_t->frame() + min_dframe) {
- new_bpm = prev_t->note_types_per_minute() * ((start_qnote - (prev_to_prev_t->pulse() * 4.0))
- / (end_qnote - (prev_to_prev_t->pulse() * 4.0)));
+ if (frame > prev_to_ts_copy->frame() + min_dframe && (frame + ts_copy_frame_contribution) > prev_to_ts_copy->frame() + min_dframe) {
+ new_bpm = ts_copy->note_types_per_minute() * ((start_qnote - (prev_to_ts_copy->pulse() * 4.0))
+ / (end_qnote - (prev_to_ts_copy->pulse() * 4.0)));
} else {
- new_bpm = prev_t->note_types_per_minute();
+ new_bpm = ts_copy->note_types_per_minute();
}
} else {
- if (frame > prev_t->frame() + min_dframe && end_frame > prev_t->frame() + min_dframe) {
+ if (frame > ts_copy->frame() + min_dframe && end_frame > ts_copy->frame() + min_dframe) {
- new_bpm = prev_t->note_types_per_minute() * ((frame - prev_t->frame())
- / (double) (end_frame - prev_t->frame()));
+ new_bpm = ts_copy->note_types_per_minute() * ((frame - ts_copy->frame())
+ / (double) (end_frame - ts_copy->frame()));
} else {
- new_bpm = prev_t->note_types_per_minute();
+ new_bpm = ts_copy->note_types_per_minute();
}
new_bpm = min (new_bpm, (double) 1000.0);
goto out;
}
- if (prev_t && prev_t->type() == TempoSection::Ramp) {
- prev_t->set_note_types_per_minute (new_bpm);
- } else {
- prev_t->set_end_note_types_per_minute (new_bpm);
- prev_t->set_note_types_per_minute (new_bpm);
- }
+ ts_copy->set_note_types_per_minute (new_bpm);
- if (prev_t->clamped()) {
+ if (ts_copy->clamped()) {
TempoSection* prev = 0;
- if ((prev = previous_tempo_section_locked (future_map, prev_t)) != 0) {
- prev->set_end_note_types_per_minute (prev_t->note_types_per_minute());
+ if ((prev = previous_tempo_section_locked (future_map, ts_copy)) != 0) {
+ prev->set_end_note_types_per_minute (ts_copy->note_types_per_minute());
}
}
recompute_meters (future_map);
if (check_solved (future_map)) {
- if (prev_t && prev_t->type() == TempoSection::Ramp) {
- ts->set_note_types_per_minute (new_bpm);
- } else {
- ts->set_end_note_types_per_minute (new_bpm);
- ts->set_note_types_per_minute (new_bpm);
- }
+ ts->set_note_types_per_minute (new_bpm);
+
if (ts->clamped()) {
TempoSection* prev = 0;
if ((prev = previous_tempo_section_locked (_metrics, ts)) != 0) {
prev->set_end_note_types_per_minute (ts->note_types_per_minute());
}
}
+
recompute_tempi (_metrics);
recompute_meters (_metrics);
}