From 5175260af41cdd532fefff15d39bd4501ea96070 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 26 May 2022 10:34:40 -0600 Subject: [PATCH] temporal: remove dangerous muldiv methods and use explicit method name not cast --- libs/ardour/rb_effect.cc | 4 ++-- libs/temporal/temporal/types.h | 13 +------------ 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/libs/ardour/rb_effect.cc b/libs/ardour/rb_effect.cc index 272ab538ae..87ce670bd4 100644 --- a/libs/ardour/rb_effect.cc +++ b/libs/ardour/rb_effect.cc @@ -148,7 +148,7 @@ RBEffect::run (boost::shared_ptr r, Progress* progress) * I hope this is clear. */ - double stretch = region->stretch() * tsr.time_fraction; + double stretch = region->stretch() * tsr.time_fraction.to_double(); double shift = region->shift() * tsr.pitch_fraction; samplecnt_t read_start = region->ancestral_start_sample () + @@ -360,7 +360,7 @@ RBEffect::run (boost::shared_ptr r, Progress* progress) /* multiply the old (possibly previously stretched) region length by the extra * stretch this time around to get its new length. this is a non-music based edit atm. */ - (*x)->set_length (timecnt_t (tsr.time_fraction * (*x)->length_samples (), (*x)->position())); + (*x)->set_length (timecnt_t (tsr.time_fraction.to_double() * (*x)->length_samples (), (*x)->position())); } /* stretch region gain envelope */ diff --git a/libs/temporal/temporal/types.h b/libs/temporal/temporal/types.h index ff39b6758f..a54659ab57 100644 --- a/libs/temporal/temporal/types.h +++ b/libs/temporal/temporal/types.h @@ -76,18 +76,7 @@ class _ratio_t { bool is_unity() const { return _numerator == _denominator; } bool is_zero() const { return _numerator == 0; } - operator double() const { return (double) _numerator / _denominator; }; - - /* provide an easy way to multiply double by ratio_t. Note that this - must be written as ratio_t * double, not the other way around. We - are not trying to duplicate boost::rational here (which also doesn't - allow this without a lot of syntactic fluff. - */ - double operator* (double v) const { return (v * (double) _numerator) / (double) _denominator; } - - /* ditto for int64_t */ - - int64_t operator* (int64_t v) const { return int_div_round (v * _numerator, _denominator); } + double to_double() const { return (double) _numerator / _denominator; }; private: T _numerator;