diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2010-12-14 20:03:40 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2010-12-14 20:03:40 +0000 |
commit | e3c67bceb864adc10764e901b87ad8b6677caebd (patch) | |
tree | 98cc093e7255dc658bd839a1bbf6c92f76b58331 /libs/ardour/beats_frames_converter.cc | |
parent | df5e700f90d9fd6c803e8e85c56f3fe8118bc101 (diff) |
implement methods in TempoMap for walking a given distance along a tempo map and returning the resulting time; add a new property, _length_beats, to MidiRegion; use previously mentioned methods to keep _length_beats up to date as regions are moved AND as tempo map changes occur
git-svn-id: svn://localhost/ardour2/branches/3.0@8274 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/beats_frames_converter.cc')
-rw-r--r-- | libs/ardour/beats_frames_converter.cc | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/libs/ardour/beats_frames_converter.cc b/libs/ardour/beats_frames_converter.cc index 180b3e563a..4cda4173b3 100644 --- a/libs/ardour/beats_frames_converter.cc +++ b/libs/ardour/beats_frames_converter.cc @@ -27,25 +27,19 @@ namespace ARDOUR { framecnt_t BeatsFramesConverter::to(double beats) const { - // FIXME: assumes tempo never changes after origin - const Tempo& tempo = _tempo_map.tempo_at (_origin_b); - const double frames_per_beat = tempo.frames_per_beat( - _tempo_map.frame_rate(), - _tempo_map.meter_at (_origin_b)); + Timecode::BBT_Time delta; - return llrint (beats * frames_per_beat); + delta.bars = 0; + delta.beats = rint (floor (beats)); + delta.ticks = rint (floor (Meter::ticks_per_beat * fmod (beats, 1.0))); + + return _tempo_map.framepos_plus_bbt (_origin_b, delta); } double BeatsFramesConverter::from (framecnt_t frames) const { - // FIXME: assumes tempo never changes after origin - const Tempo& tempo = _tempo_map.tempo_at (_origin_b); - const double frames_per_beat = tempo.frames_per_beat( - _tempo_map.frame_rate(), - _tempo_map.meter_at (_origin_b)); - - return frames / frames_per_beat; + return _tempo_map.framewalk_to_beats (_origin_b, frames); } } /* namespace ARDOUR */ |