/* XX replace old beats-per-minute name with note-types-per-minute */
if ((prop = node.property ("beats-per-minute")) != 0) {
if (sscanf (prop->value().c_str(), "%lf", &_note_types_per_minute) != 1 || _note_types_per_minute < 0.0) {
- error << _("TempoSection XML node has an illegal \"beats-per-minutee\" value") << endmsg;
+ error << _("TempoSection XML node has an illegal \"beats-per-minute\" value") << endmsg;
throw failed_constructor();
}
}
prev_t = t;
}
}
+ assert (prev_t);
prev_t->set_c_func (0.0);
}
prev_m = m;
}
}
+ assert (prev_m);
TempoSection* t;
}
}
+ assert (prev_t);
return prev_t->minute_at_pulse (((beat - prev_m->beat()) / prev_m->note_divisor()) + prev_m->pulse());
}
prev_m = m;
}
}
+ assert (prev_m);
double const ret = ((pulse - prev_m->pulse()) * prev_m->note_divisor()) + prev_m->beat();
return ret;
prev_m = m;
}
}
+ assert (prev_m);
const double beats_in_ms = beats - prev_m->beat();
const uint32_t bars_in_ms = (uint32_t) floor (beats_in_ms / prev_m->divisions_per_bar());
}
}
+ assert (prev_m);
+
const double beats_in_ms = (pulse - prev_m->pulse()) * prev_m->note_divisor();
const uint32_t bars_in_ms = (uint32_t) floor (beats_in_ms / prev_m->divisions_per_bar());
const uint32_t total_bars = bars_in_ms + (prev_m->bbt().bars - 1);
*
*/
double
-TempoMap::quarter_note_at_beat (const double beat)
+TempoMap::quarter_note_at_beat (const double beat) const
{
Glib::Threads::RWLock::ReaderLock lm (lock);
*
*/
double
-TempoMap::beat_at_quarter_note (const double quarter_note)
+TempoMap::beat_at_quarter_note (const double quarter_note) const
{
Glib::Threads::RWLock::ReaderLock lm (lock);
prev_t = t;
}
}
+ assert (prev_t);
const double start_qn = prev_t->pulse_at_frame (start);
for (Metrics::const_iterator i = metrics.begin(); i != metrics.end(); ++i) {
TempoSection* prev_to_prev_t = 0;
const frameoffset_t fr_off = end_frame - frame;
- if (prev_t && prev_t->pulse() > 0.0) {
+ assert (prev_t);
+
+ if (prev_t->pulse() > 0.0) {
prev_to_prev_t = const_cast<TempoSection*>(&tempo_section_at_minute_locked (future_map, minute_at_frame (prev_t->frame() - 1)));
}
* This function is sensitive to tempo and meter.
*/
double
-TempoMap::exact_beat_at_frame (const framepos_t& frame, const int32_t sub_num)
+TempoMap::exact_beat_at_frame (const framepos_t& frame, const int32_t sub_num) const
{
Glib::Threads::RWLock::ReaderLock lm (lock);
}
double
-TempoMap::exact_beat_at_frame_locked (const Metrics& metrics, const framepos_t& frame, const int32_t divisions)
+TempoMap::exact_beat_at_frame_locked (const Metrics& metrics, const framepos_t& frame, const int32_t divisions) const
{
return beat_at_pulse_locked (_metrics, exact_qn_at_frame_locked (metrics, frame, divisions) / 4.0);
}
* This function is tempo-sensitive.
*/
double
-TempoMap::exact_qn_at_frame (const framepos_t& frame, const int32_t sub_num)
+TempoMap::exact_qn_at_frame (const framepos_t& frame, const int32_t sub_num) const
{
Glib::Threads::RWLock::ReaderLock lm (lock);
}
double
-TempoMap::exact_qn_at_frame_locked (const Metrics& metrics, const framepos_t& frame, const int32_t sub_num)
+TempoMap::exact_qn_at_frame_locked (const Metrics& metrics, const framepos_t& frame, const int32_t sub_num) const
{
double qn = quarter_note_at_minute_locked (metrics, minute_at_frame (frame));
Glib::Threads::RWLock::ReaderLock lm (lock);
BBT_Time pos_bbt = bbt_at_minute_locked (_metrics, minute_at_frame (pos));
- const framecnt_t offset = frame_at_minute (minute_at_bbt_locked (_metrics, pos_bbt));
+
const double divisions = meter_section_at_minute_locked (_metrics, minute_at_frame (pos)).divisions_per_bar();
if (dir > 0) {
pos_bbt.bars += 1;
pos_bbt.beats -= divisions;
}
+ const framecnt_t pos_bbt_frame = frame_at_minute (minute_at_bbt_locked (_metrics, pos_bbt));
+
+ return pos_bbt_frame - pos;
- return frame_at_minute (minute_at_bbt_locked (_metrics, pos_bbt)) - offset;
} else {
- pos_bbt.bars -= bbt.bars;
+
+ if (pos_bbt.bars <= bbt.bars) {
+ pos_bbt.bars = 1;
+ } else {
+ pos_bbt.bars -= bbt.bars;
+ }
if (pos_bbt.ticks < bbt.ticks) {
- if (pos_bbt.beats == 1) {
- pos_bbt.bars--;
- pos_bbt.beats = divisions;
+ if (pos_bbt.bars > 1) {
+ if (pos_bbt.beats == 1) {
+ pos_bbt.bars--;
+ pos_bbt.beats = divisions;
+ } else {
+ pos_bbt.beats--;
+ }
+ pos_bbt.ticks = BBT_Time::ticks_per_beat - (bbt.ticks - pos_bbt.ticks);
} else {
- pos_bbt.beats--;
+ pos_bbt.beats = 1;
+ pos_bbt.ticks = 0;
}
- pos_bbt.ticks = BBT_Time::ticks_per_beat - (bbt.ticks - pos_bbt.ticks);
} else {
pos_bbt.ticks -= bbt.ticks;
}
if (pos_bbt.beats <= bbt.beats) {
- pos_bbt.bars--;
- pos_bbt.beats = divisions - (bbt.beats - pos_bbt.beats);
+ if (pos_bbt.bars > 1) {
+ pos_bbt.bars--;
+ pos_bbt.beats = divisions - (bbt.beats - pos_bbt.beats);
+ } else {
+ pos_bbt.beats = 1;
+ }
} else {
pos_bbt.beats -= bbt.beats;
}
- return offset - frame_at_minute (minute_at_bbt_locked (_metrics, pos_bbt));
+ return pos - frame_at_minute (minute_at_bbt_locked (_metrics, pos_bbt));
}
return 0;
ts_at = t;
}
}
+ assert (ts_at);
if (ts_after) {
return (60.0 * _frame_rate) / ts_at->tempo_at_minute (minute_at_frame (frame)).quarter_notes_per_minute();