Tempo ramps - use correct meter when snapping to the future.
This commit is contained in:
parent
daa07ce6e0
commit
a2797f4d38
|
@ -2158,7 +2158,10 @@ Editor::snap_musical() const
|
||||||
case SnapToBeatDiv3:
|
case SnapToBeatDiv3:
|
||||||
case SnapToBeatDiv2:
|
case SnapToBeatDiv2:
|
||||||
return true;
|
return true;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -373,6 +373,7 @@ class LIBARDOUR_API TempoMap : public PBD::StatefulDestructible
|
||||||
|
|
||||||
const TempoSection& tempo_section_at (framepos_t frame) const;
|
const TempoSection& tempo_section_at (framepos_t frame) const;
|
||||||
const MeterSection& meter_section_at (framepos_t frame) const;
|
const MeterSection& meter_section_at (framepos_t frame) const;
|
||||||
|
const MeterSection& meter_section_at (const double& beat) const;
|
||||||
|
|
||||||
void add_tempo (const Tempo&, const double& pulse, TempoSection::Type type);
|
void add_tempo (const Tempo&, const double& pulse, TempoSection::Type type);
|
||||||
void add_tempo (const Tempo&, const framepos_t& frame, TempoSection::Type type);
|
void add_tempo (const Tempo&, const framepos_t& frame, TempoSection::Type type);
|
||||||
|
|
|
@ -2483,7 +2483,7 @@ void
|
||||||
TempoMap::round_bbt (BBT_Time& when, const int32_t& sub_num)
|
TempoMap::round_bbt (BBT_Time& when, const int32_t& sub_num)
|
||||||
{
|
{
|
||||||
if (sub_num == -1) {
|
if (sub_num == -1) {
|
||||||
const double bpb = meter_at (bbt_to_beats_locked (_metrics, when)).note_divisor();
|
const double bpb = meter_section_at (bbt_to_beats_locked (_metrics, when)).divisions_per_bar();
|
||||||
if ((double) when.beats > bpb / 2.0) {
|
if ((double) when.beats > bpb / 2.0) {
|
||||||
++when.bars;
|
++when.bars;
|
||||||
}
|
}
|
||||||
|
@ -2491,8 +2491,13 @@ TempoMap::round_bbt (BBT_Time& when, const int32_t& sub_num)
|
||||||
when.ticks = 0;
|
when.ticks = 0;
|
||||||
return;
|
return;
|
||||||
} else if (sub_num == 0) {
|
} else if (sub_num == 0) {
|
||||||
|
const double bpb = meter_section_at (bbt_to_beats_locked (_metrics, when)).divisions_per_bar();
|
||||||
if (when.ticks > BBT_Time::ticks_per_beat / 2) {
|
if (when.ticks > BBT_Time::ticks_per_beat / 2) {
|
||||||
++when.beats;
|
++when.beats;
|
||||||
|
while ((double) when.beats > bpb) {
|
||||||
|
++when.bars;
|
||||||
|
when.beats -= (uint32_t) floor (bpb);
|
||||||
|
}
|
||||||
when.ticks = 0;
|
when.ticks = 0;
|
||||||
} else {
|
} else {
|
||||||
when.ticks = 0;
|
when.ticks = 0;
|
||||||
|
@ -2751,6 +2756,25 @@ TempoMap::meter_at (framepos_t frame) const
|
||||||
return m.meter();
|
return m.meter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const MeterSection&
|
||||||
|
TempoMap::meter_section_at (const double& beat) const
|
||||||
|
{
|
||||||
|
MeterSection* prev_ms = 0;
|
||||||
|
Glib::Threads::RWLock::ReaderLock lm (lock);
|
||||||
|
|
||||||
|
for (Metrics::const_iterator i = _metrics.begin(); i != _metrics.end(); ++i) {
|
||||||
|
MeterSection* m;
|
||||||
|
if ((m = dynamic_cast<MeterSection*> (*i)) != 0) {
|
||||||
|
if (prev_ms && m->beat() > beat) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
prev_ms = m;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return *prev_ms;
|
||||||
|
}
|
||||||
|
|
||||||
XMLNode&
|
XMLNode&
|
||||||
TempoMap::get_state ()
|
TempoMap::get_state ()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user