Fixing constrain().

pull/85/head
Holger Wirtz 3 years ago
parent 739bb9be2e
commit 7e06ff721c
  1. 2
      Synth_Dexed
  2. 20
      src/common.h

@ -1 +1 @@
Subproject commit 24af490e0f7d1d5b816a130f7d8c0f4a8b20946d
Subproject commit f304ae4e1cfa6ca9bab918f8f5a55bd562756e78

@ -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<class T>
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

Loading…
Cancel
Save