mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-09 16:24:57 +01:00
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:
parent
c3a52084f8
commit
a85e0b0a2e
9 changed files with 536 additions and 369 deletions
|
|
@ -1972,7 +1972,7 @@ MeterMarkerDrag::motion (GdkEvent* event, bool first_move)
|
||||||
if (!_copy) {
|
if (!_copy) {
|
||||||
TempoMap& map (_editor->session()->tempo_map());
|
TempoMap& map (_editor->session()->tempo_map());
|
||||||
/* remove the section while we drag it */
|
/* 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) {
|
if (!_copy) {
|
||||||
TempoMap& map (_editor->session()->tempo_map());
|
TempoMap& map (_editor->session()->tempo_map());
|
||||||
/* remove the section while we drag it */
|
/* 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) {
|
if (moved) {
|
||||||
TempoMap& map (_editor->session()->tempo_map());
|
TempoMap& map (_editor->session()->tempo_map());
|
||||||
/* we removed it before, so add it back now */
|
/* 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.
|
// delete the dummy marker we used for visual representation while moving.
|
||||||
// a new visual marker will show up automatically.
|
// a new visual marker will show up automatically.
|
||||||
delete _marker;
|
delete _marker;
|
||||||
|
|
|
||||||
|
|
@ -330,9 +330,12 @@ Editor::edit_meter_section (MeterSection* section)
|
||||||
|
|
||||||
double note_type = meter_dialog.get_note_type ();
|
double note_type = meter_dialog.get_note_type ();
|
||||||
|
|
||||||
|
Timecode::BBT_Time when;
|
||||||
|
meter_dialog.get_bbt_time(when);
|
||||||
|
|
||||||
begin_reversible_command (_("replace tempo mark"));
|
begin_reversible_command (_("replace tempo mark"));
|
||||||
XMLNode &before = _session->tempo_map().get_state();
|
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();
|
XMLNode &after = _session->tempo_map().get_state();
|
||||||
_session->add_command(new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
|
_session->add_command(new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
|
||||||
commit_reversible_command ();
|
commit_reversible_command ();
|
||||||
|
|
@ -360,14 +363,9 @@ Editor::edit_tempo_section (TempoSection* section)
|
||||||
tempo_dialog.get_bbt_time(when);
|
tempo_dialog.get_bbt_time(when);
|
||||||
bpm = max (0.01, bpm);
|
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"));
|
begin_reversible_command (_("replace tempo mark"));
|
||||||
XMLNode &before = _session->tempo_map().get_state();
|
XMLNode &before = _session->tempo_map().get_state();
|
||||||
_session->tempo_map().replace_tempo (*section, Tempo (bpm,nt));
|
_session->tempo_map().replace_tempo (*section, Tempo (bpm, nt), when);
|
||||||
_session->tempo_map().dump (cerr);
|
|
||||||
_session->tempo_map().move_tempo (*section, when);
|
|
||||||
_session->tempo_map().dump (cerr);
|
|
||||||
XMLNode &after = _session->tempo_map().get_state();
|
XMLNode &after = _session->tempo_map().get_state();
|
||||||
_session->add_command (new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
|
_session->add_command (new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
|
||||||
commit_reversible_command ();
|
commit_reversible_command ();
|
||||||
|
|
@ -416,7 +414,7 @@ Editor::real_remove_tempo_marker (TempoSection *section)
|
||||||
{
|
{
|
||||||
begin_reversible_command (_("remove tempo mark"));
|
begin_reversible_command (_("remove tempo mark"));
|
||||||
XMLNode &before = _session->tempo_map().get_state();
|
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();
|
XMLNode &after = _session->tempo_map().get_state();
|
||||||
_session->add_command(new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
|
_session->add_command(new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
|
||||||
commit_reversible_command ();
|
commit_reversible_command ();
|
||||||
|
|
@ -450,7 +448,7 @@ Editor::real_remove_meter_marker (MeterSection *section)
|
||||||
{
|
{
|
||||||
begin_reversible_command (_("remove tempo mark"));
|
begin_reversible_command (_("remove tempo mark"));
|
||||||
XMLNode &before = _session->tempo_map().get_state();
|
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();
|
XMLNode &after = _session->tempo_map().get_state();
|
||||||
_session->add_command(new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
|
_session->add_command(new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
|
||||||
commit_reversible_command ();
|
commit_reversible_command ();
|
||||||
|
|
|
||||||
|
|
@ -80,8 +80,12 @@ InsertTimeDialog::InsertTimeDialog (PublicEditor& e)
|
||||||
indent->set_padding (0, 0, 12, 0);
|
indent->set_padding (0, 0, 12, 0);
|
||||||
indent->add (_move_locked_markers);
|
indent->add (_move_locked_markers);
|
||||||
get_vbox()->pack_start (*indent);
|
get_vbox()->pack_start (*indent);
|
||||||
_move_tempos.set_label (_("Move tempo and meter changes"));
|
tempo_label.set_markup (_("Move tempo and meter changes\n<i>(may cause oddities in the tempo map)</i>"));
|
||||||
get_vbox()->pack_start (_move_tempos);
|
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 (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
|
||||||
add_button (_("Insert time"), Gtk::RESPONSE_OK);
|
add_button (_("Insert time"), Gtk::RESPONSE_OK);
|
||||||
|
|
|
||||||
|
|
@ -47,5 +47,6 @@ private:
|
||||||
Gtk::CheckButton _move_glued_markers;
|
Gtk::CheckButton _move_glued_markers;
|
||||||
Gtk::CheckButton _move_locked_markers;
|
Gtk::CheckButton _move_locked_markers;
|
||||||
Gtk::CheckButton _move_tempos;
|
Gtk::CheckButton _move_tempos;
|
||||||
|
Gtk::Label tempo_label;
|
||||||
AudioClock _clock;
|
AudioClock _clock;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -455,7 +455,6 @@ MeterDialog::get_bbt_time (Timecode::BBT_Time& requested)
|
||||||
}
|
}
|
||||||
|
|
||||||
requested.beats = 1;
|
requested.beats = 1;
|
||||||
|
|
||||||
requested.ticks = 0;
|
requested.ticks = 0;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,8 @@ namespace PBD {
|
||||||
extern uint64_t CycleTimers;
|
extern uint64_t CycleTimers;
|
||||||
extern uint64_t MidiTrackers;
|
extern uint64_t MidiTrackers;
|
||||||
extern uint64_t Layering;
|
extern uint64_t Layering;
|
||||||
|
extern uint64_t TempoMath;
|
||||||
|
extern uint64_t TempoMap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,10 @@
|
||||||
class XMLNode;
|
class XMLNode;
|
||||||
|
|
||||||
namespace ARDOUR {
|
namespace ARDOUR {
|
||||||
|
|
||||||
class Meter;
|
class Meter;
|
||||||
|
class TempoMap;
|
||||||
|
|
||||||
class Tempo {
|
class Tempo {
|
||||||
public:
|
public:
|
||||||
Tempo (double bpm, double type=4.0) // defaulting to quarter note
|
Tempo (double bpm, double type=4.0) // defaulting to quarter note
|
||||||
|
|
@ -105,7 +108,9 @@ class MetricSection {
|
||||||
*/
|
*/
|
||||||
virtual XMLNode& get_state() const = 0;
|
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:
|
private:
|
||||||
Timecode::BBT_Time _start;
|
Timecode::BBT_Time _start;
|
||||||
|
|
@ -129,14 +134,29 @@ class MeterSection : public MetricSection, public Meter {
|
||||||
class TempoSection : public MetricSection, public Tempo {
|
class TempoSection : public MetricSection, public Tempo {
|
||||||
public:
|
public:
|
||||||
TempoSection (const Timecode::BBT_Time& start, double qpm, double note_type)
|
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)
|
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&);
|
TempoSection (const XMLNode&);
|
||||||
|
|
||||||
static const std::string xml_state_node_name;
|
static const std::string xml_state_node_name;
|
||||||
|
|
||||||
XMLNode& get_state() const;
|
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;
|
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_tempo(const Tempo&, Timecode::BBT_Time where);
|
||||||
void add_meter(const Meter&, Timecode::BBT_Time where);
|
void add_meter(const Meter&, Timecode::BBT_Time where);
|
||||||
|
|
||||||
void add_tempo(const Tempo&, framepos_t where);
|
void remove_tempo(const TempoSection&, bool send_signal);
|
||||||
void add_meter(const Meter&, framepos_t where);
|
void remove_meter(const MeterSection&, bool send_signal);
|
||||||
|
|
||||||
void move_tempo (TempoSection&, const Timecode::BBT_Time& to);
|
void replace_tempo (const TempoSection&, const Tempo&, const Timecode::BBT_Time& where);
|
||||||
void move_meter (MeterSection&, const Timecode::BBT_Time& to);
|
void replace_meter (const MeterSection&, const Meter&, const Timecode::BBT_Time& where);
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
framepos_t round_to_bar (framepos_t frame, int dir);
|
framepos_t round_to_bar (framepos_t frame, int dir);
|
||||||
framepos_t round_to_beat (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;
|
Timecode::BBT_Time last_bbt;
|
||||||
mutable Glib::RWLock lock;
|
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);
|
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;
|
const TempoSection& first_tempo() const;
|
||||||
|
|
||||||
framecnt_t count_frames_between (const Timecode::BBT_Time&, const Timecode::BBT_Time&) 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&,
|
framecnt_t count_frames_with_metrics (const TempoMetric&, const TempoMetric&, const Timecode::BBT_Time&, const Timecode::BBT_Time&) const;
|
||||||
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);
|
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 */
|
}; /* namespace ARDOUR */
|
||||||
|
|
|
||||||
|
|
@ -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::CycleTimers = PBD::new_debug_bit ("cycletimers");
|
||||||
uint64_t PBD::DEBUG::MidiTrackers = PBD::new_debug_bit ("miditrackers");
|
uint64_t PBD::DEBUG::MidiTrackers = PBD::new_debug_bit ("miditrackers");
|
||||||
uint64_t PBD::DEBUG::Layering = PBD::new_debug_bit ("layering");
|
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
Loading…
Add table
Add a link
Reference in a new issue