ref: 9179bd92e043cbd585ce50acb0caa7cb96d6fd16
parent: 32b51e4078a2b84abcf5a9efbcb904b168ec1326
author: Matthew Wang <Matthew@nat-oitwireless-inside-vapornet100-10-9-61-0.princeton.edu>
date: Thu Feb 7 14:42:24 EST 2019
crusher parameter fixes
--- a/LEAF/Inc/leaf-math.h
+++ b/LEAF/Inc/leaf-math.h
@@ -80,7 +80,7 @@
float LEAF_reduct (float input, float ratio);
float LEAF_round (float input, float rnd);
-float LEAF_bitwise_or(float input, uint32_t op);
+float LEAF_bitwise_xor(float input, uint32_t op);
float LEAF_clip (float min, float val, float max);
int LEAF_clipInt (int min, int val, int max);
--- a/LEAF/Src/leaf-crusher.c
+++ b/LEAF/Src/leaf-crusher.c
@@ -41,11 +41,11 @@
sample *= SCALAR; // SCALAR is 5000 by default
- sample = floorf(sample);
+ sample = (int32_t) sample;
sample /= c->div;
- sample = LEAF_bitwise_or(sample, c->op << 23);
+ sample = LEAF_bitwise_xor(sample, c->op << 23);
sample = LEAF_clip(-1.f, sample, 1.f);
@@ -59,12 +59,12 @@
void tCrusher_setOperation (tCrusher* const c, float op)
{
- c->op = (int) (op * 8.0f);
+ c->op = (uint32_t) (op * 8.0f);
}
// 0.0 - 1.0
void tCrusher_setQuality (tCrusher* const c, float val)
-{
+{
val = LEAF_clip(0.0f, val, 1.0f);
c->div = 0.01f + val * SCALAR;
--- a/LEAF/Src/leaf-math.c
+++ b/LEAF/Src/leaf-math.c
@@ -127,7 +127,7 @@
float LEAF_reduct (float input, float ratio)
{
reduct_count++;
- if (reduct_count > (leaf.sampleRate * (1.f - ratio)))
+ if (reduct_count > 1.f / ratio)
{
hold = input;
reduct_count = 0;
@@ -150,10 +150,10 @@
union unholy_t unholy;
-float LEAF_bitwise_or(float input, uint32_t op)
+float LEAF_bitwise_xor(float input, uint32_t op)
{
unholy.f = input;
- unholy.i = (unholy.i | op);
+ unholy.i = (unholy.i ^ op);
return unholy.f;
}