complete changes to tempo type.

- this implements in the intention behind the previous commit.
	  a tempo mark is constant until its end has been changed by a
	  shift-drag on the next marker.
This commit is contained in:
nick_m 2017-02-26 02:22:19 +11:00
parent 30792f89b1
commit 922e40e0d3
11 changed files with 100 additions and 141 deletions

View File

@ -290,7 +290,7 @@ Editor::import_smf_tempo_map (Evoral::SMF const & smf, framepos_t pos)
Timecode::BBT_Time bbt; /* 1|1|0 which is correct for the no-meter case */
if (have_initial_meter) {
new_map.add_tempo (tempo, (t->time_pulses/smf.ppqn()) / 4.0, 0, TempoSection::Constant, MusicTime);
new_map.add_tempo (tempo, (t->time_pulses/smf.ppqn()) / 4.0, 0, MusicTime);
if (!(meter == last_meter)) {
bbt = new_map.bbt_at_quarter_note ((t->time_pulses/smf.ppqn()));
new_map.add_meter (meter, t->time_pulses, bbt, 0, MusicTime);
@ -298,7 +298,7 @@ Editor::import_smf_tempo_map (Evoral::SMF const & smf, framepos_t pos)
} else {
new_map.replace_meter (new_map.meter_section_at_frame (0), meter, bbt, pos, AudioTime);
new_map.replace_tempo (new_map.tempo_section_at_frame (0), tempo, 0.0, pos, TempoSection::Constant, AudioTime);
new_map.replace_tempo (new_map.tempo_section_at_frame (0), tempo, 0.0, pos, AudioTime);
have_initial_meter = true;
}

View File

@ -3431,15 +3431,14 @@ TempoMarkerDrag::motion (GdkEvent* event, bool first_move)
} else {
const Tempo tempo (_marker->tempo());
const framepos_t frame = adjusted_current_frame (event) + 1;
const TempoSection::Type type = _real_section->type();
_editor->begin_reversible_command (_("copy tempo mark"));
if (_real_section->position_lock_style() == MusicTime) {
const int32_t divisions = _editor->get_grid_music_divisions (event->button.state);
_real_section = map.add_tempo (tempo, map.exact_qn_at_frame (frame, divisions), 0, type, MusicTime);
_real_section = map.add_tempo (tempo, map.exact_qn_at_frame (frame, divisions), 0, MusicTime);
} else {
_real_section = map.add_tempo (tempo, 0.0, frame, type, AudioTime);
_real_section = map.add_tempo (tempo, 0.0, frame, AudioTime);
}
if (!_real_section) {

View File

@ -1417,21 +1417,20 @@ Editor::toggle_marker_lock_style ()
const double pulse = tsp->pulse();
const framepos_t frame = tsp->frame();
const TempoSection::Type type = tsp->type();
const PositionLockStyle pls = (tsp->position_lock_style() == AudioTime) ? MusicTime : AudioTime;
const Tempo tempo (tsp->note_types_per_minute(), tsp->note_type(), tsp->end_note_types_per_minute());
begin_reversible_command (_("change tempo lock style"));
XMLNode &before = _session->tempo_map().get_state();
_session->tempo_map().replace_tempo (*tsp, tempo, pulse, frame, type, pls);
_session->tempo_map().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 ();
}
}
/* actally just resets the ts to constant using initial tempo */
void
Editor::toggle_tempo_type ()
{
@ -1442,16 +1441,15 @@ Editor::toggle_tempo_type ()
if (tm) {
TempoSection* tsp = &tm->tempo();
const Tempo tempo (tsp->note_types_per_minute(), tsp->note_type(), tsp->end_note_types_per_minute());
const Tempo tempo (tsp->note_types_per_minute(), tsp->note_type());
const double pulse = tsp->pulse();
const framepos_t frame = tsp->frame();
const TempoSection::Type type = (tsp->type() == TempoSection::Ramp) ? TempoSection::Constant : TempoSection::Ramp;
const PositionLockStyle pls = tsp->position_lock_style();
begin_reversible_command (_("change tempo type"));
begin_reversible_command (_("set tempo to constant"));
XMLNode &before = _session->tempo_map().get_state();
_session->tempo_map().replace_tempo (*tsp, tempo, pulse, frame, type, pls);
_session->tempo_map().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));

View File

@ -6714,8 +6714,9 @@ Editor::define_one_bar (framepos_t start, framepos_t end)
} else if (t.frame() == start) {
_session->tempo_map().change_existing_tempo_at (start, beats_per_minute, t.note_type(), t.end_note_types_per_minute());
} else {
const Tempo tempo (beats_per_minute, t.note_type(), t.end_note_types_per_minute());
_session->tempo_map().add_tempo (tempo, 0.0, start, TempoSection::Constant, AudioTime);
/* constant tempo */
const Tempo tempo (beats_per_minute, t.note_type());
_session->tempo_map().add_tempo (tempo, 0.0, start, AudioTime);
}
XMLNode& after (_session->tempo_map().get_state());

View File

@ -404,7 +404,7 @@ Editor::mouse_add_new_tempo_event (framepos_t frame)
if (pulse > 0.0) {
XMLNode &before = map.get_state();
/* add music-locked ramped (?) tempo using the bpm/note type at frame*/
map.add_tempo (map.tempo_at_frame (frame), pulse, 0, TempoSection::Ramp, MusicTime);
map.add_tempo (map.tempo_at_frame (frame), pulse, 0, MusicTime);
XMLNode &after = map.get_state();
_session->add_command(new MementoCommand<TempoMap>(map, &before, &after));
@ -531,17 +531,15 @@ Editor::edit_tempo_section (TempoSection* section)
Timecode::BBT_Time when;
tempo_dialog.get_bbt_time (when);
const TempoSection::Type ttype (tempo_dialog.get_tempo_type());
begin_reversible_command (_("replace tempo mark"));
XMLNode &before = _session->tempo_map().get_state();
if (tempo_dialog.get_lock_style() == AudioTime) {
framepos_t const f = _session->tempo_map().predict_tempo_position (section, when).second;
_session->tempo_map().replace_tempo (*section, tempo, 0.0, f, ttype, AudioTime);
_session->tempo_map().replace_tempo (*section, tempo, 0.0, f, AudioTime);
} else {
double const p = _session->tempo_map().predict_tempo_position (section, when).first;
_session->tempo_map().replace_tempo (*section, tempo, p, 0, ttype, MusicTime);
_session->tempo_map().replace_tempo (*section, tempo, p, 0, MusicTime);
}
XMLNode &after = _session->tempo_map().get_state();

View File

@ -200,8 +200,8 @@ class LIBARDOUR_API TempoSection : public MetricSection, public Tempo {
Constant,
};
TempoSection (const double& pulse, const double& minute, Tempo tempo, Type tempo_type, PositionLockStyle pls, framecnt_t sr)
: MetricSection (pulse, minute, pls, true, sr), Tempo (tempo), _type (tempo_type), _c (0.0), _active (true), _locked_to_meter (false) {}
TempoSection (const double& pulse, const double& minute, Tempo tempo, PositionLockStyle pls, framecnt_t sr)
: MetricSection (pulse, minute, pls, true, sr), Tempo (tempo), _c (0.0), _active (true), _locked_to_meter (false) {}
TempoSection (const XMLNode&, const framecnt_t sample_rate);
@ -212,8 +212,7 @@ class LIBARDOUR_API TempoSection : public MetricSection, public Tempo {
double c () const { return _c; }
void set_c (double c) { _c = c; }
void set_type (Type type);
Type type () const { return _type; }
Type type () const { if (note_types_per_minute() == end_note_types_per_minute()) { return Constant; } else { return Ramp; } }
bool active () const { return _active; }
void set_active (bool yn) { _active = yn; }
@ -265,7 +264,6 @@ class LIBARDOUR_API TempoSection : public MetricSection, public Tempo {
this enables us to keep the tempo change at the same relative
position within the bar if/when the meter changes.
*/
Type _type;
double _c;
bool _active;
bool _locked_to_meter;
@ -374,7 +372,7 @@ class LIBARDOUR_API TempoMap : public PBD::StatefulDestructible
* @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);
TempoSection* add_tempo (const Tempo&, const double& pulse, const framepos_t& frame, PositionLockStyle pls);
/** add a meter section locked to pls.. ignored values will be set in recompute_meters()
* @param meter the Meter to be added
@ -394,8 +392,7 @@ class LIBARDOUR_API TempoMap : public PBD::StatefulDestructible
void remove_tempo (const TempoSection&, bool send_signal);
void remove_meter (const MeterSection&, bool send_signal);
void replace_tempo (TempoSection&, const Tempo&, const double& pulse, const framepos_t& frame
, TempoSection::Type type, PositionLockStyle pls);
void replace_tempo (TempoSection&, const Tempo&, const double& pulse, const framepos_t& frame, PositionLockStyle pls);
void replace_meter (const MeterSection&, const Meter&, const Timecode::BBT_Time& where, framepos_t frame, PositionLockStyle pls);
@ -589,7 +586,7 @@ private:
void do_insert (MetricSection* section);
TempoSection* add_tempo_locked (const Tempo&, double pulse, double minute
, TempoSection::Type type, PositionLockStyle pls, bool recompute, bool locked_to_meter = false);
, PositionLockStyle pls, bool recompute, bool locked_to_meter = false);
MeterSection* add_meter_locked (const Meter&, double beat, const Timecode::BBT_Time& where, framepos_t frame, PositionLockStyle pls, bool recompute);

View File

@ -171,12 +171,6 @@ TempoSection::TempoSection (const XMLNode& node, framecnt_t sample_rate)
set_active (string_is_affirmative (prop->value()));
}
if ((prop = node.property ("tempo-type")) == 0) {
_type = Constant;
} else {
_type = Type (string_2_enum (prop->value(), _type));
}
if ((prop = node.property ("lock-style")) == 0) {
if (!initial()) {
set_position_lock_style (MusicTime);
@ -224,25 +218,18 @@ TempoSection::get_state() const
root->add_property ("movable", buf);
snprintf (buf, sizeof (buf), "%s", active()?"yes":"no");
root->add_property ("active", buf);
root->add_property ("tempo-type", enum_2_string (_type));
root->add_property ("lock-style", enum_2_string (position_lock_style()));
root->add_property ("locked-to-meter", locked_to_meter()?"yes":"no");
return *root;
}
void
TempoSection::set_type (Type type)
{
_type = type;
}
/** returns the Tempo at the session-relative minute.
*/
Tempo
TempoSection::tempo_at_minute (const double& m) const
{
const bool constant = _type == Constant || _c == 0.0 || (initial() && m < minute());
const bool constant = type() == Constant || _c == 0.0 || (initial() && m < minute());
if (constant) {
return Tempo (note_types_per_minute(), note_type());
}
@ -268,7 +255,7 @@ TempoSection::tempo_at_minute (const double& m) const
double
TempoSection::minute_at_ntpm (const double& ntpm, const double& p) const
{
const bool constant = _type == Constant || _c == 0.0 || (initial() && p < pulse());
const bool constant = type() == Constant || _c == 0.0 || (initial() && p < pulse());
if (constant) {
return ((p - pulse()) / pulses_per_minute()) + minute();
}
@ -281,7 +268,7 @@ TempoSection::minute_at_ntpm (const double& ntpm, const double& p) const
Tempo
TempoSection::tempo_at_pulse (const double& p) const
{
const bool constant = _type == Constant || _c == 0.0 || (initial() && p < pulse());
const bool constant = type() == Constant || _c == 0.0 || (initial() && p < pulse());
if (constant) {
return Tempo (note_types_per_minute(), note_type());
@ -303,7 +290,7 @@ TempoSection::tempo_at_pulse (const double& p) const
double
TempoSection::pulse_at_ntpm (const double& ntpm, const double& m) const
{
const bool constant = _type == Constant || _c == 0.0 || (initial() && m < minute());
const bool constant = type() == Constant || _c == 0.0 || (initial() && m < minute());
if (constant) {
return ((m - minute()) * pulses_per_minute()) + pulse();
}
@ -316,7 +303,7 @@ TempoSection::pulse_at_ntpm (const double& ntpm, const double& m) const
double
TempoSection::pulse_at_minute (const double& m) const
{
const bool constant = _type == Constant || _c == 0.0 || (initial() && m < minute());
const bool constant = type() == Constant || _c == 0.0 || (initial() && m < minute());
if (constant) {
return ((m - minute()) * pulses_per_minute()) + pulse();
}
@ -329,7 +316,7 @@ TempoSection::pulse_at_minute (const double& m) const
double
TempoSection::minute_at_pulse (const double& p) const
{
const bool constant = _type == Constant || _c == 0.0 || (initial() && p < pulse());
const bool constant = type() == Constant || _c == 0.0 || (initial() && p < pulse());
if (constant) {
return ((p - pulse()) / pulses_per_minute()) + minute();
}
@ -346,7 +333,7 @@ TempoSection::minute_at_pulse (const double& p) const
double
TempoSection::pulse_at_frame (const framepos_t& f) const
{
const bool constant = _type == Constant || _c == 0.0 || (initial() && f < frame());
const bool constant = type() == Constant || _c == 0.0 || (initial() && f < frame());
if (constant) {
return (minute_at_frame (f - frame()) * pulses_per_minute()) + pulse();
}
@ -357,7 +344,7 @@ TempoSection::pulse_at_frame (const framepos_t& f) const
framepos_t
TempoSection::frame_at_pulse (const double& p) const
{
const bool constant = _type == Constant || _c == 0.0 || (initial() && p < pulse());
const bool constant = type() == Constant || _c == 0.0 || (initial() && p < pulse());
if (constant) {
return frame_at_minute (((p - pulse()) / pulses_per_minute()) + minute());
}
@ -448,7 +435,7 @@ https://www.zhdk.ch/fileadmin/data_subsites/data_icst/Downloads/Timegrid/ICST_Te
double
TempoSection::compute_c_pulse (const double& end_npm, const double& end_pulse) const
{
if (note_types_per_minute() == end_npm || _type == Constant) {
if (note_types_per_minute() == end_npm || type() == Constant) {
return 0.0;
}
@ -464,7 +451,7 @@ TempoSection::compute_c_pulse (const double& end_npm, const double& end_pulse) c
double
TempoSection::compute_c_minute (const double& end_npm, const double& end_minute) const
{
if (note_types_per_minute() == end_npm || _type == Constant) {
if (note_types_per_minute() == end_npm || type() == Constant) {
return 0.0;
}
@ -761,7 +748,7 @@ TempoMap::TempoMap (framecnt_t fr)
_frame_rate = fr;
BBT_Time start (1, 1, 0);
TempoSection *t = new TempoSection (0.0, 0.0, _default_tempo, TempoSection::Ramp, AudioTime, fr);
TempoSection *t = new TempoSection (0.0, 0.0, _default_tempo, AudioTime, fr);
MeterSection *m = new MeterSection (0.0, 0.0, 0.0, start, _default_meter.divisions_per_bar(), _default_meter.note_divisor(), AudioTime, fr);
t->set_initial (true);
@ -989,10 +976,6 @@ TempoMap::do_insert (MetricSection* section)
*(dynamic_cast<Tempo*>(*i)) = *(dynamic_cast<Tempo*>(insert_tempo));
(*i)->set_position_lock_style (AudioTime);
TempoSection* t;
if ((t = dynamic_cast<TempoSection*>(*i)) != 0) {
t->set_type (insert_tempo->type());
}
need_add = false;
} else {
delete (*i);
@ -1080,7 +1063,7 @@ TempoMap::do_insert (MetricSection* section)
}
/* user supplies the exact pulse if pls == MusicTime */
TempoSection*
TempoMap::add_tempo (const Tempo& tempo, const double& pulse, const framepos_t& frame, ARDOUR::TempoSection::Type type, PositionLockStyle pls)
TempoMap::add_tempo (const Tempo& tempo, const double& pulse, const framepos_t& frame, PositionLockStyle pls)
{
if (tempo.note_types_per_minute() <= 0.0) {
warning << "Cannot add tempo. note types per minute must be greater than zero." << endmsg;
@ -1091,7 +1074,7 @@ TempoMap::add_tempo (const Tempo& tempo, const double& pulse, const framepos_t&
TempoSection* prev_tempo = 0;
{
Glib::Threads::RWLock::WriterLock lm (lock);
ts = add_tempo_locked (tempo, pulse, minute_at_frame (frame), type, pls, true);
ts = add_tempo_locked (tempo, pulse, minute_at_frame (frame), pls, true);
for (Metrics::iterator i = _metrics.begin(); i != _metrics.end(); ++i) {
if ((*i)->is_tempo()) {
@ -1118,7 +1101,7 @@ TempoMap::add_tempo (const Tempo& tempo, const double& pulse, const framepos_t&
}
void
TempoMap::replace_tempo (TempoSection& ts, const Tempo& tempo, const double& pulse, const framepos_t& frame, TempoSection::Type type, PositionLockStyle pls)
TempoMap::replace_tempo (TempoSection& ts, const Tempo& tempo, const double& pulse, const framepos_t& frame, PositionLockStyle pls)
{
if (tempo.note_types_per_minute() <= 0.0) {
warning << "Cannot replace tempo. note types per minute must be greater than zero." << endmsg;
@ -1133,7 +1116,6 @@ TempoMap::replace_tempo (TempoSection& ts, const Tempo& tempo, const double& pul
TempoSection& first (first_tempo());
if (!ts.initial()) {
if (locked_to_meter) {
ts.set_type (type);
{
/* cannot move a meter-locked tempo section */
*static_cast<Tempo*>(&ts) = tempo;
@ -1141,7 +1123,7 @@ TempoMap::replace_tempo (TempoSection& ts, const Tempo& tempo, const double& pul
}
} else {
remove_tempo_locked (ts);
new_ts = add_tempo_locked (tempo, pulse, minute_at_frame (frame), type, pls, true, locked_to_meter);
new_ts = add_tempo_locked (tempo, pulse, minute_at_frame (frame), pls, true, locked_to_meter);
if (new_ts && new_ts->type() == TempoSection::Constant) {
new_ts->set_end_note_types_per_minute (new_ts->note_types_per_minute());
@ -1165,7 +1147,6 @@ TempoMap::replace_tempo (TempoSection& ts, const Tempo& tempo, const double& pul
}
} else {
first.set_type (type);
first.set_pulse (0.0);
first.set_minute (minute_at_frame (frame));
first.set_position_lock_style (AudioTime);
@ -1183,9 +1164,9 @@ TempoMap::replace_tempo (TempoSection& ts, const Tempo& tempo, const double& pul
TempoSection*
TempoMap::add_tempo_locked (const Tempo& tempo, double pulse, double minute
, TempoSection::Type type, PositionLockStyle pls, bool recompute, bool locked_to_meter)
, PositionLockStyle pls, bool recompute, bool locked_to_meter)
{
TempoSection* t = new TempoSection (pulse, minute, tempo, type, pls, _frame_rate);
TempoSection* t = new TempoSection (pulse, minute, tempo, pls, _frame_rate);
t->set_locked_to_meter (locked_to_meter);
do_insert (t);
@ -1263,7 +1244,7 @@ TempoMap::add_meter_locked (const Meter& meter, double beat, const BBT_Time& whe
if (pls == AudioTime) {
/* add meter-locked tempo */
mlt = add_tempo_locked (tempo_at_minute_locked (_metrics, time_minutes), pulse, minute_at_frame (frame), TempoSection::Ramp, AudioTime, true, true);
mlt = add_tempo_locked (tempo_at_minute_locked (_metrics, time_minutes), pulse, minute_at_frame (frame), AudioTime, true, true);
if (!mlt) {
return 0;
@ -3483,10 +3464,7 @@ TempoMap::gui_stretch_tempo (TempoSection* ts, const framepos_t frame, const fra
goto out;
}
/* this should be everywhere. no _type because type() is constant if note_types_per_minute() == end_types_per_minute()
but what to do with legact sessions?
*/
if (prev_t && prev_t->note_types_per_minute() != prev_t->end_note_types_per_minute()) {
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);
@ -3497,7 +3475,7 @@ TempoMap::gui_stretch_tempo (TempoSection* ts, const framepos_t frame, const fra
recompute_meters (future_map);
if (check_solved (future_map)) {
if (prev_t && prev_t->note_types_per_minute() != prev_t->end_note_types_per_minute()) {
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);
@ -3575,27 +3553,14 @@ TempoMap::gui_stretch_tempo_end (TempoSection* ts, const framepos_t frame, const
goto out;
}
if (prev_t && prev_t->type() == TempoSection::Ramp) {
prev_t->set_end_note_types_per_minute (new_bpm);
} else {
if (prev_t) {
prev_t->set_note_types_per_minute (new_bpm);
prev_t->set_end_note_types_per_minute (prev_t->note_types_per_minute());
}
}
prev_t->set_end_note_types_per_minute (new_bpm);
recompute_tempi (future_map);
recompute_meters (future_map);
if (check_solved (future_map)) {
if (prev_t && prev_t->type() == TempoSection::Ramp) {
ts->set_end_note_types_per_minute (new_bpm);
} else {
if (prev_t) {
ts->set_end_note_types_per_minute (prev_t->note_types_per_minute());
ts->set_note_types_per_minute (prev_t->note_types_per_minute());
}
}
ts->set_end_note_types_per_minute (new_bpm);
recompute_tempi (_metrics);
recompute_meters (_metrics);
}

View File

@ -22,7 +22,7 @@ FrameposPlusBeatsTest::singleTempoTest ()
Meter meter (4, 4);
map.replace_meter (map.first_meter(), meter, BBT_Time (1, 1, 0), 0, AudioTime);
map.replace_tempo (map.first_tempo(), tempo, 0.0, 0, TempoSection::Constant, AudioTime);
map.replace_tempo (map.first_tempo(), tempo, 0.0, 0, AudioTime);
/* Add 1 beat to beat 3 of the first bar */
framepos_t r = map.framepos_plus_qn (frames_per_beat * 2, Evoral::Beats(1));
@ -63,9 +63,9 @@ FrameposPlusBeatsTest::doubleTempoTest ()
*/
Tempo tempoA (120, 4.0);
map.replace_tempo (map.first_tempo(), tempoA, 0.0, 0, TempoSection::Constant, AudioTime);
map.replace_tempo (map.first_tempo(), tempoA, 0.0, 0, AudioTime);
Tempo tempoB (240, 4.0);
map.add_tempo (tempoB, 12.0 / tempoA.note_type(), 0, TempoSection::Constant, MusicTime);
map.add_tempo (tempoB, 12.0 / tempoA.note_type(), 0, MusicTime);
/* Now some tests */
@ -116,9 +116,9 @@ FrameposPlusBeatsTest::doubleTempoWithMeterTest ()
*/
Tempo tempoA (120, 4.0);
map.replace_tempo (map.first_tempo(), tempoA, 0.0, 0, TempoSection::Constant, AudioTime);
map.replace_tempo (map.first_tempo(), tempoA, 0.0, 0, AudioTime);
Tempo tempoB (240, 4.0);
map.add_tempo (tempoB, 12.0 / tempoA.note_type(), 0, TempoSection::Constant, MusicTime);
map.add_tempo (tempoB, 12.0 / tempoA.note_type(), 0, MusicTime);
Meter meterB (3, 8);
map.add_meter (meterB, 12.0, BBT_Time (4, 1, 0), 0, MusicTime);
@ -173,9 +173,9 @@ FrameposPlusBeatsTest::doubleTempoWithComplexMeterTest ()
*/
Tempo tempoA (120, 4.0);
map.replace_tempo (map.first_tempo(), tempoA, 0.0, 0, TempoSection::Constant, AudioTime);
map.replace_tempo (map.first_tempo(), tempoA, 0.0, 0, AudioTime);
Tempo tempoB (240, 4.0);
map.add_tempo (tempoB, 12.0 / 4.0, 0, TempoSection::Constant, MusicTime);
map.add_tempo (tempoB, 12.0 / 4.0, 0, MusicTime);
Meter meterB (5, 8);
map.add_meter (meterB, 9.0, BBT_Time (4, 1, 0), 0, MusicTime);
/* Now some tests */

View File

@ -21,7 +21,7 @@ FramewalkToBeatsTest::singleTempoTest ()
Meter meter (4, 4);
map.replace_meter (map.meter_section_at_frame (0), meter, BBT_Time (1, 1, 0), 0, AudioTime);
map.replace_tempo (map.tempo_section_at_frame (0), tempo, 0.0, 0, TempoSection::Constant, AudioTime);
map.replace_tempo (map.tempo_section_at_frame (0), tempo, 0.0, 0, AudioTime);
/* Walk 1 beats-worth of frames from beat 3 */
double r = map.framewalk_to_qn (frames_per_beat * 2, frames_per_beat * 1).to_double();
@ -71,9 +71,9 @@ FramewalkToBeatsTest::doubleTempoTest ()
*/
Tempo tempoA (120);
map.replace_tempo (map.tempo_section_at_frame (0), tempoA, 0.0, 0, TempoSection::Constant, AudioTime);
map.replace_tempo (map.tempo_section_at_frame (0), tempoA, 0.0, 0, AudioTime);
Tempo tempoB (240);
map.add_tempo (tempoB, 12.0 / tempoB.note_type(), 0, TempoSection::Constant, MusicTime);
map.add_tempo (tempoB, 12.0 / tempoB.note_type(), 0, MusicTime);
/* Now some tests */
@ -127,11 +127,11 @@ FramewalkToBeatsTest::tripleTempoTest ()
*/
Tempo tempoA (120, 4.0);
map.replace_tempo (map.tempo_section_at_frame (0), tempoA, 0.0, 0, TempoSection::Constant, AudioTime);
map.replace_tempo (map.tempo_section_at_frame (0), tempoA, 0.0, 0, AudioTime);
Tempo tempoB (240, 4.0);
map.add_tempo (tempoB, 4.0 / tempoB.note_type(), 0, TempoSection::Constant, MusicTime);
map.add_tempo (tempoB, 4.0 / tempoB.note_type(), 0, MusicTime);
Tempo tempoC (160, 4.0);
map.add_tempo (tempoC, 8.0 / tempoB.note_type(), 0, TempoSection::Constant, MusicTime);
map.add_tempo (tempoC, 8.0 / tempoB.note_type(), 0, MusicTime);
/* Walk from 1|3 to 4|1 */
double r = map.framewalk_to_qn (2 * 24e3, (2 * 24e3) + (4 * 12e3) + (4 * 18e3)).to_double();
@ -151,7 +151,7 @@ FramewalkToBeatsTest::singleTempoMeterTest ()
Meter meter (7, 8);
map.replace_meter (map.meter_section_at_frame (0), meter, BBT_Time (1, 1, 0), 0, AudioTime);
map.replace_tempo (map.tempo_section_at_frame (0), tempo, 0.0, 0, TempoSection::Constant, AudioTime);
map.replace_tempo (map.tempo_section_at_frame (0), tempo, 0.0, 0, AudioTime);
/* Walk 1 qn beats-worth of frames from beat 3 */
double r = map.framewalk_to_qn (frames_per_beat * 2, frames_per_beat * 1).to_double();

View File

@ -48,7 +48,7 @@ class TestSlaveSessionProxy : public ISlaveSessionProxy {
meter (4.0, 4.0)
{
_tempo_map = new TempoMap (FRAME_RATE);
_tempo_map->add_tempo (tempo, 0.0, 0, TempoSection::Constant, AudioTime);
_tempo_map->add_tempo (tempo, 0.0, 0, AudioTime);
_tempo_map->add_meter (meter, 0.0, Timecode::BBT_Time(1, 1, 0), 0, AudioTime);
}

View File

@ -36,9 +36,9 @@ TempoTest::recomputeMapTest48 ()
*/
Tempo tempoA (120.0, 4.0);
map.replace_tempo (map.first_tempo(), tempoA, 0.0, 0, TempoSection::Constant, AudioTime);
map.replace_tempo (map.first_tempo(), tempoA, 0.0, 0, AudioTime);
Tempo tempoB (240.0, 4.0);
map.add_tempo (tempoB, 3.0, 0, TempoSection::Constant, MusicTime);
map.add_tempo (tempoB, 3.0, 0, MusicTime);
Meter meterB (3, 4);
map.add_meter (meterB, 12.0, BBT_Time (4, 1, 0), 0, MusicTime);
//map.dump (map._metrics, std::cout);
@ -134,9 +134,9 @@ TempoTest::recomputeMapTest44 ()
*/
Tempo tempoA (120.0, 4.0);
map.replace_tempo (map.first_tempo(), tempoA, 0.0, 0, TempoSection::Constant, AudioTime);
map.replace_tempo (map.first_tempo(), tempoA, 0.0, 0, AudioTime);
Tempo tempoB (240.0, 4.0);
map.add_tempo (tempoB, 3.0, 0, TempoSection::Constant, MusicTime);
map.add_tempo (tempoB, 3.0, 0, MusicTime);
Meter meterB (3, 4);
map.add_meter (meterB, 12.0, BBT_Time (4, 1, 0), 288e3, MusicTime);
@ -234,21 +234,21 @@ TempoTest::qnDistanceTestConstant ()
*/
Tempo tempoA (120.0, 4.0);
map.replace_tempo (map.first_tempo(), tempoA, 0.0, 0, TempoSection::Constant, AudioTime);
map.replace_tempo (map.first_tempo(), tempoA, 0.0, 0, AudioTime);
/* should have no effect on pulse */
Tempo tempoB (120.0, 4.0);
map.add_tempo (tempoB, 2.0, 0, TempoSection::Constant, MusicTime);
map.add_tempo (tempoB, 2.0, 0, MusicTime);
/* equivalent to pulse 3.0 @ 120 bpm*/
Tempo tempoC (240.0, 4.0);
map.add_tempo (tempoC, 0.0, 6 * sampling_rate, TempoSection::Constant, AudioTime);
map.add_tempo (tempoC, 0.0, 6 * sampling_rate, AudioTime);
Tempo tempoD (90.4, 4.0);
map.add_tempo (tempoD, 9.0, 0, TempoSection::Constant, MusicTime);
map.add_tempo (tempoD, 9.0, 0, MusicTime);
Tempo tempoE (110.6, 4.0);
map.add_tempo (tempoE, 12.0, 0, TempoSection::Constant, MusicTime);
map.add_tempo (tempoE, 12.0, 0, MusicTime);
Tempo tempoF (123.7, 4.0);
map.add_tempo (tempoF, 15.0, 0, TempoSection::Constant, MusicTime);
map.add_tempo (tempoF, 15.0, 0, MusicTime);
Tempo tempoG (111.8, 4.0);
map.add_tempo (tempoG, 0.0, (framepos_t) 2 * 60 * sampling_rate, TempoSection::Constant, AudioTime);
map.add_tempo (tempoG, 0.0, (framepos_t) 2 * 60 * sampling_rate, AudioTime);
Meter meterB (3, 4);
map.add_meter (meterB, 12.0, BBT_Time (4, 1, 0), 288e3, MusicTime);
@ -313,23 +313,24 @@ TempoTest::qnDistanceTestRamp ()
*/
Tempo tempoA (120.2, 4.0);
map.replace_tempo (map.first_tempo(), tempoA, 0.0, 0, TempoSection::Ramp, AudioTime);
Tempo tempoB (240.5, 4.0);
map.add_tempo (tempoB, 3.0, 0, TempoSection::Ramp, MusicTime);
Tempo tempoA (120.2, 4.0, 240.5);
map.replace_tempo (map.first_tempo(), tempoA, 0.0, 0, AudioTime);
Tempo tempoB (240.5, 4.0, 130.1);
map.add_tempo (tempoB, 3.0, 0, MusicTime);
Tempo tempoC (130.1, 4.0);
map.add_tempo (tempoC, 0.0, 6 * sampling_rate, TempoSection::Ramp, AudioTime);
Tempo tempoD (90.3, 4.0);
map.add_tempo (tempoD, 9.0, 0, TempoSection::Ramp, MusicTime);
Tempo tempoE (110.7, 4.0);
map.add_tempo (tempoE, 12.0, 0, TempoSection::Ramp, MusicTime);
Tempo tempoF (123.9, 4.0);
map.add_tempo (tempoF, 15.0, 0, TempoSection::Ramp, MusicTime);
Tempo tempoC (130.1, 4.0, 90.3);
map.add_tempo (tempoC, 0.0, 6 * sampling_rate, AudioTime);
Tempo tempoD (90.3, 4.0, 110.7);
map.add_tempo (tempoD, 9.0, 0, MusicTime);
Tempo tempoE (110.7, 4.0, 123.9);
map.add_tempo (tempoE, 12.0, 0, MusicTime);
Tempo tempoF (123.9, 4.0, 111.8);
map.add_tempo (tempoF, 15.0, 0, MusicTime);
Tempo tempoG (111.8, 4.0);
map.add_tempo (tempoG, 0.0, (framepos_t) 2 * 60 * sampling_rate, TempoSection::Ramp, AudioTime);
map.add_tempo (tempoG, 0.0, (framepos_t) 2 * 60 * sampling_rate, AudioTime);
Meter meterB (3, 4);
map.add_meter (meterB, 4.0, BBT_Time (2, 1, 0), 288e3, AudioTime);
map.dump (std::cout);
map.recompute_map (map._metrics, 1);
list<MetricSection*>::iterator i = map._metrics.begin();
@ -367,10 +368,10 @@ TempoTest::rampTest48 ()
TempoMap map (sampling_rate);
Meter meterA (4, 4);
Tempo tempoA (77.0, 4.0);
Tempo tempoA (77.0, 4.0, 217.0);
Tempo tempoB (217.0, 4.0);
map.replace_tempo (map.first_tempo(), tempoA, 0.0, 0, TempoSection::Ramp, AudioTime);
map.add_tempo (tempoB, 0.0, (framepos_t) 60 * sampling_rate, TempoSection::Ramp, AudioTime);
map.replace_tempo (map.first_tempo(), tempoA, 0.0, 0, AudioTime);
map.add_tempo (tempoB, 0.0, (framepos_t) 60 * sampling_rate, AudioTime);
map.replace_meter (map.first_meter(), meterA, BBT_Time (1, 1, 0), 0, AudioTime);
/*
@ -429,10 +430,10 @@ TempoTest::rampTest44 ()
TempoMap map (sampling_rate);
Meter meterA (4, 4);
Tempo tempoA (77.0, 4.0);
Tempo tempoA (77.0, 4.0, 217.0);
Tempo tempoB (217.0, 4.0);
map.replace_tempo (map.first_tempo(), tempoA, 0.0, 0, TempoSection::Ramp, AudioTime);
map.add_tempo (tempoB, 0.0, (framepos_t) 60 * sampling_rate, TempoSection::Ramp, AudioTime);
map.replace_tempo (map.first_tempo(), tempoA, 0.0, 0, AudioTime);
map.add_tempo (tempoB, 0.0, (framepos_t) 60 * sampling_rate, AudioTime);
map.replace_meter (map.first_meter(), meterA, BBT_Time (1, 1, 0), 0, AudioTime);
/*
@ -491,15 +492,15 @@ TempoTest::tempoAtPulseTest ()
TempoMap map (sampling_rate);
Meter meterA (4, 8);
Tempo tempoA (80.0, 8.0);
Tempo tempoB (160.0, 3.0);
Tempo tempoA (80.0, 8.0, 160.0);
Tempo tempoB (160.0, 3.0, 123.0);
Tempo tempoC (123.0, 4.0);
map.replace_meter (map.first_meter(), meterA, BBT_Time (1, 1, 0), 0, AudioTime);
map.replace_tempo (map.first_tempo(), tempoA, 0.0, 0, TempoSection::Ramp, AudioTime);
map.replace_tempo (map.first_tempo(), tempoA, 0.0, 0, AudioTime);
map.add_tempo (tempoB, 20.0, 0, TempoSection::Ramp, MusicTime);
map.add_tempo (tempoC, 30.0, 0, TempoSection::Ramp, MusicTime);
map.add_tempo (tempoB, 20.0, 0, MusicTime);
map.add_tempo (tempoC, 30.0, 0, MusicTime);
TempoSection* tA = 0;
TempoSection* tB = 0;
@ -569,13 +570,13 @@ TempoTest::tempoFundamentalsTest ()
Tempo tempoE (123.0, 3.0);
map.replace_meter (map.first_meter(), meterA, BBT_Time (1, 1, 0), 0, AudioTime);
map.replace_tempo (map.first_tempo(), tempoA, 0.0, 0, TempoSection::Constant, AudioTime);
map.replace_tempo (map.first_tempo(), tempoA, 0.0, 0, AudioTime);
map.add_tempo (tempoB, 20.0, 0, TempoSection::Constant, MusicTime);
map.add_tempo (tempoC, 30.0, 0, TempoSection::Constant, MusicTime);
map.add_tempo (tempoB, 20.0, 0, MusicTime);
map.add_tempo (tempoC, 30.0, 0, MusicTime);
map.add_tempo (tempoD, 40.0, 0, TempoSection::Constant, MusicTime);
map.add_tempo (tempoE, 50.0, 0, TempoSection::Constant, MusicTime);
map.add_tempo (tempoD, 40.0, 0, MusicTime);
map.add_tempo (tempoE, 50.0, 0, MusicTime);
TempoSection* tA = 0;
TempoSection* tB = 0;