History

merge fix

Jeff Snyder committed 7 years ago

Commit ed50a402 parents 344bac3 53cc69a7 files · +135 −131Browse files

Unified · Split

7 files
  1. LEAF/Inc/leaf-crusher.h +1 −1
  2. LEAF/Inc/leaf-math.h +6 −1
  3. LEAF/Inc/leaf-mempool.h +3 −1
  4. LEAF/Src/leaf-crusher.c +1 −1
  5. LEAF/Src/leaf-delay.c +4 −6
  6. LEAF/Src/leaf-math.c +118 −121
  7. LEAF/leaf.h +2 −0
LEAF/Inc/leaf-crusher.h+1−1
@@ -61,4 +61,4 @@ void tCrusher_setSamplingRatio (tCrusher* const, float ratio); · 60 unmodified lines
61 61
62#endif // LEAF_WAVEFOLDER_H_INCLUDED62#endif // LEAF_WAVEFOLDER_H_INCLUDED
63 63
64//==============================================================================64//==============================================================================
LEAF/Inc/leaf-math.h+6−1
@@ -19,6 +19,8 @@ extern "C" { · 18 unmodified lines
19 19
20//==============================================================================20//==============================================================================
21 21
22//==============================================================================
23
22typedef enum oBool24typedef enum oBool
23{25{
24 OTRUE = 1,26 OTRUE = 1,
@@ -82,6 +84,10 @@ float LEAF_reduct (float input, float ratio); · 57 unmodified lines
82float LEAF_round (float input, float rnd);84float LEAF_round (float input, float rnd);
83float LEAF_bitwise_xor(float input, uint32_t op);85float LEAF_bitwise_xor(float input, uint32_t op);
84 86
87float LEAF_reduct (float input, float ratio);
88float LEAF_round (float input, float rnd);
89float LEAF_bitwise_xor(float input, uint32_t op);
90
85float LEAF_clip (float min, float val, float max);91float LEAF_clip (float min, float val, float max);
86int LEAF_clipInt (int min, int val, int max);92int LEAF_clipInt (int min, int val, int max);
87float LEAF_softClip (float val, float thresh);93float LEAF_softClip (float val, float thresh);
@@ -99,7 +105,6 @@ void LEAF_generate_square (float* buffer, float basefreq, int size); · 11 unmodified lines
99float LEAF_chebyshevT(float in, int n);105float LEAF_chebyshevT(float in, int n);
100float LEAF_CompoundChebyshevT(float in, int n, float* amps);106float LEAF_CompoundChebyshevT(float in, int n, float* amps);
101 107
102
103// Hermite interpolation108// Hermite interpolation
104float LEAF_interpolate_hermite (float A, float B, float C, float D, float t);109float LEAF_interpolate_hermite (float A, float B, float C, float D, float t);
105float LEAF_interpolation_linear (float A, float B, float t);110float LEAF_interpolation_linear (float A, float B, float t);
LEAF/Inc/leaf-mempool.h+3−1
@@ -50,7 +50,9 @@ extern "C" { · 49 unmodified lines
50 50
51//==============================================================================51//==============================================================================
52 52
53#define MPOOL_POOL_SIZE 30000053
54#define MPOOL_POOL_SIZE 500000
55
54#define MPOOL_ALIGN_SIZE (8)56#define MPOOL_ALIGN_SIZE (8)
55 57
56//#define size_t unsigned long58//#define size_t unsigned long
LEAF/Src/leaf-crusher.c+1−1
@@ -81,4 +81,4 @@ void tCrusher_setRound (tCrusher* const c, float rnd) · 80 unmodified lines
81void tCrusher_setSamplingRatio (tCrusher* const c, float ratio)81void tCrusher_setSamplingRatio (tCrusher* const c, float ratio)
82{82{
83 c->srr = ratio;83 c->srr = ratio;
84}84}
LEAF/Src/leaf-delay.c+4−6
@@ -437,8 +437,6 @@ float tDelayA_getGain (tDelayA* const d) · 436 unmodified lines
437void tTapeDelay_init (tTapeDelay* const d, float delay, uint32_t maxDelay)437void tTapeDelay_init (tTapeDelay* const d, float delay, uint32_t maxDelay)
438{438{
439 d->maxDelay = maxDelay;439 d->maxDelay = maxDelay;
440
441 d->delay = LEAF_clip(1.f, delay, d->maxDelay);
442 440
443 d->buff = (float*) leaf_alloc(sizeof(float) * maxDelay);441 d->buff = (float*) leaf_alloc(sizeof(float) * maxDelay);
444 442
@@ -451,7 +449,7 @@ void tTapeDelay_init (tTapeDelay* const d, float delay, uint32_t maxDelay) · 6 unmodified lines
451 d->inc = 1.0f;449 d->inc = 1.0f;
452 d->inPoint = 0;450 d->inPoint = 0;
453 451
454 tTapeDelay_setDelay(d, 1.f);452 tTapeDelay_setDelay(d, delay);
455}453}
456 454
457void tTapeDelay_free(tTapeDelay* const d)455void tTapeDelay_free(tTapeDelay* const d)
@@ -462,7 +460,7 @@ void tTapeDelay_free(tTapeDelay* const d) · 4 unmodified lines
462 460
463int count = 0;461int count = 0;
464 462
465#define SMOOTH_FACTOR 10.f463//#define SMOOTH_FACTOR 10.f
466 464
467float tTapeDelay_tick (tTapeDelay* const d, float input)465float tTapeDelay_tick (tTapeDelay* const d, float input)
468{466{
@@ -483,11 +481,11 @@ float tTapeDelay_tick (tTapeDelay* const d, float input) · 14 unmodified lines
483 float diff = (d->inPoint - d->idx);481 float diff = (d->inPoint - d->idx);
484 while (diff < 0.f) diff += d->maxDelay;482 while (diff < 0.f) diff += d->maxDelay;
485 483
486 d->inc = 1.0f + (diff - d->delay) / d->delay * SMOOTH_FACTOR;484 d->inc = 1.0f + (diff - d->delay) / d->delay; //* SMOOTH_FACTOR;
487 485
488 d->idx += d->inc;486 d->idx += d->inc;
489 487
490 if (d->idx >= d->maxDelay) d->idx = 0.f;488 if (d->idx >= d->maxDelay) d->idx = 0.0f;
491 489
492 return d->lastOut;490 return d->lastOut;
493}491}
LEAF/Src/leaf-math.c+118−121
@@ -21,8 +21,7 @@ · 20 unmodified lines
21// The C-embedded Audio Library.21// The C-embedded Audio Library.
22#define TWO_TO_16 65536.f22#define TWO_TO_16 65536.f
23 23
24#define EXPONENTIAL_TABLE_SIZE 6553624#define EXPONENTIAL_TABLE_SIZE 65536
25
26 25
27float interpolate3max(float *buf, const int peakindex)26float interpolate3max(float *buf, const int peakindex)
28{27{
@@ -71,7 +70,7 @@ float fastabs(float f) · 42 unmodified lines
71 70
72 alias.f = f;71 alias.f = f;
73 alias.ui &= 0x7fffffff;72 alias.ui &= 0x7fffffff;
74 return alias.f;73 return alias.f;
75}74}
76 75
77// dope af76// dope af
@@ -207,8 +206,7 @@ int LEAF_clipInt(int min, int val, int max) · 129 unmodified lines
207 } else {206 } else {
208 return val;207 return val;
209 }208 }
210}209}
211
212 210
213oBool LEAF_isPrime(uint64_t number )211oBool LEAF_isPrime(uint64_t number )
214{212{
@@ -232,91 +230,91 @@ float LEAF_tanh(float x) · 17 unmodified lines
232 else230 else
233 return x * ( 27 + x * x ) / ( 27 + 9 * x * x );231 return x * ( 27 + x * x ) / ( 27 + 9 * x * x );
234}232}
235 233
236 234
237void LEAF_generate_sine(float* buffer, int size)235void LEAF_generate_sine(float* buffer, int size)
238{236{
239 float phase;237 float phase;
240 for (int i = 0; i < size; i++)238 for (int i = 0; i < size; i++)
241 {239 {
242 phase = (float) i / (float) size;240 phase = (float) i / (float) size;
243 buffer[i] = sinf(phase * TWO_PI);241 buffer[i] = sinf(phase * TWO_PI);
244 }242 }
245}243}
246 244
247void LEAF_generate_sawtooth(float* buffer, float basefreq, int size)245void LEAF_generate_sawtooth(float* buffer, float basefreq, int size)
248{246{
249 int harmonic = 1;247 int harmonic = 1;
250 float phase = 0.0f;248 float phase = 0.0f;
251 float freq = harmonic * basefreq;249 float freq = harmonic * basefreq;
252 float amp;250 float amp;
253 251
254 while (freq < (leaf.sampleRate * 0.5))252 while (freq < (leaf.sampleRate * 0.5))
255 {253 {
256 amp = 1.0f / harmonic;254 amp = 1.0f / harmonic;
257 for (int i = 0; i < size; i++)255 for (int i = 0; i < size; i++)
258 {256 {
259 phase = (float) i / (float) size;257 phase = (float) i / (float) size;
260 buffer[i] += (amp * sinf(harmonic * phase * TWO_PI));258 buffer[i] += (amp * sinf(harmonic * phase * TWO_PI));
261 }259 }
262 260
263 harmonic++;261 harmonic++;
264 freq = harmonic * basefreq;262 freq = harmonic * basefreq;
265 }263 }
266}264}
267 265
268 266
269void LEAF_generate_triangle(float* buffer, float basefreq, int size)267void LEAF_generate_triangle(float* buffer, float basefreq, int size)
270{268{
271 int harmonic = 1;269 int harmonic = 1;
272 float phase = 0.0f;270 float phase = 0.0f;
273 float freq = harmonic * basefreq;271 float freq = harmonic * basefreq;
274 float amp = 1.0f;272 float amp = 1.0f;
275 273
276 int count = 0;274 int count = 0;
277 float mult = 1.0f;275 float mult = 1.0f;
278 276
279 while (freq < (leaf.sampleRate * 0.5))277 while (freq < (leaf.sampleRate * 0.5))
280 {278 {
281 amp = 1.0f / (float)(harmonic * harmonic);279 amp = 1.0f / (float)(harmonic * harmonic);
282 280
283 if (count % 2) mult = -1.0f;281 if (count % 2) mult = -1.0f;
284 else mult = 1.0f;282 else mult = 1.0f;
285 283
286 for (int i = 0; i < size; i++)284 for (int i = 0; i < size; i++)
287 {285 {
288 phase = (float) i / (float) size;286 phase = (float) i / (float) size;
289 buffer[i] += (mult * amp * sinf(harmonic * phase * TWO_PI));287 buffer[i] += (mult * amp * sinf(harmonic * phase * TWO_PI));
290 }288 }
291 289
292 count++;290 count++;
293 harmonic += 2;291 harmonic += 2;
294 freq = harmonic * basefreq;292 freq = harmonic * basefreq;
295 }293 }
296}294}
297 295
298void LEAF_generate_square(float* buffer, float basefreq, int size)296void LEAF_generate_square(float* buffer, float basefreq, int size)
299{297{
300 int harmonic = 1;298 int harmonic = 1;
301 float phase = 0.0f;299 float phase = 0.0f;
302 float freq = harmonic * basefreq;300 float freq = harmonic * basefreq;
303 float amp = 1.0f;301 float amp = 1.0f;
304 302
305 while (freq < (leaf.sampleRate * 0.5))303 while (freq < (leaf.sampleRate * 0.5))
306 {304 {
307 amp = 1.0f / (float)(harmonic);305 amp = 1.0f / (float)(harmonic);
308 306
309 for (int i = 0; i < size; i++)307 for (int i = 0; i < size; i++)
310 {308 {
311 phase = (float) i / (float) size;309 phase = (float) i / (float) size;
312 buffer[i] += (amp * sinf(harmonic * phase * TWO_PI));310 buffer[i] += (amp * sinf(harmonic * phase * TWO_PI));
313 }311 }
314 312
315 harmonic += 2;313 harmonic += 2;
316 freq = harmonic * basefreq;314 freq = harmonic * basefreq;
317 }315 }
318}316}
319 317
320 318
321//-----------------------------------------------------------------------------319//-----------------------------------------------------------------------------
322// name: mtof()320// name: mtof()
@@ -326,35 +324,34 @@ float LEAF_midiToFrequency(float f) · 3 unmodified lines
326{324{
327 if( f <= -1500.0f ) return (0);325 if( f <= -1500.0f ) return (0);
328 else if( f > 1499.0f ) return (LEAF_midiToFrequency(1499.0f));326 else if( f > 1499.0f ) return (LEAF_midiToFrequency(1499.0f));
329 else return ( powf(2.0f, (f - 69.0f) / 12.0f) * 440.0f );327 else return ( powf(2.0f, (f - 69.0f) * 0.083333333333333f) * 440.0f );
330}328}
331 329
332 330
333// alpha, [0.0, 1.0]331// alpha, [0.0, 1.0]
334float LEAF_interpolate_hermite (float A, float B, float C, float D, float alpha)332float LEAF_interpolate_hermite (float A, float B, float C, float D, float alpha)
335{333{
336 alpha = LEAF_clip(0.0f, alpha, 1.0f);334 alpha = LEAF_clip(0.0f, alpha, 1.0f);
337 335
338 float a = -A/2.0f + (3.0f*B)/2.0f - (3.0f*C)/2.0f + D/2.0f;336 float a = -A/2.0f + (3.0f*B)/2.0f - (3.0f*C)/2.0f + D/2.0f;
339 float b = A - (5.0f*B)/2.0f + 2.0f*C - D / 2.0f;337 float b = A - (5.0f*B)/2.0f + 2.0f*C - D / 2.0f;
340 float c = -A/2.0f + C/2.0f;338 float c = -A/2.0f + C/2.0f;
341 float d = B;339 float d = B;
342 340
343 return a*alpha*alpha*alpha + b*alpha*alpha + c*alpha + d;341 return a*alpha*alpha*alpha + b*alpha*alpha + c*alpha + d;
344}342}
345 343
346// alpha, [0.0, 1.0]344// alpha, [0.0, 1.0]
347float LEAF_interpolation_linear (float A, float B, float alpha)345float LEAF_interpolation_linear (float A, float B, float alpha)
348{346{
349 alpha = LEAF_clip(0.0f, alpha, 1.0f);347 alpha = LEAF_clip(0.0f, alpha, 1.0f);
350 348
351 float omAlpha = 1.0f - alpha;349 float omAlpha = 1.0f - alpha;
352 350
353 // First 1/2 of interpolation351 // First 1/2 of interpolation
354 float out = A * omAlpha;352 float out = A * omAlpha;
355
356 out += B * alpha;
357
358 return out;
359}
360 353
354 out += B * alpha;
355
356 return out;
357}
LEAF/leaf.h+2−0
@@ -37,6 +37,7 @@ · 36 unmodified lines
37#include ".\Inc\leaf-crusher.h"37#include ".\Inc\leaf-crusher.h"
38#include ".\Inc\leaf-wavefolder.h"38#include ".\Inc\leaf-wavefolder.h"
39#include ".\Inc\leaf-wavetables.h"39#include ".\Inc\leaf-wavetables.h"
40#include ".\Inc\leaf-crusher.h"
40 41
41#else42#else
42 43
@@ -58,6 +59,7 @@ · 15 unmodified lines
58#include "./Inc/leaf-crusher.h"59#include "./Inc/leaf-crusher.h"
59#include "./Inc/leaf-wavefolder.h"60#include "./Inc/leaf-wavefolder.h"
60#include "./Inc/leaf-wavetables.h"61#include "./Inc/leaf-wavetables.h"
62#include "./Inc/leaf-crusher.h"
61 63
62#endif64#endif
63 65

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