History

crusher parameter fixes

Matthew Wang committed 7 years ago

Commit 9179bd91 parent 32b51e43 files · +8 −8Browse files

Unified · Split

3 files
  1. LEAF/Inc/leaf-math.h +1 −1
  2. LEAF/Src/leaf-crusher.c +4 −4
  3. LEAF/Src/leaf-math.c +3 −3
LEAF/Inc/leaf-math.h+1−1
@@ -80,7 +80,7 @@ float LEAF_reedTable (float input, float offset, float slope); · 79 unmodified lines
80 80
81float LEAF_reduct (float input, float ratio);81float LEAF_reduct (float input, float ratio);
82float LEAF_round (float input, float rnd);82float LEAF_round (float input, float rnd);
83float LEAF_bitwise_or(float input, uint32_t op);83float LEAF_bitwise_xor(float input, uint32_t op);
84 84
85float LEAF_clip (float min, float val, float max);85float LEAF_clip (float min, float val, float max);
86int LEAF_clipInt (int min, int val, int max);86int LEAF_clipInt (int min, int val, int max);
LEAF/Src/leaf-crusher.c+4−4
@@ -41,11 +41,11 @@ float tCrusher_tick (tCrusher* const c, float input) · 40 unmodified lines
41 41
42 sample *= SCALAR; // SCALAR is 5000 by default42 sample *= SCALAR; // SCALAR is 5000 by default
43 43
44 sample = floorf(sample);44 sample = (int32_t) sample;
45 45
46 sample /= c->div;46 sample /= c->div;
47 47
48 sample = LEAF_bitwise_or(sample, c->op << 23);48 sample = LEAF_bitwise_xor(sample, c->op << 23);
49 49
50 sample = LEAF_clip(-1.f, sample, 1.f);50 sample = LEAF_clip(-1.f, sample, 1.f);
51 51
@@ -59,12 +59,12 @@ float tCrusher_tick (tCrusher* const c, float input) · 7 unmodified lines
59 59
60void tCrusher_setOperation (tCrusher* const c, float op)60void tCrusher_setOperation (tCrusher* const c, float op)
61{61{
62 c->op = (int) (op * 8.0f);62 c->op = (uint32_t) (op * 8.0f);
63}63}
64 64
65// 0.0 - 1.065// 0.0 - 1.0
66void tCrusher_setQuality (tCrusher* const c, float val)66void tCrusher_setQuality (tCrusher* const c, float val)
67{67{
68 val = LEAF_clip(0.0f, val, 1.0f);68 val = LEAF_clip(0.0f, val, 1.0f);
69 69
70 c->div = 0.01f + val * SCALAR;70 c->div = 0.01f + val * SCALAR;
LEAF/Src/leaf-math.c+3−3
@@ -127,7 +127,7 @@ int reduct_count = 0; · 126 unmodified lines
127float LEAF_reduct (float input, float ratio)127float LEAF_reduct (float input, float ratio)
128{128{
129 reduct_count++;129 reduct_count++;
130 if (reduct_count > (leaf.sampleRate * (1.f - ratio)))130 if (reduct_count > 1.f / ratio)
131 {131 {
132 hold = input;132 hold = input;
133 reduct_count = 0;133 reduct_count = 0;
@@ -150,10 +150,10 @@ float LEAF_round (float input, float rnd) · 16 unmodified lines
150 150
151union unholy_t unholy;151union unholy_t unholy;
152 152
153float LEAF_bitwise_or(float input, uint32_t op)153float LEAF_bitwise_xor(float input, uint32_t op)
154{154{
155 unholy.f = input;155 unholy.f = input;
156 unholy.i = (unholy.i | op);156 unholy.i = (unholy.i ^ op);
157 157
158 return unholy.f;158 return unholy.f;
159}159}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t