if (tempo_dialog.get_lock_style() == MusicTime) {
_session->tempo_map().replace_tempo (*section, Tempo (bpm, nt), beat, tempo_dialog.get_tempo_type());
} else {
- _session->tempo_map().replace_tempo (*section, Tempo (bpm, nt), section->frame(), tempo_dialog.get_tempo_type());
+ _session->tempo_map().replace_c_func_from_tempo_and_beat (bpm, beat);
+ framepos_t const f = _session->tempo_map().frame_at_beat (beat);
+ _session->tempo_map().replace_tempo (*section, Tempo (bpm, nt), f, tempo_dialog.get_tempo_type());
}
XMLNode &after = _session->tempo_map().get_state();
_session->add_command (new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
lock_styles.insert (make_pair (_("music"), PositionLockStyle::MusicTime));
strings.push_back (_("music"));
- lock_styles.insert (make_pair (_("audio ur brane wul xplod"), PositionLockStyle::AudioTime));
- strings.push_back (_("audio"));
+ lock_styles.insert (make_pair (_("audio"), PositionLockStyle::AudioTime));
+ strings.push_back (_("audio ur brane wul xplod"));
set_popdown_strings (lock_style, strings);
LockStyles::iterator ls;
for (ls = lock_styles.begin(); ls != lock_styles.end(); ++ls) {
table->attach (*bpb_label, 0, 1, 0, 1, FILL|EXPAND, FILL|EXPAND);
table->attach (bpb_entry, 1, 2, 0, 1, FILL|EXPAND, FILL|EXPAND);
table->attach (*note_label, 0, 1, 1, 2, FILL|EXPAND, FILL|EXPAND);
- table->attach (note_type, 1, 2, 1, 2, FILL|EXPAND, SHRINK);
+ table->attach (note_type, 1, 2, 1, 2, FILL|EXPAND, FILL|EXPAND);
snprintf (buf, sizeof (buf), "%" PRIu32, when.bars);
when_bar_entry.set_text (buf);
table->attach (*when_label, 0, 1, 2, 3, FILL | EXPAND, FILL | EXPAND);
table->attach (when_bar_entry, 1, 2, 2, 3, FILL | EXPAND, FILL | EXPAND);
- }
- table->attach (*lock_label, 0, 1, 3, 4, FILL|EXPAND, FILL|EXPAND);
- table->attach (lock_style, 1, 2, 3, 4, FILL|EXPAND, SHRINK);
+ table->attach (*lock_label, 0, 1, 3, 4, FILL|EXPAND, FILL|EXPAND);
+ table->attach (lock_style, 1, 2, 3, 4, FILL|EXPAND, SHRINK);
+ } else {
+ table->attach (*lock_label, 0, 1, 2, 3, FILL|EXPAND, FILL|EXPAND);
+ table->attach (lock_style, 1, 2, 2, 3, FILL|EXPAND, SHRINK);
+ }
get_vbox()->set_border_width (12);
get_vbox()->pack_start (*table, false, false);
}
}
+/*
+This is for a gui who needs to know the frame of a beat if a proposed tempo section were to be placed there.
+You probably shouldn't use this unless you know what you're doing,
+as it doesn't recompute the tempo map and will make a ramp invalid intil that next happens.
+It is assumed that the next frame calculation is the last time you need this c_func before the next do_insert() and/or recompute_map().
+*/
+void
+TempoMap::replace_c_func_from_tempo_and_beat (const double& bpm, const double& beat)
+{
+ Glib::Threads::RWLock::WriterLock lm (lock);
+ TempoSection* prev_ts = 0;
+ TempoSection* t;
+
+ for (Metrics::iterator i = metrics.begin(); i != metrics.end(); ++i) {
+ if ((t = dynamic_cast<TempoSection*> (*i)) != 0) {
+ if (prev_ts && t->beat() > prev_ts->beat()) {
+ prev_ts->set_c_func_from_tempo_and_beat (bpm, beat, _frame_rate);
+ break;
+ }
+ prev_ts = t;
+ }
+ }
+}
+
void
TempoMap::replace_tempo (const TempoSection& ts, const Tempo& tempo, const double& where, TempoSection::Type type)
{