diff options
author | be_ <be.0@gmx.com> | 2017-05-16 15:43:37 -0500 |
---|---|---|
committer | be_ <be.0@gmx.com> | 2017-05-16 20:37:24 -0500 |
commit | 1c9c5a1da5f494c881bcd62b40ea3a2f1256f696 (patch) | |
tree | 39915080a9e0f991ede5607fc9c667df10ff2b72 /src/util/math.h | |
parent | c710ac8d420578dce5ebebc388df6b1d9279494d (diff) |
round synced echo time to 1/4 beats
Diffstat (limited to 'src/util/math.h')
-rw-r--r-- | src/util/math.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/util/math.h b/src/util/math.h index d4f2edcf80..5547c98649 100644 --- a/src/util/math.h +++ b/src/util/math.h @@ -65,6 +65,13 @@ inline int roundUpToPowerOf2(int v) { return power; } +inline double roundToFraction(double value, int denominator) { + int wholePart = value; + double fractionPart = value - wholePart; + int numerator = fractionPart * denominator; + return wholePart + (double) numerator / (double) denominator; +} + template <typename T> inline const T ratio2db(const T a) { return log10(a) * 20; |