beats_per_bar = metric.meter().beats_per_bar();
}
-
+
/* We now counted the beats and landed in the target measure, now deal
with ticks this seems complicated, but we want to deal with the
corner case of a sequence of time signatures like 0.2/4-0.7/4 and
difference = mod;
}
- try {
+ try {
the_beat = bbt_subtract (the_beat, BBT_Time (0, 0, difference));
} catch (...) {
/* can't go backwards from wherever pos is, so just return it */
midbar_beats = metric.meter().beats_per_bar() / 2 + 1;
midbar_ticks = BBT_Time::ticks_per_beat * fmod (midbar_beats, 1.0f);
midbar_beats = floor (midbar_beats);
-
+
BBT_Time midbar (bbt.bars, lrintf (midbar_beats), lrintf (midbar_ticks));
if (bbt < midbar) {
/* find beat position preceding frame */
try {
- bbt = bbt_subtract (bbt, one_beat);
+ bbt = bbt_subtract (bbt, one_beat);
}
catch (...) {
TempoMap::insert_time (framepos_t where, framecnt_t amount)
{
for (Metrics::iterator i = metrics->begin(); i != metrics->end(); ++i) {
- if ((*i)->frame() >= where) {
+ if ((*i)->frame() >= where && (*i)->movable ()) {
(*i)->set_frame ((*i)->frame() + amount);
}
}
/* now comes the complicated part. we have to add one beat a time,
checking for a new metric on every beat.
*/
-
+
/* grab all meter sections */
-
+
list<const MeterSection*> meter_sections;
-
+
for (Metrics::const_iterator x = metrics->begin(); x != metrics->end(); ++x) {
const MeterSection* ms;
if ((ms = dynamic_cast<const MeterSection*>(*x)) != 0) {
meter_sections.push_back (ms);
}
}
-
+
assert (!meter_sections.empty());
-
+
list<const MeterSection*>::const_iterator next_meter;
const Meter* meter = 0;
-
+
/* go forwards through the meter sections till we get to the one
- covering the current value of result. this positions i to point to
+ covering the current value of result. this positions i to point to
the next meter section too, or the end.
*/
-
+
for (next_meter = meter_sections.begin(); next_meter != meter_sections.end(); ++next_meter) {
-
+
if (result < (*next_meter)->start()) {
/* this metric is past the result time. stop looking, we have what we need */
break;
++next_meter;
break;
}
-
+
meter = *next_meter;
}
-
+
assert (meter != 0);
-
- /* OK, now have the meter for the bar start we are on, and i is an iterator
- that points to the metric after the one we are currently dealing with
- (or to metrics->end(), of course)
+
+ /* OK, now have the meter for the bar start we are on, and i is an iterator
+ that points to the metric after the one we are currently dealing with
+ (or to metrics->end(), of course)
*/
-
+
while (op.beats) {
-
+
/* given the current meter, have we gone past the end of the bar ? */
-
+
if (result.beats >= meter->beats_per_bar()) {
/* move to next bar, first beat */
result.bars++;
} else {
result.beats++;
}
-
+
/* one down ... */
-
+
op.beats--;
-
- /* check if we need to use a new meter section: has adding beats to result taken us
+
+ /* check if we need to use a new meter section: has adding beats to result taken us
to or after the start of the next meter section? in which case, use it.
*/
/* now comes the complicated part. we have to subtract one beat a time,
checking for a new metric on every beat.
*/
-
+
/* grab all meter sections */
-
+
list<const MeterSection*> meter_sections;
-
+
for (Metrics::const_iterator x = metrics->begin(); x != metrics->end(); ++x) {
const MeterSection* ms;
if ((ms = dynamic_cast<const MeterSection*>(*x)) != 0) {
meter_sections.push_back (ms);
}
}
-
+
assert (!meter_sections.empty());
-
+
/* go backwards through the meter sections till we get to the one
- covering the current value of result. this positions i to point to
+ covering the current value of result. this positions i to point to
the next (previous) meter section too, or the end.
*/
-
+
const MeterSection* meter = 0;
- list<const MeterSection*>::reverse_iterator next_meter; // older versions of GCC don't
+ list<const MeterSection*>::reverse_iterator next_meter; // older versions of GCC don't
// support const_reverse_iterator::operator!=()
-
+
for (next_meter = meter_sections.rbegin(); next_meter != meter_sections.rend(); ++next_meter) {
-
+
/* when we find the first meter section that is before or at result, use it,
- and set next_meter to the previous one
+ and set next_meter to the previous one
*/
-
+
if ((*next_meter)->start() < result || (*next_meter)->start() == result) {
meter = *next_meter;
++next_meter;
}
assert (meter != 0);
-
- /* OK, now have the meter for the bar start we are on, and i is an iterator
- that points to the metric after the one we are currently dealing with
- (or to metrics->end(), of course)
+
+ /* OK, now have the meter for the bar start we are on, and i is an iterator
+ that points to the metric after the one we are currently dealing with
+ (or to metrics->end(), of course)
*/
-
+
while (op.beats) {
/* have we reached the start of the bar? if so, move to the last beat of the previous
bar. opwise, just step back 1 beat.
*/
-
+
if (result.beats == 1) {
-
+
/* move to previous bar, last beat */
-
+
if (result.bars <= 1) {
/* i'm sorry dave, i can't do that */
throw std::out_of_range ("illegal BBT subtraction");
}
-
+
result.bars--;
result.beats = meter->beats_per_bar();
} else {
result.beats--;
}
-
+
/* one down ... */
op.beats--;
-
- /* check if we need to use a new meter section: has subtracting beats to result taken us
+
+ /* check if we need to use a new meter section: has subtracting beats to result taken us
to before the start of the current meter section? in which case, use the prior one.
*/
frames_per_beat is rounded. Other errors can be introduced
by op.ticks' integer nature.
*/
-
+
Metrics::const_iterator i;
const MeterSection* meter;
const MeterSection* m;
/* now comes the complicated part. we have to add one beat a time,
checking for a new metric on every beat.
*/
-
+
frames_per_beat = tempo->frames_per_beat (_frame_rate, *meter);
while (op.bars) {
pos += llrint (frames_per_beat * meter->beats_per_bar());
op.bars--;
-
+
/* check if we need to use a new metric section: has adding frames moved us
to or after the start of the next metric section? in which case, use it.
*/
}
while (op.beats) {
-
+
/* given the current meter, have we gone past the end of the bar ? */
pos += frames_per_beat;
op.beats--;
-
+
/* check if we need to use a new metric section: has adding frames moved us
to or after the start of the next metric section? in which case, use it.
*/
meter = m;
}
++i;
- frames_per_beat = tempo->frames_per_beat (_frame_rate, *meter);
+ frames_per_beat = tempo->frames_per_beat (_frame_rate, *meter);
}
}
}
/* now comes the complicated part. we have to add one beat a time,
checking for a new metric on every beat.
*/
-
+
frames_per_beat = tempo->frames_per_beat (_frame_rate, *meter);
while (ddist > 0) {
/** Compare the time of this with that of another MetricSection.
- * @param with_bbt True to compare using ::start(), false to use ::frame().
+ * @param with_bbt True to compare using start(), false to use frame().
* @return -1 for less than, 0 for equal, 1 for greater than.
*/