ref: b799241bdde98885bb18b0f2e2cc06b063eb2d13
parent: b75f8902da21dec3c60db9fc1eda9437b39d7a48
author: Paul Brossier <[email protected]>
date: Fri Mar 10 15:16:28 EST 2017
src/musicutils.h: add fvec_clamp, basic limiter
--- a/src/mathutils.c
+++ b/src/mathutils.c
@@ -297,6 +297,17 @@
in->data[in->length - 1] = new_elem;
}
+void fvec_clamp(fvec_t *in, smpl_t absmax) {
+ uint_t i;
+ for (i = 0; i < in->length; i++) {
+ if (in->data[i] > 0 && in->data[i] > ABS(absmax)) {
+ in->data[i] = absmax;
+ } else if (in->data[i] < 0 && in->data[i] < -ABS(absmax)) {
+ in->data[i] = -absmax;
+ }
+ }
+}
+
smpl_t
aubio_level_lin (const fvec_t * f)
{
--- a/src/musicutils.h
+++ b/src/musicutils.h
@@ -156,6 +156,14 @@
*/
smpl_t aubio_level_detection (const fvec_t * v, smpl_t threshold);
+/** clamp the values of a vector within the range [-abs(max), abs(max)]
+
+ \param in vector to clamp
+ \param max maximum value over which input vector elements should be clamped
+
+*/
+void fvec_clamp(fvec_t *in, smpl_t absmax);
+
#ifdef __cplusplus
}
#endif