summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-12-03 18:20:54 -0800
committerVito Caputo <vcaputo@pengaru.com>2023-12-03 18:20:54 -0800
commit50987c0a263c06aeb2ba335799264d696ac2c8bf (patch)
tree053f6c7b2dd473bf40681e817b6eb5cd0e9a729c
parent2cced409304e215ca09bf2946a1d34585f1bb8bd (diff)
modules/rkt: round integer tap values
It's looking like truncation is more often annoying, let's try rounding.
-rw-r--r--src/modules/rkt/rkt.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/modules/rkt/rkt.c b/src/modules/rkt/rkt.c
index 6fac2c2..d10c046 100644
--- a/src/modules/rkt/rkt.c
+++ b/src/modules/rkt/rkt.c
@@ -263,33 +263,38 @@ static int rkt_pipe_update(void *context, til_stream_pipe_t *pipe, const void *o
* to integers on their own with whatever methods they prefer. Even if that
* resembles letting Rocket implementation details bleed through to the til_tap
* API.
+ * XXX: despite the above, I've added rounding in the integer types. It's useful
+ * for getting reasonable results abusing Rocket's interpolation on integer tracks.
+ * With truncation when interpolating up to an upper bound before descending, the
+ * upper bound integer basically never arrives. With rounding, once .5 within the
+ * peak the peak integer value will occur...
*/
#define RKT_CLAMP(_val, _min, _max) \
((_val < _min) ? _min : (_val > _max) ? _max : _val)
case TIL_TAP_TYPE_I8:
- rkt_pipe->var.i8 = RKT_CLAMP(val, INT8_MIN, INT8_MAX);
+ rkt_pipe->var.i8 = RKT_CLAMP(round(val), INT8_MIN, INT8_MAX);
break;
case TIL_TAP_TYPE_I16:
- rkt_pipe->var.i16 = RKT_CLAMP(val, INT16_MIN, INT16_MAX);
+ rkt_pipe->var.i16 = RKT_CLAMP(round(val), INT16_MIN, INT16_MAX);
break;
case TIL_TAP_TYPE_I32:
- rkt_pipe->var.i32 = RKT_CLAMP(val, INT32_MIN, INT32_MAX);
+ rkt_pipe->var.i32 = RKT_CLAMP(round(val), INT32_MIN, INT32_MAX);
break;
case TIL_TAP_TYPE_I64:
- rkt_pipe->var.i64 = RKT_CLAMP(val, INT64_MIN, INT64_MAX);
+ rkt_pipe->var.i64 = RKT_CLAMP(round(val), INT64_MIN, INT64_MAX);
break;
case TIL_TAP_TYPE_U8:
- rkt_pipe->var.u8 = RKT_CLAMP(val, 0, UINT8_MAX);
+ rkt_pipe->var.u8 = RKT_CLAMP(round(val), 0, UINT8_MAX);
break;
case TIL_TAP_TYPE_U16:
- rkt_pipe->var.u16 = RKT_CLAMP(val, 0, UINT16_MAX);
+ rkt_pipe->var.u16 = RKT_CLAMP(round(val), 0, UINT16_MAX);
break;
case TIL_TAP_TYPE_U32:
- rkt_pipe->var.u32 = RKT_CLAMP(val, 0, UINT32_MAX);
+ rkt_pipe->var.u32 = RKT_CLAMP(round(val), 0, UINT32_MAX);
break;
case TIL_TAP_TYPE_U64:
- rkt_pipe->var.u64 = RKT_CLAMP(val, 0, UINT64_MAX);
+ rkt_pipe->var.u64 = RKT_CLAMP(round(val), 0, UINT64_MAX);
break;
case TIL_TAP_TYPE_FLOAT:
rkt_pipe->var.f = RKT_CLAMP(val, FLT_MIN, FLT_MAX);
© All Rights Reserved