diff --git a/Synth_Dexed b/Synth_Dexed index 24af490..f304ae4 160000 --- a/Synth_Dexed +++ b/Synth_Dexed @@ -1 +1 @@ -Subproject commit 24af490e0f7d1d5b816a130f7d8c0f4a8b20946d +Subproject commit f304ae4e1cfa6ca9bab918f8f5a55bd562756e78 diff --git a/src/common.h b/src/common.h index 3b56b3c..902f74b 100644 --- a/src/common.h +++ b/src/common.h @@ -16,19 +16,11 @@ inline float32_t mapfloat(int val, int in_min, int in_max, float32_t out_min, fl return (val - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; } -#ifndef _constrain_defined_ -#define _constrain_defined_ -template -const T& constrain(const T& x, const T& a, const T& b) { - if(x < a) { - return a; - } - else if(b < x) { - return b; - } - else - return x; -} -#endif +#define constrain(amt, low, high) ({ \ + __typeof__(amt) _amt = (amt); \ + __typeof__(low) _low = (low); \ + __typeof__(high) _high = (high); \ + (_amt < _low) ? _low : ((_amt > _high) ? _high : _amt); \ +}) #endif