diff options
| author | Carl Hetherington <cth@carlh.net> | 2017-07-21 13:06:07 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2017-07-21 13:06:07 +0100 |
| commit | d95907ad565ac587dea8f8692a3775c1dc6e0ff1 (patch) | |
| tree | 8b23935cc906260797f7b3e39568171d19d6b9d6 /src | |
| parent | a25cc3fda26e2bbc6b1c3786cc7f2ed7141a29f0 (diff) | |
Fix completely-broken Time::scale.
Diffstat (limited to 'src')
| -rw-r--r-- | src/sub_time.cc | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/sub_time.cc b/src/sub_time.cc index adaab31..763b4e4 100644 --- a/src/sub_time.cc +++ b/src/sub_time.cc @@ -169,7 +169,7 @@ Time::from_frames (int f, Rational rate) double Time::all_as_seconds () const { - return _seconds + double(milliseconds ()) / 1000; + return _seconds + double(milliseconds()) / 1000; } /** Add a time to this one. Both *this and t must have a specified _rate */ @@ -190,10 +190,7 @@ Time::scale (float f) SUB_ASSERT (_rate->denominator != 0); SUB_ASSERT (_rate->integer ()); - _seconds = rint (_seconds * f); - _frames = rint (_frames * f); - if (_frames >= _rate->integer_fraction()) { - _frames -= _rate->integer_fraction (); - ++_seconds; - } + double const s = Time::all_as_seconds() * f; + _seconds = floor (s); + _frames = rint ((s - _seconds) * _rate->fraction()); } |
