a huge set of changes to tempo+meter handling. testing feedback requested. the_CLA, you know who i mean :)

git-svn-id: svn://localhost/ardour2/branches/3.0@11103 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2011-12-28 21:02:31 +00:00
parent c3a52084f8
commit a85e0b0a2e
9 changed files with 536 additions and 369 deletions

View file

@ -1972,7 +1972,7 @@ MeterMarkerDrag::motion (GdkEvent* event, bool first_move)
if (!_copy) {
TempoMap& map (_editor->session()->tempo_map());
/* remove the section while we drag it */
map.remove_meter (section);
map.remove_meter (section, true);
}
}
@ -2090,7 +2090,7 @@ TempoMarkerDrag::motion (GdkEvent* event, bool first_move)
if (!_copy) {
TempoMap& map (_editor->session()->tempo_map());
/* remove the section while we drag it */
map.remove_tempo (section);
map.remove_tempo (section, true);
}
}
@ -2143,7 +2143,7 @@ TempoMarkerDrag::aborted (bool moved)
if (moved) {
TempoMap& map (_editor->session()->tempo_map());
/* we removed it before, so add it back now */
map.add_tempo (_marker->tempo(), _marker->tempo().frame());
map.add_tempo (_marker->tempo(), _marker->tempo().start());
// delete the dummy marker we used for visual representation while moving.
// a new visual marker will show up automatically.
delete _marker;

View file

@ -330,9 +330,12 @@ Editor::edit_meter_section (MeterSection* section)
double note_type = meter_dialog.get_note_type ();
Timecode::BBT_Time when;
meter_dialog.get_bbt_time(when);
begin_reversible_command (_("replace tempo mark"));
XMLNode &before = _session->tempo_map().get_state();
_session->tempo_map().replace_meter (*section, Meter (bpb, note_type));
_session->tempo_map().replace_meter (*section, Meter (bpb, note_type), when);
XMLNode &after = _session->tempo_map().get_state();
_session->add_command(new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
commit_reversible_command ();
@ -360,14 +363,9 @@ Editor::edit_tempo_section (TempoSection* section)
tempo_dialog.get_bbt_time(when);
bpm = max (0.01, bpm);
cerr << "Editing tempo section to be at " << when << endl;
_session->tempo_map().dump (cerr);
begin_reversible_command (_("replace tempo mark"));
XMLNode &before = _session->tempo_map().get_state();
_session->tempo_map().replace_tempo (*section, Tempo (bpm,nt));
_session->tempo_map().dump (cerr);
_session->tempo_map().move_tempo (*section, when);
_session->tempo_map().dump (cerr);
_session->tempo_map().replace_tempo (*section, Tempo (bpm, nt), when);
XMLNode &after = _session->tempo_map().get_state();
_session->add_command (new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
commit_reversible_command ();
@ -416,7 +414,7 @@ Editor::real_remove_tempo_marker (TempoSection *section)
{
begin_reversible_command (_("remove tempo mark"));
XMLNode &before = _session->tempo_map().get_state();
_session->tempo_map().remove_tempo (*section);
_session->tempo_map().remove_tempo (*section, true);
XMLNode &after = _session->tempo_map().get_state();
_session->add_command(new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
commit_reversible_command ();
@ -450,7 +448,7 @@ Editor::real_remove_meter_marker (MeterSection *section)
{
begin_reversible_command (_("remove tempo mark"));
XMLNode &before = _session->tempo_map().get_state();
_session->tempo_map().remove_meter (*section);
_session->tempo_map().remove_meter (*section, true);
XMLNode &after = _session->tempo_map().get_state();
_session->add_command(new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
commit_reversible_command ();

View file

@ -80,8 +80,12 @@ InsertTimeDialog::InsertTimeDialog (PublicEditor& e)
indent->set_padding (0, 0, 12, 0);
indent->add (_move_locked_markers);
get_vbox()->pack_start (*indent);
_move_tempos.set_label (_("Move tempo and meter changes"));
get_vbox()->pack_start (_move_tempos);
tempo_label.set_markup (_("Move tempo and meter changes\n<i>(may cause oddities in the tempo map)</i>"));
HBox* tempo_box = manage (new HBox);
tempo_box->set_spacing (6);
tempo_box->pack_start (_move_tempos, false, false);
tempo_box->pack_start (tempo_label, false, false);
get_vbox()->pack_start (*tempo_box);
add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
add_button (_("Insert time"), Gtk::RESPONSE_OK);

View file

@ -47,5 +47,6 @@ private:
Gtk::CheckButton _move_glued_markers;
Gtk::CheckButton _move_locked_markers;
Gtk::CheckButton _move_tempos;
Gtk::Label tempo_label;
AudioClock _clock;
};

View file

@ -455,7 +455,6 @@ MeterDialog::get_bbt_time (Timecode::BBT_Time& requested)
}
requested.beats = 1;
requested.ticks = 0;
return true;

View file

@ -57,6 +57,8 @@ namespace PBD {
extern uint64_t CycleTimers;
extern uint64_t MidiTrackers;
extern uint64_t Layering;
extern uint64_t TempoMath;
extern uint64_t TempoMap;
}
}

View file

@ -37,7 +37,10 @@
class XMLNode;
namespace ARDOUR {
class Meter;
class TempoMap;
class Tempo {
public:
Tempo (double bpm, double type=4.0) // defaulting to quarter note
@ -105,7 +108,9 @@ class MetricSection {
*/
virtual XMLNode& get_state() const = 0;
int compare (MetricSection *, bool) const;
int compare (const MetricSection&) const;
bool operator== (const MetricSection& other) const;
bool operator!= (const MetricSection& other) const;
private:
Timecode::BBT_Time _start;
@ -129,14 +134,29 @@ class MeterSection : public MetricSection, public Meter {
class TempoSection : public MetricSection, public Tempo {
public:
TempoSection (const Timecode::BBT_Time& start, double qpm, double note_type)
: MetricSection (start), Tempo (qpm, note_type) {}
: MetricSection (start), Tempo (qpm, note_type), _bar_offset (-1.0) {}
TempoSection (framepos_t start, double qpm, double note_type)
: MetricSection (start), Tempo (qpm, note_type) {}
: MetricSection (start), Tempo (qpm, note_type), _bar_offset (-1.0) {}
TempoSection (const XMLNode&);
static const std::string xml_state_node_name;
XMLNode& get_state() const;
void update_bar_offset_from_bbt (const Meter&);
void update_bbt_time_from_bar_offset (const Meter&);
double bar_offset() const { return _bar_offset; }
private:
/* this value provides a fractional offset into the bar in which
the tempo section is located in. A value of 0.0 indicates that
it occurs on the first beat of the bar, a value of 0.5 indicates
that it occurs halfway through the bar and so on.
this enables us to keep the tempo change at the same relative
position within the bar if/when the meter changes.
*/
double _bar_offset;
};
typedef std::list<MetricSection*> Metrics;
@ -215,17 +235,11 @@ class TempoMap : public PBD::StatefulDestructible
void add_tempo(const Tempo&, Timecode::BBT_Time where);
void add_meter(const Meter&, Timecode::BBT_Time where);
void add_tempo(const Tempo&, framepos_t where);
void add_meter(const Meter&, framepos_t where);
void remove_tempo(const TempoSection&, bool send_signal);
void remove_meter(const MeterSection&, bool send_signal);
void move_tempo (TempoSection&, const Timecode::BBT_Time& to);
void move_meter (MeterSection&, const Timecode::BBT_Time& to);
void remove_tempo(const TempoSection&);
void remove_meter(const MeterSection&);
void replace_tempo (TempoSection& existing, const Tempo& replacement);
void replace_meter (MeterSection& existing, const Meter& replacement);
void replace_tempo (const TempoSection&, const Tempo&, const Timecode::BBT_Time& where);
void replace_meter (const MeterSection&, const Meter&, const Timecode::BBT_Time& where);
framepos_t round_to_bar (framepos_t frame, int dir);
framepos_t round_to_beat (framepos_t frame, int dir);
@ -274,7 +288,8 @@ class TempoMap : public PBD::StatefulDestructible
Timecode::BBT_Time last_bbt;
mutable Glib::RWLock lock;
void timestamp_metrics (bool use_bbt);
void timestamp_metrics (bool reassign_bar_references);
void timestamp_metrics_from_audio_time ();
framepos_t round_to_type (framepos_t fr, int dir, BBTPointType);
@ -288,11 +303,11 @@ class TempoMap : public PBD::StatefulDestructible
const TempoSection& first_tempo() const;
framecnt_t count_frames_between (const Timecode::BBT_Time&, const Timecode::BBT_Time&) const;
framecnt_t count_frames_between_metrics (const Meter&, const Tempo&,
const Timecode::BBT_Time&, const Timecode::BBT_Time&) const;
framecnt_t count_frames_with_metrics (const TempoMetric&, const TempoMetric&, const Timecode::BBT_Time&, const Timecode::BBT_Time&) const;
framecnt_t count_frames_between_metrics (const Meter& meter, const Tempo& tempo, const Timecode::BBT_Time& start, const Timecode::BBT_Time& end) const;
int move_metric_section (MetricSection&, const Timecode::BBT_Time& to);
void do_insert (MetricSection* section, bool with_bbt);
void do_insert (MetricSection* section);
};
}; /* namespace ARDOUR */

View file

@ -54,4 +54,7 @@ uint64_t PBD::DEBUG::ControlProtocols = PBD::new_debug_bit ("controlprotocols");
uint64_t PBD::DEBUG::CycleTimers = PBD::new_debug_bit ("cycletimers");
uint64_t PBD::DEBUG::MidiTrackers = PBD::new_debug_bit ("miditrackers");
uint64_t PBD::DEBUG::Layering = PBD::new_debug_bit ("layering");
uint64_t PBD::DEBUG::TempoMath = PBD::new_debug_bit ("tempomath");
uint64_t PBD::DEBUG::TempoMap = PBD::new_debug_bit ("tempomap");

File diff suppressed because it is too large Load diff