mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-19 21:26:26 +01:00
Tempo ramps - snap uses audio-locked meter offsets.
- fixes much of the fallout from the previous commit.
This commit is contained in:
parent
ec791c8dd4
commit
8fce08610a
2 changed files with 25 additions and 24 deletions
|
|
@ -432,7 +432,7 @@ class LIBARDOUR_API TempoMap : public PBD::StatefulDestructible
|
||||||
private:
|
private:
|
||||||
double bbt_to_beats_locked (const Metrics& metrics, Timecode::BBT_Time bbt);
|
double bbt_to_beats_locked (const Metrics& metrics, Timecode::BBT_Time bbt);
|
||||||
Timecode::BBT_Time beats_to_bbt_locked (Metrics& metrics, double beats);
|
Timecode::BBT_Time beats_to_bbt_locked (Metrics& metrics, double beats);
|
||||||
double beat_at_frame_locked (Metrics& metrics, framecnt_t frame) const;
|
double beat_at_frame_locked (const Metrics& metrics, framecnt_t frame) const;
|
||||||
framecnt_t frame_at_beat_locked (const Metrics& metrics, double beat) const;
|
framecnt_t frame_at_beat_locked (const Metrics& metrics, double beat) const;
|
||||||
double tick_at_frame_locked (const Metrics& metrics, framecnt_t frame) const;
|
double tick_at_frame_locked (const Metrics& metrics, framecnt_t frame) const;
|
||||||
double tick_offset_at (const Metrics& metrics, double tick) const;
|
double tick_offset_at (const Metrics& metrics, double tick) const;
|
||||||
|
|
|
||||||
|
|
@ -1517,10 +1517,8 @@ double
|
||||||
TempoMap::bbt_to_beats (Timecode::BBT_Time bbt)
|
TempoMap::bbt_to_beats (Timecode::BBT_Time bbt)
|
||||||
{
|
{
|
||||||
Glib::Threads::RWLock::ReaderLock lm (lock);
|
Glib::Threads::RWLock::ReaderLock lm (lock);
|
||||||
double const ticks = bbt_to_beats_locked (_metrics, bbt) * BBT_Time::ticks_per_beat;
|
|
||||||
double const tick_off = tick_offset_at (_metrics, ticks);
|
|
||||||
|
|
||||||
return (ticks + tick_off) / BBT_Time::ticks_per_beat;
|
return bbt_to_beats_locked (_metrics, bbt);
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
|
|
@ -1561,9 +1559,8 @@ Timecode::BBT_Time
|
||||||
TempoMap::beats_to_bbt (double beats)
|
TempoMap::beats_to_bbt (double beats)
|
||||||
{
|
{
|
||||||
Glib::Threads::RWLock::ReaderLock lm (lock);
|
Glib::Threads::RWLock::ReaderLock lm (lock);
|
||||||
double const ticks = beats * BBT_Time::ticks_per_beat;
|
|
||||||
double const tick_off = tick_offset_at (_metrics, ticks);
|
return beats_to_bbt_locked (_metrics, beats);
|
||||||
return beats_to_bbt_locked (_metrics, (ticks + tick_off) / BBT_Time::ticks_per_beat);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Timecode::BBT_Time
|
Timecode::BBT_Time
|
||||||
|
|
@ -1732,13 +1729,14 @@ double
|
||||||
TempoMap::beat_at_frame (framecnt_t frame) const
|
TempoMap::beat_at_frame (framecnt_t frame) const
|
||||||
{
|
{
|
||||||
Glib::Threads::RWLock::ReaderLock lm (lock);
|
Glib::Threads::RWLock::ReaderLock lm (lock);
|
||||||
double const tick = tick_at_frame_locked (_metrics, frame);
|
framecnt_t const offset_frame = frame + frame_offset_at (_metrics, frame);
|
||||||
framecnt_t const tick_off = tick_offset_at (_metrics, tick);
|
double const tick = tick_at_frame_locked (_metrics, offset_frame);
|
||||||
return (tick + tick_off) / BBT_Time::ticks_per_beat;
|
|
||||||
|
return tick / BBT_Time::ticks_per_beat;
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
TempoMap::beat_at_frame_locked (Metrics& metrics, framecnt_t frame) const
|
TempoMap::beat_at_frame_locked (const Metrics& metrics, framecnt_t frame) const
|
||||||
{
|
{
|
||||||
return tick_at_frame_locked (metrics, frame) / BBT_Time::ticks_per_beat;
|
return tick_at_frame_locked (metrics, frame) / BBT_Time::ticks_per_beat;
|
||||||
}
|
}
|
||||||
|
|
@ -1747,7 +1745,7 @@ framecnt_t
|
||||||
TempoMap::frame_at_beat (double beat) const
|
TempoMap::frame_at_beat (double beat) const
|
||||||
{
|
{
|
||||||
Glib::Threads::RWLock::ReaderLock lm (lock);
|
Glib::Threads::RWLock::ReaderLock lm (lock);
|
||||||
framecnt_t const frame = frame_at_tick_locked (_metrics, beat * BBT_Time::ticks_per_beat);
|
framecnt_t const frame = frame_at_beat_locked (_metrics, beat);
|
||||||
framecnt_t const frame_off = frame_offset_at (_metrics, frame);
|
framecnt_t const frame_off = frame_offset_at (_metrics, frame);
|
||||||
return frame - frame_off;
|
return frame - frame_off;
|
||||||
}
|
}
|
||||||
|
|
@ -2074,13 +2072,14 @@ TempoMap::bbt_duration_at (framepos_t pos, const BBT_Time& bbt, int dir)
|
||||||
Metrics::const_iterator i;
|
Metrics::const_iterator i;
|
||||||
TempoSection* first = 0;
|
TempoSection* first = 0;
|
||||||
TempoSection* second = 0;
|
TempoSection* second = 0;
|
||||||
|
framepos_t const offset_pos = pos + frame_offset_at (_metrics, pos);
|
||||||
|
|
||||||
for (i = _metrics.begin(); i != _metrics.end(); ++i) {
|
for (i = _metrics.begin(); i != _metrics.end(); ++i) {
|
||||||
TempoSection* t;
|
TempoSection* t;
|
||||||
|
|
||||||
if ((t = dynamic_cast<TempoSection*> (*i)) != 0) {
|
if ((t = dynamic_cast<TempoSection*> (*i)) != 0) {
|
||||||
|
|
||||||
if ((*i)->frame() > pos) {
|
if ((*i)->frame() > offset_pos) {
|
||||||
second = t;
|
second = t;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -2089,15 +2088,15 @@ TempoMap::bbt_duration_at (framepos_t pos, const BBT_Time& bbt, int dir)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (first && second) {
|
if (first && second) {
|
||||||
double const tick_at_time = first->tick_at_frame (pos, _frame_rate);
|
double const tick_at_time = first->tick_at_frame (offset_pos, _frame_rate);
|
||||||
double const bbt_ticks = bbt.ticks + (bbt.beats * BBT_Time::ticks_per_beat);
|
double const bbt_ticks = bbt.ticks + (bbt.beats * BBT_Time::ticks_per_beat);
|
||||||
double const time_at_bbt = first->frame_at_tick (tick_at_time + bbt_ticks, _frame_rate);
|
framecnt_t const time_at_bbt = first->frame_at_tick (tick_at_time + bbt_ticks, _frame_rate);
|
||||||
|
framecnt_t const ret = time_at_bbt - offset_pos;
|
||||||
return time_at_bbt - pos;
|
return ret - frame_offset_at (_metrics, pos);
|
||||||
}
|
}
|
||||||
double const ticks = bbt.ticks + (bbt.beats * BBT_Time::ticks_per_beat);
|
double const ticks = bbt.ticks + (bbt.beats * BBT_Time::ticks_per_beat);
|
||||||
|
framecnt_t const ret = (framecnt_t) floor ((ticks / BBT_Time::ticks_per_beat) * first->frames_per_beat(_frame_rate));
|
||||||
return (framecnt_t) floor ((ticks / BBT_Time::ticks_per_beat) * first->frames_per_beat(_frame_rate));
|
return ret - frame_offset_at (_metrics, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
framepos_t
|
framepos_t
|
||||||
|
|
@ -2117,7 +2116,7 @@ TempoMap::round_to_beat_subdivision (framepos_t fr, int sub_num, RoundMode dir)
|
||||||
{
|
{
|
||||||
Glib::Threads::RWLock::ReaderLock lm (lock);
|
Glib::Threads::RWLock::ReaderLock lm (lock);
|
||||||
|
|
||||||
uint32_t ticks = (uint32_t) floor (tick_at_frame_locked (_metrics, fr) + 0.5);
|
uint32_t ticks = (uint32_t) floor (tick_at_frame_locked (_metrics, fr + frame_offset_at (_metrics, fr)) + 0.5);
|
||||||
uint32_t beats = (uint32_t) floor (ticks / BBT_Time::ticks_per_beat);
|
uint32_t beats = (uint32_t) floor (ticks / BBT_Time::ticks_per_beat);
|
||||||
uint32_t ticks_one_subdivisions_worth = (uint32_t)BBT_Time::ticks_per_beat / sub_num;
|
uint32_t ticks_one_subdivisions_worth = (uint32_t)BBT_Time::ticks_per_beat / sub_num;
|
||||||
|
|
||||||
|
|
@ -2203,7 +2202,9 @@ TempoMap::round_to_beat_subdivision (framepos_t fr, int sub_num, RoundMode dir)
|
||||||
/* on the subdivision, do nothing */
|
/* on the subdivision, do nothing */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return frame_at_tick_locked (_metrics, (beats * BBT_Time::ticks_per_beat) + ticks);
|
framepos_t ret_frame = frame_at_tick_locked (_metrics, (beats * BBT_Time::ticks_per_beat) + ticks);
|
||||||
|
return ret_frame - frame_offset_at (_metrics, fr);
|
||||||
|
//return frame_at_tick_locked (_metrics, (beats * BBT_Time::ticks_per_beat) + ticks);
|
||||||
}
|
}
|
||||||
|
|
||||||
framepos_t
|
framepos_t
|
||||||
|
|
@ -2211,7 +2212,7 @@ TempoMap::round_to_type (framepos_t frame, RoundMode dir, BBTPointType type)
|
||||||
{
|
{
|
||||||
Glib::Threads::RWLock::ReaderLock lm (lock);
|
Glib::Threads::RWLock::ReaderLock lm (lock);
|
||||||
|
|
||||||
double const beat_at_framepos = beat_at_frame_locked (_metrics, frame) + tick_offset_at (_metrics, frame);
|
double const beat_at_framepos = beat_at_frame_locked (_metrics, frame + frame_offset_at (_metrics, frame));
|
||||||
|
|
||||||
BBT_Time bbt (beats_to_bbt_locked (_metrics, beat_at_framepos));
|
BBT_Time bbt (beats_to_bbt_locked (_metrics, beat_at_framepos));
|
||||||
|
|
||||||
|
|
@ -2799,14 +2800,14 @@ TempoMap::remove_time (framepos_t where, framecnt_t amount)
|
||||||
framepos_t
|
framepos_t
|
||||||
TempoMap::framepos_plus_beats (framepos_t pos, Evoral::Beats beats) const
|
TempoMap::framepos_plus_beats (framepos_t pos, Evoral::Beats beats) const
|
||||||
{
|
{
|
||||||
return frame_at_beat (beat_at_frame (pos) + beats.to_double());
|
return frame_at_beat (beat_at_frame_locked (_metrics, pos) + beats.to_double());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Subtract some (fractional) beats from a frame position, and return the result in frames */
|
/** Subtract some (fractional) beats from a frame position, and return the result in frames */
|
||||||
framepos_t
|
framepos_t
|
||||||
TempoMap::framepos_minus_beats (framepos_t pos, Evoral::Beats beats) const
|
TempoMap::framepos_minus_beats (framepos_t pos, Evoral::Beats beats) const
|
||||||
{
|
{
|
||||||
return frame_at_beat (beat_at_frame (pos) - beats.to_double());
|
return frame_at_beat (beat_at_frame_locked (_metrics, pos) - beats.to_double());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Add the BBT interval op to pos and return the result */
|
/** Add the BBT interval op to pos and return the result */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue