const double beat = map.bbt_to_beats (bbt);
if (_real_section->position_lock_style() == AudioTime) {
- _real_section = map.add_meter (Meter (_marker->meter().divisions_per_bar(), _marker->meter().note_divisor())
+ _real_section = map.add_meter_frame (Meter (_marker->meter().divisions_per_bar(), _marker->meter().note_divisor())
, map.frame_time (bbt), beat, bbt);
} else {
- _real_section = map.add_meter (Meter (_marker->meter().divisions_per_bar(), _marker->meter().note_divisor()), beat, bbt);
+ _real_section = map.add_meter_beat (Meter (_marker->meter().divisions_per_bar(), _marker->meter().note_divisor()), beat, bbt);
}
}
}
} else if ((bbt.bars != _real_section->bbt().bars && pf > last_pointer_frame())
|| (bbt.bars < _real_section->bbt().bars && pf < last_pointer_frame())) {
/* move meter beat-based */
- _editor->session()->tempo_map().gui_move_meter (_real_section, bbt);
+ _editor->session()->tempo_map().gui_move_meter_bbt (_real_section, bbt);
}
} else {
/* AudioTime */
_editor->session()->tempo_map().gui_dilate_tempo (_real_section, pf);
}
} else {
- _editor->session()->tempo_map().gui_move_meter (_real_section, pf);
+ _editor->session()->tempo_map().gui_move_meter_frame (_real_section, pf);
}
}
_marker->set_position (pf);
map.round_bbt (bbt, _editor->get_grid_beat_divisions (0), RoundNearest);
}
double const pulse = map.predict_tempo_pulse (_real_section, map.frame_time (bbt));
- _real_section = map.add_tempo (_marker->tempo(), pulse, _real_section->type());
+ _real_section = map.add_tempo_pulse (_marker->tempo(), pulse, _real_section->type());
} else {
if (use_snap && _editor->snap_type() == SnapToBar) {
map.round_bbt (bbt, -1, (frame > _real_section->frame()) ? RoundUpMaybe : RoundDownMaybe);
if (use_snap) {
frame = map.predict_tempo_frame (_real_section, bbt);
}
- _real_section = map.add_tempo (_marker->tempo(), frame, _real_section->type());
+ _real_section = map.add_tempo_frame (_marker->tempo(), frame, _real_section->type());
}
}
XMLNode &before = _session->tempo_map().get_state();
MeterSection* msp = &mm->meter();
if (mm->meter().position_lock_style() == AudioTime) {
- _session->tempo_map().replace_meter (*msp, Meter (msp->divisions_per_bar(), msp->note_divisor()), msp->bbt());
+ _session->tempo_map().replace_meter_bbt (*msp, Meter (msp->divisions_per_bar(), msp->note_divisor()), msp->bbt());
} else {
- _session->tempo_map().replace_meter (*msp, Meter (msp->divisions_per_bar(), msp->note_divisor()), msp->frame());
+ _session->tempo_map().replace_meter_frame (*msp, Meter (msp->divisions_per_bar(), msp->note_divisor()), msp->frame());
}
XMLNode &after = _session->tempo_map().get_state();
_session->add_command(new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
XMLNode &before = _session->tempo_map().get_state();
TempoSection* tsp = &tm->tempo();
if (tsp->position_lock_style() == AudioTime) {
- _session->tempo_map().replace_tempo (*tsp, Tempo (tsp->beats_per_minute(), tsp->note_type()), tsp->pulse(), tsp->type());
+ _session->tempo_map().replace_tempo_pulse (*tsp, Tempo (tsp->beats_per_minute(), tsp->note_type()), tsp->pulse(), tsp->type());
} else {
- _session->tempo_map().replace_tempo (*tsp, Tempo (tsp->beats_per_minute(), tsp->note_type()), tsp->frame(), tsp->type());
+ _session->tempo_map().replace_tempo_frame (*tsp, Tempo (tsp->beats_per_minute(), tsp->note_type()), tsp->frame(), tsp->type());
}
XMLNode &after = _session->tempo_map().get_state();
_session->add_command(new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
XMLNode &before = _session->tempo_map().get_state();
TempoSection* tsp = &tm->tempo();
if (tsp->position_lock_style() == AudioTime) {
- _session->tempo_map().replace_tempo (*tsp, Tempo (tsp->beats_per_minute(), tsp->note_type()), tsp->frame(), (tsp->type() == TempoSection::Ramp) ? TempoSection::Constant : TempoSection::Ramp);
+ _session->tempo_map().replace_tempo_frame (*tsp, Tempo (tsp->beats_per_minute(), tsp->note_type())
+ , tsp->frame(), (tsp->type() == TempoSection::Ramp) ? TempoSection::Constant : TempoSection::Ramp);
} else {
- _session->tempo_map().replace_tempo (*tsp, Tempo (tsp->beats_per_minute(), tsp->note_type()), tsp->pulse(), (tsp->type() == TempoSection::Ramp) ? TempoSection::Constant : TempoSection::Ramp);
+ _session->tempo_map().replace_tempo_pulse (*tsp, Tempo (tsp->beats_per_minute(), tsp->note_type())
+ , tsp->pulse(), (tsp->type() == TempoSection::Ramp) ? TempoSection::Constant : TempoSection::Ramp);
}
XMLNode &after = _session->tempo_map().get_state();
} else if (t.frame() == start) {
_session->tempo_map().change_existing_tempo_at (start, beats_per_minute, t.note_type());
} else {
- _session->tempo_map().add_tempo (Tempo (beats_per_minute, t.note_type()), start, TempoSection::Constant);
+ _session->tempo_map().add_tempo_frame (Tempo (beats_per_minute, t.note_type()), start, TempoSection::Constant);
}
XMLNode& after (_session->tempo_map().get_state());
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), pulse, TempoSection::Ramp);
+ map.add_tempo_pulse (map.tempo_at (frame), pulse, TempoSection::Ramp);
XMLNode &after = map.get_state();
_session->add_command(new MementoCommand<TempoMap>(map, &before, &after));
XMLNode &before = map.get_state();
if (meter_dialog.get_lock_style() == MusicTime) {
- map.add_meter (Meter (bpb, note_type), map.bbt_to_beats (requested), requested);
+ map.add_meter_beat (Meter (bpb, note_type), map.bbt_to_beats (requested), requested);
} else {
- map.add_meter (Meter (bpb, note_type), map.frame_time (requested), map.bbt_to_beats (requested), requested);
+ map.add_meter_frame (Meter (bpb, note_type), map.frame_time (requested), map.bbt_to_beats (requested), requested);
}
_session->add_command(new MementoCommand<TempoMap>(map, &before, &map.get_state()));
XMLNode &before = _session->tempo_map().get_state();
section->set_position_lock_style (meter_dialog.get_lock_style());
if (meter_dialog.get_lock_style() == MusicTime) {
- _session->tempo_map().replace_meter (*section, Meter (bpb, note_type), when);
+ _session->tempo_map().replace_meter_bbt (*section, Meter (bpb, note_type), when);
} else {
- _session->tempo_map().replace_meter (*section, Meter (bpb, note_type), frame);
+ _session->tempo_map().replace_meter_frame (*section, Meter (bpb, note_type), frame);
}
XMLNode &after = _session->tempo_map().get_state();
_session->add_command(new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
section->set_position_lock_style (MusicTime);
framepos_t const f = _session->tempo_map().predict_tempo_frame (section, when);
double const p = _session->tempo_map().predict_tempo_pulse (section, f);
- _session->tempo_map().replace_tempo (*section, Tempo (bpm, nt), p, tempo_dialog.get_tempo_type());
+ _session->tempo_map().replace_tempo_pulse (*section, Tempo (bpm, nt), p, tempo_dialog.get_tempo_type());
} else {
framepos_t const f = _session->tempo_map().predict_tempo_frame (section, when);
- _session->tempo_map().replace_tempo (*section, Tempo (bpm, nt), f, tempo_dialog.get_tempo_type());
+ _session->tempo_map().replace_tempo_frame (*section, Tempo (bpm, nt), f, tempo_dialog.get_tempo_type());
}
XMLNode &after = _session->tempo_map().get_state();
points->push_back (ArdourCanvas::Duple (ArdourCanvas::COORD_MAX - 5.0, y_pos));
} else {
- const framepos_t frame_step = (end_frame - frame) / 31;
+ const framepos_t frame_step = ((end_frame - 1) - frame) / 29;
framepos_t current_frame = frame;
- while (current_frame < end_frame) {
+ while (current_frame < (end_frame - frame_step)) {
const double tempo_at = _tempo.tempo_at_frame (current_frame, editor.session()->frame_rate()) * _tempo.note_type();
const double y_pos = (curve_height) - (((tempo_at - _min_tempo) / (tempo_delta)) * curve_height);
max_y = max (y_pos, max_y);
current_frame += frame_step;
}
- if (current_frame != end_frame) {
- const double tempo_at = _tempo.tempo_at_frame (end_frame, editor.session()->frame_rate()) * _tempo.note_type();
- const double y_pos = (curve_height) - (((tempo_at - _min_tempo) / (tempo_delta)) * curve_height);
+ const double tempo_at = _tempo.tempo_at_frame (end_frame, editor.session()->frame_rate()) * _tempo.note_type();
+ const double y_pos = (curve_height) - (((tempo_at - _min_tempo) / (tempo_delta)) * curve_height);
- points->push_back (ArdourCanvas::Duple (editor.sample_to_pixel (end_frame - frame), y_pos));
- }
+ points->push_back (ArdourCanvas::Duple (editor.sample_to_pixel ((end_frame - 1) - frame), y_pos));
}
_curve->set (*points);
/** A section of timeline with a certain Tempo or Meter. */
class LIBARDOUR_API MetricSection {
public:
- MetricSection (double pulse)
- : _pulse (pulse), _frame (0), _movable (true), _position_lock_style (MusicTime) {}
- MetricSection (framepos_t frame)
- : _pulse (0.0), _frame (frame), _movable (true), _position_lock_style (AudioTime) {}
+ MetricSection (double pulse, framepos_t frame, PositionLockStyle pls)
+ : _pulse (pulse), _frame (frame), _movable (true), _position_lock_style (pls) {}
virtual ~MetricSection() {}
/** A section of timeline with a certain Meter. */
class LIBARDOUR_API MeterSection : public MetricSection, public Meter {
public:
- MeterSection (double pulse, double beat, const Timecode::BBT_Time& bbt, double bpb, double note_type)
- : MetricSection (pulse), Meter (bpb, note_type), _bbt (bbt), _beat (beat) {}
- MeterSection (framepos_t frame, double beat, const Timecode::BBT_Time& bbt, double bpb, double note_type)
- : MetricSection (frame), Meter (bpb, note_type), _bbt (bbt), _beat (beat) {}
+ MeterSection (double pulse, framepos_t frame, double beat, const Timecode::BBT_Time& bbt, double bpb, double note_type, PositionLockStyle pls)
+ : MetricSection (pulse, frame, pls), Meter (bpb, note_type), _bbt (bbt), _beat (beat) {}
+
MeterSection (const XMLNode&);
static const std::string xml_state_node_name;
Constant,
};
- TempoSection (const double& pulse, double qpm, double note_type, Type tempo_type)
- : MetricSection (pulse), Tempo (qpm, note_type), _type (tempo_type), _c_func (0.0), _active (true), _locked_to_meter (false) {}
- TempoSection (framepos_t frame, double qpm, double note_type, Type tempo_type)
- : MetricSection (frame), Tempo (qpm, note_type), _type (tempo_type), _c_func (0.0), _active (true), _locked_to_meter (false) {}
+ TempoSection (const double& pulse, const framepos_t& frame, double qpm, double note_type, Type tempo_type, PositionLockStyle pls)
+ : MetricSection (pulse, frame, pls), Tempo (qpm, note_type), _type (tempo_type), _c_func (0.0), _active (true), _locked_to_meter (false) {}
+
TempoSection (const XMLNode&);
static const std::string xml_state_node_name;
const MeterSection& meter_section_at (framepos_t frame) const;
const MeterSection& meter_section_at_beat (double beat) const;
- TempoSection* add_tempo (const Tempo&, const double& pulse, TempoSection::Type type);
- TempoSection* add_tempo (const Tempo&, const framepos_t& frame, TempoSection::Type type);
+ /** add a music-locked tempo section at pulse
+ * @param pulse pulse position of new section
+ */
+ TempoSection* add_tempo_pulse (const Tempo&, const double& pulse, TempoSection::Type type);
+
+ /** add an audio-locked tempo section at frame
+ * @param frame frame position of new section
+ */
+ TempoSection* add_tempo_frame (const Tempo&, const framepos_t& frame, TempoSection::Type type);
+
+ /** add a music-locked meter section at beat
+ * @param beat beat position of new section
+ * @param where bbt position of new section
+ */
+ MeterSection* add_meter_beat (const Meter&, const double& beat, const Timecode::BBT_Time& where);
- MeterSection* add_meter (const Meter&, const double& beat, const Timecode::BBT_Time& where);
- MeterSection* add_meter (const Meter&, const framepos_t& frame, const double& beat, const Timecode::BBT_Time& where);
+ /** add an audio-locked meter section at frame
+ * @param frame frame position of new section
+ * @param beat beat position of new section
+ * @param where bbt position of new section
+ */
+ MeterSection* add_meter_frame (const Meter&, const framepos_t& frame, const double& beat, const Timecode::BBT_Time& where);
void remove_tempo (const TempoSection&, bool send_signal);
void remove_meter (const MeterSection&, bool send_signal);
framepos_t predict_tempo_frame (TempoSection* section, const Timecode::BBT_Time& bbt);
double predict_tempo_pulse (TempoSection* section, const framepos_t& frame);
- void replace_tempo (const TempoSection&, const Tempo&, const double& where, TempoSection::Type type);
- void replace_tempo (const TempoSection&, const Tempo&, const framepos_t& frame, TempoSection::Type type);
+ void replace_tempo_pulse (const TempoSection&, const Tempo&, const double& where, TempoSection::Type type);
+ void replace_tempo_frame (const TempoSection&, const Tempo&, const framepos_t& frame, TempoSection::Type type);
void gui_move_tempo_frame (TempoSection*, const framepos_t& frame);
void gui_move_tempo_beat (TempoSection*, const double& beat);
- void gui_move_meter (MeterSection*, const framepos_t& frame);
- void gui_move_meter (MeterSection*, const Timecode::BBT_Time& bbt);
+ void gui_move_meter_frame (MeterSection*, const framepos_t& frame);
+ void gui_move_meter_bbt (MeterSection*, const Timecode::BBT_Time& bbt);
bool gui_change_tempo (TempoSection*, const Tempo& bpm);
void gui_dilate_tempo (MeterSection*, const framepos_t& frame);
void gui_dilate_tempo (TempoSection* tempo, const framepos_t& frame, const framepos_t& end_frame, const double& pulse);
bool can_solve_bbt (TempoSection* section, const Timecode::BBT_Time& bbt);
- void replace_meter (const MeterSection&, const Meter&, const Timecode::BBT_Time& where);
- void replace_meter (const MeterSection&, const Meter&, const framepos_t& frame);
+ void replace_meter_bbt (const MeterSection&, const Meter&, const Timecode::BBT_Time& where);
+ void replace_meter_frame (const MeterSection&, const Meter&, const framepos_t& frame);
framepos_t round_to_bar (framepos_t frame, RoundMode dir);
framepos_t round_to_beat (framepos_t frame, RoundMode dir);
bool check_solved (const Metrics& metrics, bool by_frame) const;
bool set_active_tempos (const Metrics& metrics, const framepos_t& frame);
- bool solve_map (Metrics& metrics, TempoSection* section, const framepos_t& frame);
- bool solve_map (Metrics& metrics, TempoSection* section, const double& pulse);
- bool solve_map (Metrics& metrics, MeterSection* section, const framepos_t& frame);
- bool solve_map (Metrics& metrics, MeterSection* section, const Timecode::BBT_Time& bbt);
+ bool solve_map_frame (Metrics& metrics, TempoSection* section, const framepos_t& frame);
+ bool solve_map_pulse (Metrics& metrics, TempoSection* section, const double& pulse);
+ bool solve_map_frame (Metrics& metrics, MeterSection* section, const framepos_t& frame);
+ bool solve_map_bbt (Metrics& metrics, MeterSection* section, const Timecode::BBT_Time& bbt);
friend class ::BBTTest;
friend class ::FrameposPlusBeatsTest;
void do_insert (MetricSection* section);
- TempoSection* add_tempo_locked (const Tempo&, double pulse, bool recompute, TempoSection::Type type);
- TempoSection* add_tempo_locked (const Tempo&, framepos_t frame, bool recompute, TempoSection::Type type);
+ TempoSection* add_tempo_pulse_locked (const Tempo&, double pulse, bool recompute, TempoSection::Type type);
+ TempoSection* add_tempo_frame_locked (const Tempo&, framepos_t frame, bool recompute, TempoSection::Type type);
- MeterSection* add_meter_locked (const Meter&, double beat, const Timecode::BBT_Time& where, bool recompute);
- MeterSection* add_meter_locked (const Meter&, framepos_t frame, double beat, const Timecode::BBT_Time& where, bool recompute);
+ MeterSection* add_meter_beat_locked (const Meter&, double beat, const Timecode::BBT_Time& where, bool recompute);
+ MeterSection* add_meter_frame_locked (const Meter&, framepos_t frame, double beat, const Timecode::BBT_Time& where, bool recompute);
bool remove_tempo_locked (const TempoSection&);
bool remove_meter_locked (const MeterSection&);
.endClass ()
.beginClass <TempoMap> ("TempoMap")
- //.addFunction ("add_tempo", &TempoMap::add_tempo)
- //.addFunction ("add_meter", &TempoMap::add_meter)
+ .addFunction ("add_tempo_pulse", &TempoMap::add_tempo_pulse)
+ .addFunction ("add_tempo_frame", &TempoMap::add_tempo_frame)
+ .addFunction ("add_meter_beat", &TempoMap::add_meter_beat)
+ .addFunction ("add_meter_frame", &TempoMap::add_meter_frame)
.endClass ()
.beginClass <ChanCount> ("ChanCount")
const string TempoSection::xml_state_node_name = "Tempo";
TempoSection::TempoSection (const XMLNode& node)
- : MetricSection (0.0)
+ : MetricSection (0.0, 0, MusicTime)
, Tempo (TempoMap::default_tempo())
, _c_func (0.0)
, _active (true)
const string MeterSection::xml_state_node_name = "Meter";
MeterSection::MeterSection (const XMLNode& node)
- : MetricSection (0.0), Meter (TempoMap::default_meter())
+ : MetricSection (0.0, 0, MusicTime), Meter (TempoMap::default_meter())
{
XMLProperty const * prop;
LocaleGuard lg;
_frame_rate = fr;
BBT_Time start (1, 1, 0);
- TempoSection *t = new TempoSection ((framepos_t) 0, _default_tempo.beats_per_minute(), _default_tempo.note_type(), TempoSection::Constant);
- MeterSection *m = new MeterSection ((framepos_t) 0, 0.0, start, _default_meter.divisions_per_bar(), _default_meter.note_divisor());
+ TempoSection *t = new TempoSection (0.0, 0, _default_tempo.beats_per_minute(), _default_tempo.note_type(), TempoSection::Constant, AudioTime);
+ MeterSection *m = new MeterSection (0.0, 0, 0.0, start, _default_meter.divisions_per_bar(), _default_meter.note_divisor(), AudioTime);
t->set_movable (false);
m->set_movable (false);
}
void
-TempoMap::replace_tempo (const TempoSection& ts, const Tempo& tempo, const double& pulse, TempoSection::Type type)
+TempoMap::replace_tempo_pulse (const TempoSection& ts, const Tempo& tempo, const double& pulse, TempoSection::Type type)
{
{
Glib::Threads::RWLock::WriterLock lm (lock);
TempoSection& first (first_tempo());
if (ts.pulse() != first.pulse()) {
remove_tempo_locked (ts);
- add_tempo_locked (tempo, pulse, true, type);
+ add_tempo_pulse_locked (tempo, pulse, true, type);
} else {
first.set_type (type);
{
}
void
-TempoMap::replace_tempo (const TempoSection& ts, const Tempo& tempo, const framepos_t& frame, TempoSection::Type type)
+TempoMap::replace_tempo_frame (const TempoSection& ts, const Tempo& tempo, const framepos_t& frame, TempoSection::Type type)
{
{
Glib::Threads::RWLock::WriterLock lm (lock);
TempoSection& first (first_tempo());
if (ts.frame() != first.frame()) {
remove_tempo_locked (ts);
- add_tempo_locked (tempo, frame, true, type);
+ add_tempo_frame_locked (tempo, frame, true, type);
} else {
first.set_type (type);
first.set_pulse (0.0);
}
TempoSection*
-TempoMap::add_tempo (const Tempo& tempo, const double& pulse, ARDOUR::TempoSection::Type type)
+TempoMap::add_tempo_pulse (const Tempo& tempo, const double& pulse, ARDOUR::TempoSection::Type type)
{
TempoSection* ts = 0;
{
Glib::Threads::RWLock::WriterLock lm (lock);
- ts = add_tempo_locked (tempo, pulse, true, type);
+ ts = add_tempo_pulse_locked (tempo, pulse, true, type);
}
PropertyChanged (PropertyChange ());
}
TempoSection*
-TempoMap::add_tempo (const Tempo& tempo, const framepos_t& frame, ARDOUR::TempoSection::Type type)
+TempoMap::add_tempo_frame (const Tempo& tempo, const framepos_t& frame, ARDOUR::TempoSection::Type type)
{
TempoSection* ts = 0;
{
Glib::Threads::RWLock::WriterLock lm (lock);
- ts = add_tempo_locked (tempo, frame, true, type);
+ ts = add_tempo_frame_locked (tempo, frame, true, type);
}
}
TempoSection*
-TempoMap::add_tempo_locked (const Tempo& tempo, double pulse, bool recompute, ARDOUR::TempoSection::Type type)
+TempoMap::add_tempo_pulse_locked (const Tempo& tempo, double pulse, bool recompute, ARDOUR::TempoSection::Type type)
{
- TempoSection* t = new TempoSection (pulse, tempo.beats_per_minute(), tempo.note_type(), type);
+ TempoSection* t = new TempoSection (pulse, 0, tempo.beats_per_minute(), tempo.note_type(), type, MusicTime);
do_insert (t);
if (recompute) {
- solve_map (_metrics, t, t->pulse());
+ solve_map_pulse (_metrics, t, t->pulse());
recompute_meters (_metrics);
}
}
TempoSection*
-TempoMap::add_tempo_locked (const Tempo& tempo, framepos_t frame, bool recompute, ARDOUR::TempoSection::Type type)
+TempoMap::add_tempo_frame_locked (const Tempo& tempo, framepos_t frame, bool recompute, ARDOUR::TempoSection::Type type)
{
- TempoSection* t = new TempoSection (frame, tempo.beats_per_minute(), tempo.note_type(), type);
+ TempoSection* t = new TempoSection (0.0, frame, tempo.beats_per_minute(), tempo.note_type(), type, AudioTime);
do_insert (t);
if (recompute) {
- solve_map (_metrics, t, t->frame());
+ solve_map_frame (_metrics, t, t->frame());
recompute_meters (_metrics);
}
}
void
-TempoMap::replace_meter (const MeterSection& ms, const Meter& meter, const BBT_Time& where)
+TempoMap::replace_meter_bbt (const MeterSection& ms, const Meter& meter, const BBT_Time& where)
{
{
Glib::Threads::RWLock::WriterLock lm (lock);
if (ms.movable()) {
remove_meter_locked (ms);
- add_meter_locked (meter, bbt_to_beats_locked (_metrics, where), where, true);
+ add_meter_beat_locked (meter, bbt_to_beats_locked (_metrics, where), where, true);
} else {
MeterSection& first (first_meter());
/* cannot move the first meter section */
}
void
-TempoMap::replace_meter (const MeterSection& ms, const Meter& meter, const framepos_t& frame)
+TempoMap::replace_meter_frame (const MeterSection& ms, const Meter& meter, const framepos_t& frame)
{
{
Glib::Threads::RWLock::WriterLock lm (lock);
if (ms.movable()) {
remove_meter_locked (ms);
- add_meter_locked (meter, frame, beat, bbt, true);
+ add_meter_frame_locked (meter, frame, beat, bbt, true);
} else {
MeterSection& first (first_meter());
TempoSection& first_t (first_tempo());
MeterSection*
-TempoMap::add_meter (const Meter& meter, const double& beat, const BBT_Time& where)
+TempoMap::add_meter_beat (const Meter& meter, const double& beat, const BBT_Time& where)
{
MeterSection* m = 0;
{
Glib::Threads::RWLock::WriterLock lm (lock);
- m = add_meter_locked (meter, beat, where, true);
+ m = add_meter_beat_locked (meter, beat, where, true);
}
}
MeterSection*
-TempoMap::add_meter (const Meter& meter, const framepos_t& frame, const double& beat, const Timecode::BBT_Time& where)
+TempoMap::add_meter_frame (const Meter& meter, const framepos_t& frame, const double& beat, const Timecode::BBT_Time& where)
{
MeterSection* m = 0;
{
Glib::Threads::RWLock::WriterLock lm (lock);
- m = add_meter_locked (meter, frame, beat, where, true);
+ m = add_meter_frame_locked (meter, frame, beat, where, true);
}
}
MeterSection*
-TempoMap::add_meter_locked (const Meter& meter, double beat, const BBT_Time& where, bool recompute)
+TempoMap::add_meter_beat_locked (const Meter& meter, double beat, const BBT_Time& where, bool recompute)
{
/* a new meter always starts a new bar on the first beat. so
round the start time appropriately. remember that
*/
const double pulse = pulse_at_beat_locked (_metrics, beat);
- MeterSection* new_meter = new MeterSection (pulse, beat, where, meter.divisions_per_bar(), meter.note_divisor());
+ MeterSection* new_meter = new MeterSection (pulse, 0, beat, where, meter.divisions_per_bar(), meter.note_divisor(), MusicTime);
do_insert (new_meter);
if (recompute) {
- solve_map (_metrics, new_meter, where);
+ solve_map_bbt (_metrics, new_meter, where);
}
return new_meter;
}
MeterSection*
-TempoMap::add_meter_locked (const Meter& meter, framepos_t frame, double beat, const Timecode::BBT_Time& where, bool recompute)
+TempoMap::add_meter_frame_locked (const Meter& meter, framepos_t frame, double beat, const Timecode::BBT_Time& where, bool recompute)
{
/* add meter-locked tempo */
- TempoSection* t = add_tempo_locked (tempo_at_locked (_metrics, frame), frame, true, TempoSection::Ramp);
+ TempoSection* t = add_tempo_frame_locked (tempo_at_locked (_metrics, frame), frame, true, TempoSection::Ramp);
if (t) {
t->set_locked_to_meter (true);
}
- MeterSection* new_meter = new MeterSection (frame, beat, where, meter.divisions_per_bar(), meter.note_divisor());
+ MeterSection* new_meter = new MeterSection (0.0, frame, beat, where, meter.divisions_per_bar(), meter.note_divisor(), AudioTime);
new_meter->set_pulse (pulse_at_frame_locked (_metrics, frame));
do_insert (new_meter);
if (recompute) {
- solve_map (_metrics, new_meter, frame);
+ solve_map_frame (_metrics, new_meter, frame);
}
-
return new_meter;
}
}
bool
-TempoMap::solve_map (Metrics& imaginary, TempoSection* section, const framepos_t& frame)
+TempoMap::solve_map_frame (Metrics& imaginary, TempoSection* section, const framepos_t& frame)
{
TempoSection* prev_t = 0;
TempoSection* section_prev = 0;
}
bool
-TempoMap::solve_map (Metrics& imaginary, TempoSection* section, const double& pulse)
+TempoMap::solve_map_pulse (Metrics& imaginary, TempoSection* section, const double& pulse)
{
TempoSection* prev_t = 0;
TempoSection* section_prev = 0;
}
bool
-TempoMap::solve_map (Metrics& imaginary, MeterSection* section, const framepos_t& frame)
+TempoMap::solve_map_frame (Metrics& imaginary, MeterSection* section, const framepos_t& frame)
{
/* disallow moving first meter past any subsequent one, and any movable meter before the first one */
const MeterSection* other = &meter_section_at_locked (imaginary, frame);
const double new_pulse = ((section->beat() - prev_m->beat())
/ prev_m->note_divisor()) + prev_m->pulse();
const framepos_t smallest_frame = frame_at_pulse_locked (future_map, new_pulse);
- if ((solved = solve_map (future_map, tempo_copy, smallest_frame))) {
+ if ((solved = solve_map_frame (future_map, tempo_copy, smallest_frame))) {
meter_locked_tempo->set_pulse (new_pulse);
- solve_map (imaginary, meter_locked_tempo, smallest_frame);
+ solve_map_frame (imaginary, meter_locked_tempo, smallest_frame);
section->set_frame (smallest_frame);
section->set_pulse (new_pulse);
} else {
MeterSection* meter_copy = const_cast<MeterSection*> (&meter_section_at_locked (future_map, section->frame()));
meter_copy->set_frame (frame);
- if ((solved = solve_map (future_map, tempo_copy, frame))) {
+ if ((solved = solve_map_frame (future_map, tempo_copy, frame))) {
section->set_frame (frame);
meter_locked_tempo->set_pulse (((section->beat() - prev_m->beat())
/ prev_m->note_divisor()) + prev_m->pulse());
- solve_map (imaginary, meter_locked_tempo, frame);
+ solve_map_frame (imaginary, meter_locked_tempo, frame);
} else {
solved = false;
}
tempo_copy->set_frame (frame);
tempo_copy->set_pulse (0.0);
- if ((solved = solve_map (future_map, tempo_copy, frame))) {
+ if ((solved = solve_map_frame (future_map, tempo_copy, frame))) {
section->set_frame (frame);
meter_locked_tempo->set_frame (frame);
meter_locked_tempo->set_pulse (0.0);
- solve_map (imaginary, meter_locked_tempo, frame);
+ solve_map_frame (imaginary, meter_locked_tempo, frame);
} else {
solved = false;
}
}
bool
-TempoMap::solve_map (Metrics& imaginary, MeterSection* section, const BBT_Time& when)
+TempoMap::solve_map_bbt (Metrics& imaginary, MeterSection* section, const BBT_Time& when)
{
/* disallow setting section to an existing meter's bbt */
for (Metrics::iterator i = imaginary.begin(); i != imaginary.end(); ++i) {
}
const double beat = bbt_to_beats_locked (copy, bbt);
- const bool ret = solve_map (copy, tempo_copy, pulse_at_beat_locked (copy, beat));
+ const bool ret = solve_map_pulse (copy, tempo_copy, pulse_at_beat_locked (copy, beat));
Metrics::const_iterator d = copy.begin();
while (d != copy.end()) {
}
const double beat = bbt_to_beats_locked (future_map, bbt);
- if (solve_map (future_map, tempo_copy, pulse_at_beat_locked (future_map, beat))) {
+ if (solve_map_pulse (future_map, tempo_copy, pulse_at_beat_locked (future_map, beat))) {
ret = tempo_copy->frame();
} else {
ret = section->frame();
double ret = 0.0;
TempoSection* tempo_copy = copy_metrics_and_point (_metrics, future_map, section);
- if (solve_map (future_map, tempo_copy, frame)) {
+ if (solve_map_frame (future_map, tempo_copy, frame)) {
ret = tempo_copy->pulse();
} else {
ret = section->pulse();
{
Glib::Threads::RWLock::WriterLock lm (lock);
TempoSection* tempo_copy = copy_metrics_and_point (_metrics, future_map, ts);
- if (solve_map (future_map, tempo_copy, frame)) {
- solve_map (_metrics, ts, frame);
+ if (solve_map_frame (future_map, tempo_copy, frame)) {
+ solve_map_frame (_metrics, ts, frame);
recompute_meters (_metrics);
}
}
{
Glib::Threads::RWLock::WriterLock lm (lock);
TempoSection* tempo_copy = copy_metrics_and_point (_metrics, future_map, ts);
- if (solve_map (future_map, tempo_copy, pulse_at_beat_locked (future_map, beat))) {
- solve_map (_metrics, ts, pulse_at_beat_locked (_metrics, beat));
+ if (solve_map_pulse (future_map, tempo_copy, pulse_at_beat_locked (future_map, beat))) {
+ solve_map_pulse (_metrics, ts, pulse_at_beat_locked (_metrics, beat));
recompute_meters (_metrics);
}
}
}
void
-TempoMap::gui_move_meter (MeterSection* ms, const framepos_t& frame)
+TempoMap::gui_move_meter_frame (MeterSection* ms, const framepos_t& frame)
{
Metrics future_map;
{
Glib::Threads::RWLock::WriterLock lm (lock);
MeterSection* copy = copy_metrics_and_point (_metrics, future_map, ms);
- if (solve_map (future_map, copy, frame)) {
- solve_map (_metrics, ms, frame);
+ if (solve_map_frame (future_map, copy, frame)) {
+ solve_map_frame (_metrics, ms, frame);
recompute_tempos (_metrics);
}
}
}
void
-TempoMap::gui_move_meter (MeterSection* ms, const Timecode::BBT_Time& bbt)
+TempoMap::gui_move_meter_bbt (MeterSection* ms, const Timecode::BBT_Time& bbt)
{
Metrics future_map;
{
Glib::Threads::RWLock::WriterLock lm (lock);
MeterSection* copy = copy_metrics_and_point (_metrics, future_map, ms);
- if (solve_map (future_map, copy, bbt)) {
- solve_map (_metrics, ms, bbt);
+ if (solve_map_bbt (future_map, copy, bbt)) {
+ solve_map_bbt (_metrics, ms, bbt);
recompute_tempos (_metrics);
}
}
Tempo tempo(120);
Meter meter(4.0, 4.0);
- map.add_meter (meter, 0.0, BBT_Time(1, 1, 0));
+ map.add_meter_beat (meter, 0.0, BBT_Time(1, 1, 0));
/* add some good stuff here */
}
Tempo tempo (bpm);
Meter meter (4, 4);
- map.add_meter (meter, 0.0, BBT_Time (1, 1, 0));
- map.add_tempo (tempo, 0.0, TempoSection::Constant);
+ map.add_meter_beat (meter, 0.0, BBT_Time (1, 1, 0));
+ map.add_tempo_pulse (tempo, 0.0, TempoSection::Constant);
/* Subtract 1 beat from beat 3 of the first bar */
framepos_t r = map.framepos_minus_beats (frames_per_beat * 2, Beats(1));
TempoMap map (sampling_rate);
Meter meter (4, 4);
- map.add_meter (meter, 0.0, BBT_Time (1, 1, 0));
+ map.add_meter_beat (meter, 0.0, BBT_Time (1, 1, 0));
/*
120bpm at bar 1, 240bpm at bar 4
*/
Tempo tempoA (120);
- map.add_tempo (tempoA, 0.0, TempoSection::Constant);
+ map.add_tempo_pulse (tempoA, 0.0, TempoSection::Constant);
Tempo tempoB (240);
- map.add_tempo (tempoB, 12.0 / tempoA.note_type(), TempoSection::Constant);
+ map.add_tempo_pulse (tempoB, 12.0 / tempoA.note_type(), TempoSection::Constant);
/* Now some tests */
TempoMap map (sampling_rate);
Meter meterA (4, 4);
- map.add_meter (meterA, 0.0, BBT_Time (1, 1, 0));
+ map.add_meter_beat (meterA, 0.0, BBT_Time (1, 1, 0));
/*
120bpm at bar 1, 240bpm at bar 4
*/
Tempo tempoA (120);
- map.add_tempo (tempoA, 0.0, TempoSection::Constant);
+ map.add_tempo_pulse (tempoA, 0.0, TempoSection::Constant);
Tempo tempoB (240);
- map.add_tempo (tempoB, 12.0 / tempoA.note_type(), TempoSection::Constant);
+ map.add_tempo_pulse (tempoB, 12.0 / tempoA.note_type(), TempoSection::Constant);
Meter meterB (3, 4);
- map.add_meter (meterB, 12.0 / tempoA.note_type(), BBT_Time (4, 1, 0));
+ map.add_meter_beat (meterB, 12.0 / tempoA.note_type(), BBT_Time (4, 1, 0));
/* Now some tests */
Tempo tempo (bpm);
Meter meter (4, 4);
- map.add_meter (meter, 0.0, BBT_Time (1, 1, 0));
- map.add_tempo (tempo, 0.0, TempoSection::Constant);
+ map.add_meter_beat (meter, 0.0, BBT_Time (1, 1, 0));
+ map.add_tempo_pulse (tempo, 0.0, TempoSection::Constant);
/* Add 1 beat to beat 3 of the first bar */
framepos_t r = map.framepos_plus_beats (frames_per_beat * 2, Evoral::Beats(1));
TempoMap map (sampling_rate);
Meter meter (4, 4);
- map.add_meter (meter, 0.0, BBT_Time (1, 1, 0));
+ map.add_meter_beat (meter, 0.0, BBT_Time (1, 1, 0));
/*
120bpm at bar 1, 240bpm at bar 4
*/
Tempo tempoA (120);
- map.add_tempo (tempoA, 0.0, TempoSection::Constant);
+ map.add_tempo_pulse (tempoA, 0.0, TempoSection::Constant);
Tempo tempoB (240);
- map.add_tempo (tempoB, 12.0 / tempoA.note_type(), TempoSection::Constant);
+ map.add_tempo_pulse (tempoB, 12.0 / tempoA.note_type(), TempoSection::Constant);
/* Now some tests */
TempoMap map (sampling_rate);
Meter meterA (4, 4);
- map.add_meter (meterA, 0.0, BBT_Time (1, 1, 0));
+ map.add_meter_beat (meterA, 0.0, BBT_Time (1, 1, 0));
/*
120bpm at bar 1, 240bpm at bar 4
*/
Tempo tempoA (120);
- map.add_tempo (tempoA, 0.0, TempoSection::Constant);
+ map.add_tempo_pulse (tempoA, 0.0, TempoSection::Constant);
Tempo tempoB (240);
- map.add_tempo (tempoB, 12.0 / tempoA.note_type(), TempoSection::Constant);
+ map.add_tempo_pulse (tempoB, 12.0 / tempoA.note_type(), TempoSection::Constant);
Meter meterB (3, 4);
- map.add_meter (meterB, 12.0 / tempoA.note_type(), BBT_Time (4, 1, 0));
+ map.add_meter_beat (meterB, 12.0 / tempoA.note_type(), BBT_Time (4, 1, 0));
/* Now some tests */
Tempo tempo (bpm);
Meter meter (4, 4);
- map.add_meter (meter, 0.0, BBT_Time (1, 1, 0));
- map.add_tempo (tempo, 0.0, TempoSection::Constant);
+ map.add_meter_beat (meter, 0.0, BBT_Time (1, 1, 0));
+ map.add_tempo_pulse (tempo, 0.0, TempoSection::Constant);
/* Walk 1 beats-worth of frames from beat 3 */
double r = map.framewalk_to_beats (frames_per_beat * 2, frames_per_beat * 1).to_double();
TempoMap map (sampling_rate);
Meter meter (4, 4);
- map.add_meter (meter, 0.0, BBT_Time (1, 1, 0));
+ map.add_meter_beat (meter, 0.0, BBT_Time (1, 1, 0));
/*
120bpm at bar 1, 240bpm at bar 4
*/
Tempo tempoA (120);
- map.add_tempo (tempoA, 0.0, TempoSection::Constant);
+ map.add_tempo_pulse (tempoA, 0.0, TempoSection::Constant);
Tempo tempoB (240);
- map.add_tempo (tempoB, 12.0 / tempoB.note_type(), TempoSection::Constant);
+ map.add_tempo_pulse (tempoB, 12.0 / tempoB.note_type(), TempoSection::Constant);
/* Now some tests */
TempoMap map (sampling_rate);
Meter meter (4, 4);
- map.add_meter (meter, 0.0, BBT_Time (1, 1, 0));
+ map.add_meter_beat (meter, 0.0, BBT_Time (1, 1, 0));
/*
120bpm at bar 1, 240bpm at bar 2, 160bpm at bar 3
*/
Tempo tempoA (120);
- map.add_tempo (tempoA, 0.0, TempoSection::Constant);
+ map.add_tempo_pulse (tempoA, 0.0, TempoSection::Constant);
Tempo tempoB (240);
- map.add_tempo (tempoB, 4.0 / tempoB.note_type(), TempoSection::Constant);
+ map.add_tempo_pulse (tempoB, 4.0 / tempoB.note_type(), TempoSection::Constant);
Tempo tempoC (160);
- map.add_tempo (tempoC, 8.0 / tempoB.note_type(), TempoSection::Constant);
+ map.add_tempo_pulse (tempoC, 8.0 / tempoB.note_type(), TempoSection::Constant);
/* Walk from 1|3 to 4|1 */
double r = map.framewalk_to_beats (2 * 24e3, (2 * 24e3) + (4 * 12e3) + (4 * 18e3)).to_double();
meter (4.0, 4.0)
{
_tempo_map = new TempoMap (FRAME_RATE);
- _tempo_map->add_tempo (tempo, 0.0, TempoSection::Type::Constant);
- _tempo_map->add_meter (meter, 0.0, Timecode::BBT_Time(1, 1, 0));
+ _tempo_map->add_tempo_pulse (tempo, 0.0, TempoSection::Type::Constant);
+ _tempo_map->add_meter_beat (meter, 0.0, Timecode::BBT_Time(1, 1, 0));
}
// Controlling the mock object
TempoMap map (sampling_rate);
Meter meterA (4, 4);
- map.add_meter (meterA, 0.0, BBT_Time (1, 1, 0));
+ map.add_meter_beat (meterA, 0.0, BBT_Time (1, 1, 0));
/*
120bpm at bar 1, 240bpm at bar 4
*/
Tempo tempoA (120);
- map.add_tempo (tempoA, 0.0, TempoSection::Constant);
+ map.add_tempo_pulse (tempoA, 0.0, TempoSection::Constant);
Tempo tempoB (240);
- map.add_tempo (tempoB, 12.0, TempoSection::Constant);
+ map.add_tempo_pulse (tempoB, 4.0, TempoSection::Constant);
Meter meterB (3, 4);
- map.add_meter (meterB, 12.0, BBT_Time (4, 1, 0));
+ map.add_meter_beat (meterB, 12.0, BBT_Time (4, 1, 0));
list<MetricSection*>::iterator i = map._metrics.begin();
CPPUNIT_ASSERT_EQUAL (framepos_t (0), (*i)->frame ());
Meter meterA (4, 4);
Tempo tempoA (77.0, 4.0);
Tempo tempoB (217.0, 4.0);
- map.add_tempo (tempoA, (framepos_t) 0, TempoSection::Ramp);
- map.add_tempo (tempoB, (framepos_t) 60 * sampling_rate, TempoSection::Ramp);
- map.add_meter (meterA, 0.0, BBT_Time (1, 1, 0));
+ map.add_tempo_frame (tempoA, (framepos_t) 0, TempoSection::Ramp);
+ map.add_tempo_frame (tempoB, (framepos_t) 60 * sampling_rate, TempoSection::Ramp);
+ map.add_meter_beat (meterA, 0.0, BBT_Time (1, 1, 0));
/*