iidxhook9: Add turntable multiplier
This commit is contained in:
@@ -10,6 +10,7 @@ src_util := \
|
||||
iobuf.c \
|
||||
list.c \
|
||||
log.c \
|
||||
math.c \
|
||||
mem.c \
|
||||
msg-thread.c \
|
||||
net.c \
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
#include "util/math.h"
|
||||
|
||||
int16_t get_wrapped_delta_s16(int16_t val, int16_t last, int16_t bound) {
|
||||
int16_t half_point = bound / 2;
|
||||
|
||||
int16_t delta = val - last;
|
||||
|
||||
if (delta > half_point) {
|
||||
delta -= bound;
|
||||
}
|
||||
|
||||
if (delta < -half_point) {
|
||||
delta += bound;
|
||||
}
|
||||
|
||||
// delta is now between (-half_point - half_point)
|
||||
return delta;
|
||||
}
|
||||
|
||||
int16_t sign_s16(int16_t x) {
|
||||
return (x > 0) - (x < 0);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#ifndef UTIL_MATH_H
|
||||
#define UTIL_MATH_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
int16_t get_wrapped_delta_s16(int16_t val, int16_t last, int16_t bound);
|
||||
int16_t sign_s16(int16_t x);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user