diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2010-12-17 01:51:12 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2010-12-17 01:51:12 +0000 |
commit | 428aabdcfc66ce2202b63cdf2de945e0651e50df (patch) | |
tree | 5bd89939fc31b375076c222efcb68060f2f0d211 /libs | |
parent | 39ebb427b3125c9c48c37d0cf05a27267efeb6a3 (diff) |
fix BeatFramesConverter so that it at least works even if its not optimally named/designed
git-svn-id: svn://localhost/ardour2/branches/3.0@8290 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ardour/ardour/beats_frames_converter.h | 15 | ||||
-rw-r--r-- | libs/ardour/beats_frames_converter.cc | 4 | ||||
-rw-r--r-- | libs/ardour/midi_region.cc | 3 | ||||
-rw-r--r-- | libs/ardour/tempo.cc | 4 |
4 files changed, 13 insertions, 13 deletions
diff --git a/libs/ardour/ardour/beats_frames_converter.h b/libs/ardour/ardour/beats_frames_converter.h index e0856acc6f..286c4aaa6a 100644 --- a/libs/ardour/ardour/beats_frames_converter.h +++ b/libs/ardour/ardour/beats_frames_converter.h @@ -29,18 +29,19 @@ namespace ARDOUR { class TempoMap; -/** Converter between beats and frames. Takes `distances' in beats or frames +/** Converter between beats and frames. Takes durations in beats or frames * and converts them using the tempo at the \a origin supplied to the constructor. + * Note that this does not covert positions, only durations. */ class BeatsFramesConverter : public Evoral::TimeConverter<double,framepos_t> { public: - BeatsFramesConverter(const TempoMap& tempo_map, framepos_t origin) - : Evoral::TimeConverter<double, framepos_t> (origin) - , _tempo_map(tempo_map) - {} + BeatsFramesConverter (const TempoMap& tempo_map, framepos_t origin) + : Evoral::TimeConverter<double, framepos_t> (origin) + , _tempo_map(tempo_map) + {} - framepos_t to(double beats) const; - double from(framepos_t frames) const; + framepos_t to (double beats) const; + double from (framepos_t frames) const; private: const TempoMap& _tempo_map; diff --git a/libs/ardour/beats_frames_converter.cc b/libs/ardour/beats_frames_converter.cc index c2c54eb9cd..69610aecd3 100644 --- a/libs/ardour/beats_frames_converter.cc +++ b/libs/ardour/beats_frames_converter.cc @@ -25,9 +25,9 @@ namespace ARDOUR { framecnt_t -BeatsFramesConverter::to(double beats) const +BeatsFramesConverter::to (double beats) const { - return _tempo_map.framepos_plus_bbt (_origin_b, Timecode::BBT_Time(beats)); + return _tempo_map.framepos_plus_bbt (_origin_b, Timecode::BBT_Time(beats)) - _origin_b; } double diff --git a/libs/ardour/midi_region.cc b/libs/ardour/midi_region.cc index ee5d42dcf9..e487cae2f5 100644 --- a/libs/ardour/midi_region.cc +++ b/libs/ardour/midi_region.cc @@ -134,7 +134,7 @@ void MidiRegion::update_length_beats () { cerr << name() << " Updating length beats, currently = " << _length_beats << " w/length = " << _length << endl; - BeatsFramesConverter converter (_session.tempo_map(), _position - _start); + BeatsFramesConverter converter (_session.tempo_map(), _position); _length_beats = converter.from (_length); cerr << "\tnew value: " << _length_beats << endl; } @@ -151,7 +151,6 @@ MidiRegion::set_position_internal (framepos_t pos, bool allow_bbt_recompute) at the new position (tempo map may dictate a different number of frames */ BeatsFramesConverter converter (_session.tempo_map(), _position - _start); - cerr << name() << " change frame length to " << converter.to (_length_beats) << endl; Region::set_length_internal (converter.to (_length_beats)); } } diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc index 08c9289919..dd1b07ad01 100644 --- a/libs/ardour/tempo.cc +++ b/libs/ardour/tempo.cc @@ -2067,7 +2067,7 @@ TempoMap::framewalk_to_beats (framepos_t pos, framecnt_t distance) const */ if (ddist < frames_per_beat) { - beats += BBT_Time::ticks_per_beat * (ddist/frames_per_beat); + beats += (1.0/BBT_Time::ticks_per_beat) * (ddist/frames_per_beat); break; } @@ -2076,7 +2076,7 @@ TempoMap::framewalk_to_beats (framepos_t pos, framecnt_t distance) const ddist -= frames_per_beat; dpos += frames_per_beat; beats += 1.0; - + /* 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. */ |