File tree Expand file tree Collapse file tree
thirdparty/bungee_library/upstream/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,8 +51,15 @@ struct Time
5151 inline int32_t delta (int32_t phase, int32_t previous, int m) const
5252 {
5353 constexpr auto logS = 32 + log2SynthesisHopRevolution;
54- const int32_t da = (phase - previous) - m * a;
55- return (m << logS) + (da >> 15 ) * multiplier;
54+ // const int32_t da = (phase - previous) - m * a;
55+ // return (m << logS) + (da >> 15) * multiplier;
56+ const int32_t phaseDiff = int32_t (int64_t (phase) - int64_t (previous));
57+ const int32_t ma = int32_t (int64_t (m) * int64_t (a));
58+ const int32_t da = int32_t (int64_t (phaseDiff) - int64_t (ma));
59+ const uint64_t shifted64 = uint64_t (uint32_t (m)) << logS;
60+ const int32_t mShifted = int32_t (uint32_t (shifted64));
61+ const int32_t scaled = int32_t ((int64_t (da) >> 15 ) * int64_t (multiplier));
62+ return int32_t (int64_t (mShifted ) + int64_t (scaled));
5663 }
5764
5865 inline int16_t delta (int16_t phase, int16_t previous, int m) const
You can’t perform that action at this time.
0 commit comments