History

use mempool for all large/variable size member and free function for every object

Matthew Wang committed 7 years ago

Commit 3b564d41 parent d6d64a942 files · +421 −347Browse files

Unified · Split

42 files
  1. LEAF/Inc/.DS_Store +0 −0
  2. LEAF/Inc/leaf-808.h +3 −3
  3. LEAF/Inc/leaf-WDF.h +1 −1
  4. LEAF/Inc/leaf-crusher.h +1 −1
  5. LEAF/Inc/leaf-delay.h +47 −48
  6. LEAF/Inc/leaf-filter.h +0 −3
  7. LEAF/Inc/leaf-formant.h +2 −1
  8. LEAF/Inc/leaf-global.h +37 −0
  9. LEAF/Inc/leaf-globals.h +0 −61
  10. LEAF/Inc/leaf-math.h +7 −0
  11. LEAF/Inc/leaf-mempool.h +0 −3
  12. LEAF/Inc/leaf-midi.h +3 −3
  13. LEAF/Inc/leaf-oscillator.h +10 −11
  14. LEAF/Inc/leaf-oversampler.h +2 −1
  15. LEAF/Inc/leaf-pitch.h +2 −2
  16. LEAF/Inc/leaf-reverb.h +1 −1
  17. LEAF/Inc/leaf-sample.h +1 −1
  18. LEAF/Inc/leaf-string.h +1 −1
  19. LEAF/Inc/leaf-tables.h +0 −1
  20. LEAF/Inc/leaf-utilities.h +2 −1
  21. LEAF/Inc/leaf-vocoder.h +1 −1
  22. LEAF/Inc/leaf-wavefolder.h +1 −1
  23. LEAF/Src/leaf-808.c +133 −93
  24. LEAF/Src/leaf-WDF.c +1 −1
  25. LEAF/Src/leaf-crusher.c +1 −1
  26. LEAF/Src/leaf-delay.c +0 −4
  27. LEAF/Src/leaf-filter.c +30 −29
  28. LEAF/Src/leaf-formant.c +0 −2
  29. LEAF/Src/leaf-mempool.c +1 −0
  30. LEAF/Src/leaf-midi.c +12 −14
  31. LEAF/Src/leaf-oscillator.c +17 −16
  32. LEAF/Src/leaf-oversampler.c +0 −1
  33. LEAF/Src/leaf-pitch.c +0 −7
  34. LEAF/Src/leaf-reverb.c +4 −5
  35. LEAF/Src/leaf-sample.c +0 −2
  36. LEAF/Src/leaf-string.c +0 −4
  37. LEAF/Src/leaf-tables.c +2 −2
  38. LEAF/Src/leaf-utilities.c +84 −16
  39. LEAF/Src/leaf-vocoder.c +5 −3
  40. LEAF/Src/leaf-wavefolder.c +5 −0
  41. LEAF/leaf.h +4 −2
  42. LEAF_JUCEPlugin/LEAF.jucer +1 −1
LEAF/Inc/.DS_Store+0−0

Binary file not shown.

LEAF/Inc/leaf-808.h+3−3
@@ -15,9 +15,7 @@ extern "C" { · 14 unmodified lines
1515
1616 //==============================================================================
1717
18−#include "leaf-globals.h"
1918 #include "leaf-math.h"
20−
2119 #include "leaf-oscillator.h"
2220 #include "leaf-utilities.h"
2321 #include "leaf-filter.h"
@@ -37,10 +35,11 @@ typedef struct _t808Cowbell { · 13 unmodified lines
3735 tHighpass highpass;
3836 float oscMix;
3937 float filterCutoff;
38+ oBool useStick;
4039
4140 } t808Cowbell;
4241
43−void t808Cowbell_init (t808Cowbell* const);
42+void t808Cowbell_init (t808Cowbell* const, int useStick);
4443 void t808Cowbell_free (t808Cowbell* const);
4544 float t808Cowbell_tick (t808Cowbell* const);
4645 void t808Cowbell_on (t808Cowbell* const, float vel);
@@ -49,6 +48,7 @@ void t808Cowbell_setHighpassFreq (t808Cowbell* const, float freq); · 2 unmodified lines
4948 void t808Cowbell_setBandpassFreq (t808Cowbell* const, float freq);
5049 void t808Cowbell_setFreq (t808Cowbell* const, float freq);
5150 void t808Cowbell_setOscMix (t808Cowbell* const, float oscMix);
51+void t808Cowbell_setStick (t808Cowbell* const, int useStick);
5252
5353 //==============================================================================
5454
LEAF/Inc/leaf-WDF.h+1−1
@@ -14,7 +14,7 @@ extern "C" { · 13 unmodified lines
1414
1515 //==============================================================================
1616
17−#include "leaf-globals.h"
17+#include "leaf-global.h"
1818 #include "leaf-math.h"
1919
2020 //==============================================================================
LEAF/Inc/leaf-crusher.h+1−1
@@ -18,7 +18,7 @@ extern "C" { · 17 unmodified lines
1818
1919 //==============================================================================
2020
21−#include "leaf-globals.h"
21+#include "leaf-global.h"
2222 #include "leaf-math.h"
2323
2424 //==============================================================================
LEAF/Inc/leaf-delay.h+47−48
@@ -7,18 +7,17 @@ · 6 unmodified lines
77 ==============================================================================*/
88
99 #ifndef LEAF_DELAY_H_INCLUDED
10−#define LEAF_DELAY_H_INCLUDED
11−
12−#ifdef __cplusplus
13−extern "C" {
10+#define LEAF_DELAY_H_INCLUDED
11+
12+#ifdef __cplusplus
13+extern "C" {
1414 #endif
1515
16−//==============================================================================
16+//==============================================================================
1717
18−#include "leaf-globals.h"
1918 #include "leaf-math.h"
2019
21−//==============================================================================
20+//==============================================================================
2221
2322 /* Non-interpolating delay, reimplemented from STK (Cook and Scavone). */
2423 typedef struct _tDelay
@@ -46,7 +45,7 @@ float tDelay_tick (tDelay* const, float sample); · 21 unmodified lines
4645 float tDelay_getLastOut (tDelay* const);
4746 float tDelay_getLastIn (tDelay* const);
4847
49−//==============================================================================
48+//==============================================================================
5049
5150 /* Linearly-interpolating delay, reimplemented from STK (Cook and Scavone). */
5251 typedef struct _tDelayL
@@ -80,7 +79,7 @@ float tDelayL_tickOut (tDelayL* const d); · 27 unmodified lines
8079 float tDelayL_getLastOut (tDelayL* const);
8180 float tDelayL_getLastIn (tDelayL* const);
8281
83−//==============================================================================
82+//==============================================================================
8483
8584 /* Allpass-interpolating delay, reimplemented from STK (Cook and Scavone). */
8685 typedef struct _tDelayA
@@ -103,7 +102,7 @@ typedef struct _tDelayA · 16 unmodified lines
103102 } tDelayA;
104103
105104 void tDelayA_init (tDelayA* const, float delay, uint32_t maxDelay);
106−void tDelayA_free (tDelayA* const);
105+void tDelayA_free (tDelayA* const);
107106
108107 int tDelayA_setDelay (tDelayA* const, float delay);
109108 float tDelayA_getDelay (tDelayA* const);
@@ -114,44 +113,44 @@ float tDelayA_tick (tDelayA* const, float sample); · 4 unmodified lines
114113 float tDelayA_getLastOut (tDelayA* const);
115114 float tDelayA_getLastIn (tDelayA* const);
116115
117−//==============================================================================
118−
119−/* Linear interpolating delay with fixed read and write pointers, variable rate. */
120−typedef struct _tTapeDelay
121−{
122− float gain;
123− float* buff;
124−
125− float lastOut, lastIn;
126−
127− uint32_t inPoint;
128−
129− uint32_t maxDelay;
130−
131− float delay, inc, idx;
132−
133− float apInput;
134−
135−} tTapeDelay;
136−
137−void tTapeDelay_init (tTapeDelay* const, float delay, uint32_t maxDelay);
138−void tTapeDelay_free (tTapeDelay* const);
139−
140−int tTapeDelay_setDelay (tTapeDelay* const, float delay);
141−float tTapeDelay_getDelay (tTapeDelay* const);
142−void tTapeDelay_tapIn (tTapeDelay* const, float in, uint32_t tapDelay);
143−float tTapeDelay_tapOut (tTapeDelay* const d, float tapDelay);
144−float tTapeDelay_addTo (tTapeDelay* const, float value, uint32_t tapDelay);
145−float tTapeDelay_tick (tTapeDelay* const, float sample);
146−float tTapeDelay_getLastOut (tTapeDelay* const);
147−float tTapeDelay_getLastIn (tTapeDelay* const);
148−
149−//==============================================================================
150−
151−#ifdef __cplusplus
152−}
116+//==============================================================================
117+
118+/* Linear interpolating delay with fixed read and write pointers, variable rate. */
119+typedef struct _tTapeDelay
120+{
121+ float gain;
122+ float* buff;
123+
124+ float lastOut, lastIn;
125+
126+ uint32_t inPoint;
127+
128+ uint32_t maxDelay;
129+
130+ float delay, inc, idx;
131+
132+ float apInput;
133+
134+} tTapeDelay;
135+
136+void tTapeDelay_init (tTapeDelay* const, float delay, uint32_t maxDelay);
137+void tTapeDelay_free (tTapeDelay* const);
138+
139+int tTapeDelay_setDelay (tTapeDelay* const, float delay);
140+float tTapeDelay_getDelay (tTapeDelay* const);
141+void tTapeDelay_tapIn (tTapeDelay* const, float in, uint32_t tapDelay);
142+float tTapeDelay_tapOut (tTapeDelay* const d, float tapDelay);
143+float tTapeDelay_addTo (tTapeDelay* const, float value, uint32_t tapDelay);
144+float tTapeDelay_tick (tTapeDelay* const, float sample);
145+float tTapeDelay_getLastOut (tTapeDelay* const);
146+float tTapeDelay_getLastIn (tTapeDelay* const);
147+
148+//==============================================================================
149+
150+#ifdef __cplusplus
151+}
153152 #endif
154153
155−#endif // LEAF_DELAY_H_INCLUDED
156−
154+#endif // LEAF_DELAY_H_INCLUDED
155+
157156 //==============================================================================
LEAF/Inc/leaf-filter.h+0−3
@@ -15,11 +15,8 @@ extern "C" { · 14 unmodified lines
1515
1616 //==============================================================================
1717
18−#include "leaf-globals.h"
1918 #include "leaf-math.h"
20−
2119 #include "leaf-delay.h"
22−
2320 #include "leaf-tables.h"
2421
2522 //==============================================================================
LEAF/Inc/leaf-formant.h+2−1
@@ -15,7 +15,8 @@ extern "C" { · 14 unmodified lines
1515
1616 //==============================================================================
1717
18−#include "leaf-globals.h"
18+#include "leaf-global.h"
19+#include "leaf-mempool.h"
1920 #include "leaf-math.h"
2021
2122 //==============================================================================
LEAF/Inc/leaf-global.h+37−0
@@ -0,0 +1,37 @@
1+/*
2+ ==============================================================================
3+
4+ leaf-global.h
5+ Created: 24 Oct 2019 2:24:38pm
6+ Author: Matthew Wang
7+
8+ ==============================================================================
9+*/
10+
11+#ifndef LEAF_GLOBAL_H_INCLUDED
12+#define LEAF_GLOBAL_H_INCLUDED
13+
14+#ifdef __cplusplus
15+extern "C" {
16+#endif
17+
18+typedef struct _LEAF
19+{
20+ float sampleRate;
21+ float invSampleRate;
22+ int blockSize;
23+
24+ float (*random)(void);
25+} LEAF;
26+
27+extern LEAF leaf; // The global instance of LEAF.
28+
29+ //==============================================================================
30+
31+#ifdef __cplusplus
32+}
33+#endif
34+
35+#endif // LEAF_GLOBAL_H_INCLUDED
36+
37+//==============================================================================
LEAF/Inc/leaf-globals.h+0−61
@@ -1,61 +0,0 @@
1−/*==============================================================================
2−
3− leaf-globals.h
4− Created: 23 Jan 2017 10:34:10pm
5− Author: Michael R Mulshine
6−
7−==============================================================================*/
8−
9−#ifndef LEAF_GLOBALS_H_INCLUDED
10−#define LEAF_GLOBALS_H_INCLUDED
11−
12−#ifdef __cplusplus
13−extern "C" {
14−#endif
15−
16−//==============================================================================
17−
18−#include "leaf-mempool.h"
19−
20−//==============================================================================
21−
22−typedef struct _LEAF
23−{
24− float sampleRate;
25− float invSampleRate;
26− int blockSize;
27−
28−
29− float* sinewave;
30− float* sawtooth[11];
31− float* square[11];
32− float* triangle[11];
33−
34−
35− float (*random)(void);
36−} LEAF;
37−
38−//==============================================================================
39−
40−extern LEAF leaf; // The global instance of LEAF.
41−
42−//==============================================================================
43−
44−#define PS_FRAME_SIZE 1024 // SNAC_FRAME_SIZE in leaf-pitch.h should match (or be smaller than?) this
45−#define ENV_WINDOW_SIZE 1024
46−#define ENV_HOP_SIZE 256
47−
48−union unholy_t { /* a union between a float and an integer */
49− float f;
50− int i;
51−};
52−
53−//==============================================================================
54−
55−#ifdef __cplusplus
56−}
57−#endif
58−
59−#endif // LEAF_GLOBALS_H_INCLUDED
60−
61−//==============================================================================
LEAF/Inc/leaf-math.h+7−0
@@ -13,6 +13,7 @@ · 12 unmodified lines
1313 extern "C" {
1414 #endif
1515
16+#include "leaf-global.h"
1617 #include "math.h"
1718 #include "stdint.h"
1819 #include "stdlib.h"
@@ -26,6 +27,12 @@ typedef enum oBool · 7 unmodified lines
2627 OTRUE = 1,
2728 OFALSE = 0
2829 }oBool;
30+
31+// Allows for bitwise operations on floats
32+union unholy_t { /* a union between a float and an integer */
33+ float f;
34+ int i;
35+};
2936
3037 #define SQRT8 2.82842712475f
3138 #define WSCALE 1.30612244898f
LEAF/Inc/leaf-mempool.h+0−3
@@ -50,9 +50,6 @@ extern "C" { · 49 unmodified lines
5050
5151 //==============================================================================
5252
53−
54−#define MPOOL_POOL_SIZE 50 000
55−
5653 #define MPOOL_ALIGN_SIZE (8)
5754
5855 //#define size_t unsigned long
LEAF/Inc/leaf-midi.h+3−3
@@ -15,9 +15,9 @@ extern "C" { · 14 unmodified lines
1515
1616 //==============================================================================
1717
18−#include "leaf-globals.h"
18+#include "leaf-global.h"
19+#include "leaf-mempool.h"
1920 #include "leaf-math.h"
20−
2121 #include "leaf-utilities.h"
2222
2323 //==============================================================================
@@ -28,7 +28,7 @@ typedef struct _tPoly · 4 unmodified lines
2828 tStack stack;
2929 tStack orderStack;
3030
31− tRamp* ramp;
31+ tRamp* ramps;
3232 float* rampVals;
3333 oBool* firstReceived;
3434 float glideTime;
LEAF/Inc/leaf-oscillator.h+10−11
@@ -7,15 +7,14 @@ · 6 unmodified lines
77 ==============================================================================*/
88
99 #ifndef LEAF_OSCILLATOR_H_INCLUDED
10−#define LEAF_OSCILLATOR_H_INCLUDED
11−
12−#ifdef __cplusplus
13−extern "C" {
10+#define LEAF_OSCILLATOR_H_INCLUDED
11+
12+#ifdef __cplusplus
13+extern "C" {
1414 #endif
1515
1616 //==============================================================================
1717
18−#include "leaf-globals.h"
1918 #include "leaf-math.h"
2019
2120 #include "leaf-filter.h"
@@ -171,12 +170,12 @@ void tNoise_free (tNoise* const); · 149 unmodified lines
171170
172171 float tNoise_tick (tNoise* const);
173172
174−//==============================================================================
173+//==============================================================================
175174
176−#ifdef __cplusplus
177−}
178−#endif
175+#ifdef __cplusplus
176+}
177+#endif
179178
180−#endif // LEAF_OSCILLATOR_H_INCLUDED
181−
179+#endif // LEAF_OSCILLATOR_H_INCLUDED
180+
182181 //==============================================================================
LEAF/Inc/leaf-oversampler.h+2−1
@@ -16,7 +16,8 @@ extern "C" { · 15 unmodified lines
1616
1717 //==============================================================================
1818
19−#include "leaf-globals.h"
19+#include "leaf-global.h"
20+#include "leaf-mempool.h"
2021 #include "leaf-math.h"
2122 #include "leaf-filter.h"
2223
LEAF/Inc/leaf-pitch.h+2−2
@@ -17,12 +17,12 @@ extern "C" { · 16 unmodified lines
1717
1818 //==============================================================================
1919
20−#include "leaf-globals.h"
20+#include "leaf-global.h"
2121 #include "leaf-math.h"
2222
2323 #include "leaf-filter.h"
2424 #include "leaf-utilities.h"
25−#include "../leaf.h"
25+
2626 //==============================================================================
2727
2828 #define DEFPITCHRATIO 2.0f
LEAF/Inc/leaf-reverb.h+1−1
@@ -15,7 +15,7 @@ extern "C" { · 14 unmodified lines
1515
1616 //==============================================================================
1717
18−#include "leaf-globals.h"
18+#include "leaf-global.h"
1919 #include "leaf-math.h"
2020
2121 #include "leaf-delay.h"
LEAF/Inc/leaf-sample.h+1−1
@@ -16,7 +16,7 @@ extern "C" { · 15 unmodified lines
1616
1717 //==============================================================================
1818
19−#include "leaf-globals.h"
19+#include "leaf-global.h"
2020 #include "leaf-math.h"
2121
2222 #include "leaf-utilities.h"
LEAF/Inc/leaf-string.h+1−1
@@ -17,7 +17,7 @@ extern "C" { · 16 unmodified lines
1717
1818 //==============================================================================
1919
20−#include "leaf-globals.h"
20+#include "leaf-global.h"
2121 #include "leaf-math.h"
2222
2323 #include "leaf-delay.h"
LEAF/Inc/leaf-tables.h+0−1
@@ -15,7 +15,6 @@ extern "C" { · 14 unmodified lines
1515
1616 //==============================================================================
1717
18−#include "leaf-globals.h"
1918 #include "leaf-math.h"
2019
2120 //==============================================================================
LEAF/Inc/leaf-utilities.h+2−1
@@ -17,7 +17,6 @@ extern "C" { · 16 unmodified lines
1717
1818 // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
1919
20−#include "leaf-globals.h"
2120 #include "leaf-math.h"
2221 #include "leaf-filter.h"
2322 #include "leaf-delay.h"
@@ -369,6 +368,8 @@ int tAtkDtk_detect (tAtkDtk* const, float *in); · 345 unmodified lines
369368 // ENV~ from PD, modified for LEAF
370369 #define MAXOVERLAP 32
371370 #define INITVSTAKEN 64
371+#define ENV_WINDOW_SIZE 1024
372+#define ENV_HOP_SIZE 256
372373
373374 typedef struct _tEnv
374375 {
LEAF/Inc/leaf-vocoder.h+1−1
@@ -15,7 +15,7 @@ extern "C" { · 14 unmodified lines
1515
1616 //==============================================================================
1717
18−#include "leaf-globals.h"
18+#include "leaf-global.h"
1919 #include "leaf-math.h"
2020
2121 //==============================================================================
LEAF/Inc/leaf-wavefolder.h+1−1
@@ -16,7 +16,7 @@ extern "C" { · 15 unmodified lines
1616
1717 //==============================================================================
1818
19−#include "leaf-globals.h"
19+#include "leaf-global.h"
2020 #include "leaf-math.h"
2121
2222 //==============================================================================
LEAF/Src/leaf-808.c+133−93
@@ -16,16 +16,54 @@ · 15 unmodified lines
1616
1717 #endif
1818
19−#define USE_STICK 0
19+// ----------------- COWBELL ----------------------------//
20+
21+void t808Cowbell_init(t808Cowbell* const cowbell, int useStick) {
22+
23+ tSquare_init(&cowbell->p[0]);
24+ tSquare_setFreq(&cowbell->p[0], 540.0f);
25+
26+ tSquare_init(&cowbell->p[1]);
27+ tSquare_setFreq(&cowbell->p[1], 1.48148f * 540.0f);
28+
29+ cowbell->oscMix = 0.5f;
30+
31+ tSVF_init(&cowbell->bandpassOsc, SVFTypeBandpass, 2500, 1.0f);
32+
33+ tSVF_init(&cowbell->bandpassStick, SVFTypeBandpass, 1800, 1.0f);
34+
35+ tEnvelope_init(&cowbell->envGain, 5.0f, 100.0f, OFALSE);
36+
37+ tEnvelope_init(&cowbell->envFilter, 5.0, 100.0f, OFALSE);
38+
39+ tHighpass_init(&cowbell->highpass, 1000.0f);
40+
41+ tNoise_init(&cowbell->stick, WhiteNoise);
42+
43+ tEnvelope_init(&cowbell->envStick, 5.0f, 5.0f, 0);
44+
45+ cowbell->useStick = useStick;
46+}
47+
48+void t808Cowebell_free(t808Cowbell* const cowbell)
49+{
50+ tSquare_free(&cowbell->p[0]);
51+ tSquare_free(&cowbell->p[1]);
52+ tSVF_free(&cowbell->bandpassOsc);
53+ tSVF_free(&cowbell->bandpassStick);
54+ tEnvelope_free(&cowbell->envGain);
55+ tEnvelope_free(&cowbell->envFilter);
56+ tHighpass_free(&cowbell->highpass);
57+ tNoise_free(&cowbell->stick);
58+ tEnvelope_free(&cowbell->envStick);
59+}
60+
2061 void t808Cowbell_on(t808Cowbell* const cowbell, float vel)
2162 {
22−
2363 tEnvelope_on(&cowbell->envGain, vel);
2464
25−#if USE_STICK
26− tEnvelope_on(&cowbell->envStick,vel);
27−#endif
28−
65+ if (cowbell->useStick)
66+ tEnvelope_on(&cowbell->envStick,vel);
2967 }
3068
3169 float t808Cowbell_tick(t808Cowbell* const cowbell) {
@@ -41,9 +79,9 @@ float t808Cowbell_tick(t808Cowbell* const cowbell) { · 9 unmodified lines
4179
4280 sample *= (0.9f * tEnvelope_tick(&cowbell->envGain));
4381
44−#if USE_STICK
45− sample += (0.1f * tEnvelope_tick(&cowbell->envStick) * tSVF_tick(&cowbell->bandpassStick, tNoise_tick(&cowbell->stick)));
46−#endif
82+ if (cowbell->useStick)
83+ sample += (0.1f * tEnvelope_tick(&cowbell->envStick) * tSVF_tick(&cowbell->bandpassStick, tNoise_tick(&cowbell->stick)));
84+
4785
4886 sample = tHighpass_tick(&cowbell->highpass, sample);
4987
@@ -77,30 +115,61 @@ void t808Cowbell_setOscMix(t808Cowbell* const cowbell, float oscMix) · 27 unmodified lines
77115 cowbell->oscMix = oscMix;
78116 }
79117
80−void t808Cowbell_init(t808Cowbell* const cowbell) {
118+void t808Cowbell_setStick(t808Cowbell* const cowbell, int useStick)
119+{
120+ cowbell->useStick = useStick;
121+}
122+
123+// ----------------- HIHAT ----------------------------//
124+
125+void t808Hihat_init(t808Hihat* const hihat)
126+{
127+ for (int i = 0; i < 6; i++)
128+ {
129+ tSquare_init(&hihat->p[i]);
130+ }
81131
82− tSquare_init(&cowbell->p[0]);
83− tSquare_setFreq(&cowbell->p[0], 540.0f);
132+ tNoise_init(&hihat->stick, PinkNoise);
133+ tNoise_init(&hihat->n, WhiteNoise);
84134
85− tSquare_init(&cowbell->p[1]);
86− tSquare_setFreq(&cowbell->p[1], 1.48148f * 540.0f);
135+ // need to fix SVF to be generic
136+ tSVF_init(&hihat->bandpassStick, SVFTypeBandpass,2500.0f,1.2f);
137+ tSVF_init(&hihat->bandpassOsc, SVFTypeBandpass,3500.0f,0.3f);
87138
88− cowbell->oscMix = 0.5f;
139+ tEnvelope_init(&hihat->envGain, 0.0f, 50.0f, OFALSE);
140+ tEnvelope_init(&hihat->envStick, 0.0f, 7.0f, OFALSE);
89141
90− tSVF_init(&cowbell->bandpassOsc, SVFTypeBandpass, 2500, 1.0f);
91142
92− tSVF_init(&cowbell->bandpassStick, SVFTypeBandpass, 1800, 1.0f);
143+ tHighpass_init(&hihat->highpass, 7000.0f);
93144
94− tEnvelope_init(&cowbell->envGain, 5.0f, 100.0f, OFALSE);
145+ hihat->freq = 40.0f;
146+ hihat->stretch = 0.0f;
95147
96− tEnvelope_init(&cowbell->envFilter, 5.0, 100.0f, OFALSE);
148+ tSquare_setFreq(&hihat->p[0], 2.0f * hihat->freq);
149+ tSquare_setFreq(&hihat->p[1], 3.00f * hihat->freq);
150+ tSquare_setFreq(&hihat->p[2], 4.16f * hihat->freq);
151+ tSquare_setFreq(&hihat->p[3], 5.43f * hihat->freq);
152+ tSquare_setFreq(&hihat->p[4], 6.79f * hihat->freq);
153+ tSquare_setFreq(&hihat->p[5], 8.21f * hihat->freq);
154+}
155+
156+void t808Hihat_free(t808Hihat* const hihat)
157+{
158+ for (int i = 0; i < 6; i++)
159+ {
160+ tSquare_free(&hihat->p[i]);
161+ }
97162
98− tHighpass_init(&cowbell->highpass, 1000.0f);
163+ tNoise_free(&hihat->stick);
164+ tNoise_free(&hihat->n);
99165
100−#if USE_STICK
101− tNoise_init(&cowbell->stick, NoiseTypeWhite);
102− tEnvelope_init(&cowbell->envStick, 5.0f, 5.0f, 0);
103−#endif
166+ // need to fix SVF to be generic
167+ tSVF_free(&hihat->bandpassStick);
168+ tSVF_free(&hihat->bandpassOsc);
169+ tEnvelope_free(&hihat->envGain);
170+ tEnvelope_free(&hihat->envStick);
171+
172+ tHighpass_free(&hihat->highpass);
104173 }
105174
106175 void t808Hihat_on(t808Hihat* const hihat, float vel) {
@@ -198,35 +267,50 @@ void t808Hihat_setOscFreq(t808Hihat* const hihat, float freq) · 91 unmodified lines
198267 hihat->freq = freq;
199268 }
200269
201−void t808Hihat_init(t808Hihat* const hihat)
270+// ----------------- SNARE ----------------------------//
271+
272+void t808Snare_init(t808Snare* const snare)
202273 {
203− for (int i = 0; i < 6; i++)
274+ float ratio[2] = {1.0, 1.5};
275+ for (int i = 0; i < 2; i++)
204276 {
205− tSquare_init(&hihat->p[i]);
277+ tTriangle_init(&snare->tone[i]);
278+
279+ tTriangle_setFreq(&snare->tone[i], ratio[i] * 400.0f);
280+ tSVF_init(&snare->toneLowpass[i], SVFTypeLowpass, 4000, 1.0f);
281+ tEnvelope_init(&snare->toneEnvOsc[i], 0.0f, 50.0f, OFALSE);
282+ tEnvelope_init(&snare->toneEnvGain[i], 1.0f, 150.0f, OFALSE);
283+ tEnvelope_init(&snare->toneEnvFilter[i], 1.0f, 2000.0f, OFALSE);
284+
285+ snare->toneGain[i] = 0.5f;
206286 }
207287
208− tNoise_init(&hihat->stick, PinkNoise);
209− tNoise_init(&hihat->n, WhiteNoise);
210−
211− // need to fix SVF to be generic
212− tSVF_init(&hihat->bandpassStick, SVFTypeBandpass,2500.0f,1.2f);
213− tSVF_init(&hihat->bandpassOsc, SVFTypeBandpass,3500.0f,0.3f);
214−
215− tEnvelope_init(&hihat->envGain, 0.0f, 50.0f, OFALSE);
216− tEnvelope_init(&hihat->envStick, 0.0f, 7.0f, OFALSE);
217−
288+ snare->tone1Freq = ratio[0] * 100.0f;
289+ snare->tone2Freq = ratio[1] * 100.0f;
290+ snare->noiseFilterFreq = 3000.0f;
291+ tNoise_init(&snare->noiseOsc, WhiteNoise);
292+ tSVF_init(&snare->noiseLowpass, SVFTypeLowpass, 12000.0f, 0.8f);
293+ tEnvelope_init(&snare->noiseEnvGain, 0.0f, 100.0f, OFALSE);
294+ tEnvelope_init(&snare->noiseEnvFilter, 0.0f, 1000.0f, OFALSE);
295+ snare->noiseGain = 1.0f;
296+}
218297
219− tHighpass_init(&hihat->highpass, 7000.0f);
298+void t808Snare_free (t808Snare* const snare)
299+{
300+ for (int i = 0; i < 2; i++)
301+ {
302+ tTriangle_free(&snare->tone[i]);
303+ tSVF_free(&snare->toneLowpass[i]);
304+ tEnvelope_free(&snare->toneEnvOsc[i]);
305+ tEnvelope_free(&snare->toneEnvGain[i]);
306+ tEnvelope_free(&snare->toneEnvFilter[i]);
307+ }
220308
221− hihat->freq = 40.0f;
222− hihat->stretch = 0.0f;
223−
224− tSquare_setFreq(&hihat->p[0], 2.0f * hihat->freq);
225− tSquare_setFreq(&hihat->p[1], 3.00f * hihat->freq);
226− tSquare_setFreq(&hihat->p[2], 4.16f * hihat->freq);
227− tSquare_setFreq(&hihat->p[3], 5.43f * hihat->freq);
228− tSquare_setFreq(&hihat->p[4], 6.79f * hihat->freq);
229− tSquare_setFreq(&hihat->p[5], 8.21f * hihat->freq);
309+
310+ tNoise_free(&snare->noiseOsc);
311+ tSVF_free(&snare->noiseLowpass);
312+ tEnvelope_free(&snare->noiseEnvGain);
313+ tEnvelope_free(&snare->noiseEnvFilter);
230314 }
231315
232316 void t808Snare_on(t808Snare* const snare, float vel)
@@ -285,7 +369,6 @@ void t808Snare_setNoiseFilterQ(t808Snare* const snare, float noiseFilterQ) · 52 unmodified lines
285369 tSVF_setQ(&snare->noiseLowpass, noiseFilterQ);
286370 }
287371
288−
289372 static float tone[2];
290373
291374 float t808Snare_tick(t808Snare* const snare)
@@ -308,50 +391,7 @@ float t808Snare_tick(t808Snare* const snare) · 16 unmodified lines
308391 return sample;
309392 }
310393
311−void t808Snare_init(t808Snare* const snare)
312−{
313− float ratio[2] = {1.0, 1.5};
314− for (int i = 0; i < 2; i++)
315− {
316− tTriangle_init(&snare->tone[i]);
317−
318− tTriangle_setFreq(&snare->tone[i], ratio[i] * 400.0f);
319− tSVF_init(&snare->toneLowpass[i], SVFTypeLowpass, 4000, 1.0f);
320− tEnvelope_init(&snare->toneEnvOsc[i], 0.0f, 50.0f, OFALSE);
321− tEnvelope_init(&snare->toneEnvGain[i], 1.0f, 150.0f, OFALSE);
322− tEnvelope_init(&snare->toneEnvFilter[i], 1.0f, 2000.0f, OFALSE);
323−
324− snare->toneGain[i] = 0.5f;
325− }
326−
327− snare->tone1Freq = ratio[0] * 100.0f;
328− snare->tone2Freq = ratio[1] * 100.0f;
329− snare->noiseFilterFreq = 3000.0f;
330− tNoise_init(&snare->noiseOsc, WhiteNoise);
331− tSVF_init(&snare->noiseLowpass, SVFTypeLowpass, 12000.0f, 0.8f);
332− tEnvelope_init(&snare->noiseEnvGain, 0.0f, 100.0f, OFALSE);
333− tEnvelope_init(&snare->noiseEnvFilter, 0.0f, 1000.0f, OFALSE);
334− snare->noiseGain = 1.0f;
335−}
336−
337−void t808Snare_free (t808Snare* const snare)
338−{
339− for (int i = 0; i < 2; i++)
340− {
341− tTriangle_free(&snare->tone[i]);
342− tSVF_free(&snare->toneLowpass[i]);
343− tEnvelope_free(&snare->toneEnvOsc[i]);
344− tEnvelope_free(&snare->toneEnvGain[i]);
345− tEnvelope_free(&snare->toneEnvFilter[i]);
346− }
347−
348−
349− tNoise_free(&snare->noiseOsc);
350− tSVF_free(&snare->noiseLowpass);
351− tEnvelope_free(&snare->noiseEnvGain);
352− tEnvelope_free(&snare->noiseEnvFilter);
353−}
354−
394+// ----------------- KICK ----------------------------//
355395
356396 void t808Kick_init (t808Kick* const kick)
357397 {
@@ -369,7 +409,6 @@ void t808Kick_init (t808Kick* const kick) · 11 unmodified lines
369409 kick->noiseGain = 0.3f;
370410 }
371411
372−
373412 void t808Kick_free (t808Kick* const kick)
374413 {
375414 tCycle_free(&kick->tone);
@@ -410,6 +449,7 @@ void t808Kick_setToneDecay (t808Kick* const kick, float decay) · 34 unmodified lines
410449 tEnvelope_setDecay(&kick->toneEnvGain,decay);
411450 tEnvelope_setDecay(&kick->toneEnvGain,decay * 3.0f);
412451 }
452+
413453 void t808Kick_setNoiseDecay (t808Kick* const kick, float decay);
414454 void t808Kick_setSighAmount (t808Kick* const kick, float sigh);
415455 void t808Kick_setChirpAmount (t808Kick* const kick, float chirp);
LEAF/Src/leaf-WDF.c+1−1
@@ -154,7 +154,7 @@ void tWDF_init(tWDF* const r, WDFComponentType type, float value, tWDF* const rL · 153 unmodified lines
154154
155155 void tWDF_free(tWDF* const r)
156156 {
157− leaf_free(r);
157+
158158 }
159159
160160 float tWDF_tick(tWDF* const r, float sample, tWDF* const outputPoint, uint8_t paramsChanged)
LEAF/Src/leaf-crusher.c+1−1
@@ -32,7 +32,7 @@ void tCrusher_init (tCrusher* const c) · 31 unmodified lines
3232
3333 void tCrusher_free (tCrusher* const c)
3434 {
35− leaf_free(c);
35+
3636 }
3737
3838 float tCrusher_tick (tCrusher* const c, float input)
LEAF/Src/leaf-delay.c+0−4
@@ -41,7 +41,6 @@ void tDelay_init (tDelay* const d, uint32_t delay, uint32_t maxDelay) · 40 unmodified lines
4141 void tDelay_free(tDelay* const d)
4242 {
4343 leaf_free(d->buff);
44− leaf_free(d);
4544 }
4645
4746 float tDelay_tick (tDelay* const d, float input)
@@ -153,7 +152,6 @@ void tDelayL_init (tDelayL* const d, float delay, uint32_t maxDelay) · 105 unmodified lines
153152 void tDelayL_free(tDelayL* const d)
154153 {
155154 leaf_free(d->buff);
156− leaf_free(d);
157155 }
158156
159157 float tDelayL_tick (tDelayL* const d, float input)
@@ -319,7 +317,6 @@ void tDelayA_init (tDelayA* const d, float delay, uint32_t maxDelay) · 159 unmodified lines
319317 void tDelayA_free(tDelayA* const d)
320318 {
321319 leaf_free(d->buff);
322− leaf_free(d);
323320 }
324321
325322 float tDelayA_tick (tDelayA* const d, float input)
@@ -455,7 +452,6 @@ void tTapeDelay_init (tTapeDelay* const d, float delay, uint32_t maxDelay) · 129 unmodified lines
455452 void tTapeDelay_free(tTapeDelay* const d)
456453 {
457454 leaf_free(d->buff);
458− leaf_free(d);
459455 }
460456
461457 //#define SMOOTH_FACTOR 10.f
LEAF/Src/leaf-filter.c+30−29
@@ -30,15 +30,14 @@ void tAllpass_init(tAllpass* const f, float initDelay, uint32_t maxDelay) · 29 unmodified lines
3030 tDelayL_init(&f->delay, initDelay, maxDelay);
3131 }
3232
33−void tAllpass_setDelay(tAllpass* const f, float delay)
33+void tAllpass_free(tAllpass* const f)
3434 {
35− tDelayL_setDelay(&f->delay, delay);
35+ tDelayL_free(&f->delay);
3636 }
3737
38−void tAllpass_free(tAllpass* const f)
38+void tAllpass_setDelay(tAllpass* const f, float delay)
3939 {
40− leaf_free(&f->delay);
41− leaf_free(f);
40+ tDelayL_setDelay(&f->delay, delay);
4241 }
4342
4443 void tAllpass_setGain(tAllpass* const f, float gain)
@@ -81,8 +80,6 @@ void tButterworth_free(tButterworth* const f) · 36 unmodified lines
8180 tSVF_free(&f->low[i]);
8281 tSVF_free(&f->high[i]);
8382 }
84−
85− leaf_free(f);
8683 }
8784
8885 float tButterworth_tick(tButterworth* const f, float samp)
@@ -129,7 +126,7 @@ void tOneZero_init(tOneZero* const f, float theZero) · 40 unmodified lines
129126
130127 void tOneZero_free(tOneZero* const f)
131128 {
132− leaf_free(f);
129+
133130 }
134131
135132 float tOneZero_tick(tOneZero* const f, float input)
@@ -210,7 +207,7 @@ void tTwoZero_init(tTwoZero* const f) · 74 unmodified lines
210207
211208 void tTwoZero_free(tTwoZero* const f)
212209 {
213− leaf_free(f);
210+
214211 }
215212
216213 float tTwoZero_tick(tTwoZero* const f, float input)
@@ -287,7 +284,7 @@ void tOnePole_init(tOnePole* const f, float freq) · 70 unmodified lines
287284
288285 void tOnePole_free(tOnePole* const f)
289286 {
290− leaf_free(f);
287+
291288 }
292289
293290 void tOnePole_setB0(tOnePole* const f, float b0)
@@ -359,7 +356,7 @@ void tTwoPole_init(tTwoPole* const f) · 65 unmodified lines
359356
360357 void tTwoPole_free(tTwoPole* const f)
361358 {
362− leaf_free(f);
359+
363360 }
364361
365362 float tTwoPole_tick(tTwoPole* const f, float input)
@@ -450,7 +447,7 @@ void tPoleZero_init(tPoleZero* const f) · 84 unmodified lines
450447
451448 void tPoleZero_free(tPoleZero* const f)
452449 {
453− leaf_free(f);
450+
454451 }
455452
456453 void tPoleZero_setB0(tPoleZero* const pzf, float b0)
@@ -543,7 +540,7 @@ void tBiQuad_init(tBiQuad* const f) · 86 unmodified lines
543540
544541 void tBiQuad_free(tBiQuad* const f)
545542 {
546− leaf_free(f);
543+
547544 }
548545
549546 float tBiQuad_tick(tBiQuad* const f, float input)
@@ -655,6 +652,20 @@ void tBiQuadSampleRateChanged(tBiQuad* const f) · 105 unmodified lines
655652 }
656653
657654 /* Highpass */
655+void tHighpass_init(tHighpass* const f, float freq)
656+{
657+ f->R = (1.0f-((freq * 2.0f * 3.14f)* leaf.invSampleRate));
658+ f->ys = 0.0f;
659+ f->xs = 0.0f;
660+
661+ f->frequency = freq;
662+}
663+
664+void tHighpass_free(tHighpass* const f)
665+{
666+
667+}
668+
658669 void tHighpass_setFreq(tHighpass* const f, float freq)
659670 {
660671 f->frequency = freq;
@@ -675,20 +686,6 @@ float tHighpass_tick(tHighpass* const f, float x) · 14 unmodified lines
675686 return f->ys;
676687 }
677688
678−void tHighpass_init(tHighpass* const f, float freq)
679−{
680− f->R = (1.0f-((freq * 2.0f * 3.14f)* leaf.invSampleRate));
681− f->ys = 0.0f;
682− f->xs = 0.0f;
683−
684− f->frequency = freq;
685−}
686−
687−void tHighpass_free(tHighpass* const f)
688−{
689− leaf_free(f);
690−}
691−
692689 void tHighpassSampleRateChanged(tHighpass* const f)
693690 {
694691 f->R = (1.0f-((f->frequency * 2.0f * 3.14f) * leaf.invSampleRate));
@@ -737,7 +734,7 @@ void tSVF_init(tSVF* const svf, SVFType type, float freq, float Q) · 42 unmodified lines
737734
738735 void tSVF_free(tSVF* const svf)
739736 {
740− leaf_free(svf);
737+
741738 }
742739
743740 int tSVF_setFreq(tSVF* const svf, float freq)
@@ -782,6 +779,11 @@ void tSVFE_init(tSVFE* const svf, SVFType type, uint16_t input, float Q) · 38 unmodified lines
782779 svf->a3 = a3;
783780 }
784781
782+void tSVFE_free(tSVFE* const svf)
783+{
784+
785+}
786+
785787 float tSVFE_tick(tSVFE* const svf, float v0)
786788 {
787789 float v1,v2,v3;
@@ -838,5 +840,4 @@ float tFIR_tick(tFIR* const fir, float input){ · 50 unmodified lines
838840 void tFIR_free(tFIR* const fir)
839841 {
840842 leaf_free(fir->past);
841− leaf_free(fir);
842843 }
LEAF/Src/leaf-formant.c+0−2
@@ -61,8 +61,6 @@ void tFormantShifter_free(tFormantShifter* const fs) · 60 unmodified lines
6161 leaf_free(fs->fbuff[i]);
6262 }
6363 leaf_free(fs->fbuff);
64−
65− leaf_free(fs);
6664 }
6765
6866
LEAF/Src/leaf-mempool.c+1−0
@@ -48,6 +48,7 @@ · 47 unmodified lines
4848
4949 #endif
5050
51+// This might be too low.
5152 #define NUM_BLOCKS 50
5253
5354 mpool_pool_t blocks[NUM_BLOCKS];
LEAF/Src/leaf-midi.c+12−14
@@ -37,7 +37,7 @@ void tPoly_init(tPoly* const poly, int maxNumVoices) · 36 unmodified lines
3737
3838 poly->glideTime = 5.0f;
3939
40− poly->ramp = (tRamp*) leaf_alloc(sizeof(tRamp) * poly->maxNumVoices);
40+ poly->ramps = (tRamp*) leaf_alloc(sizeof(tRamp) * poly->maxNumVoices);
4141 poly->rampVals = (float*) leaf_alloc(sizeof(float) * poly->maxNumVoices);
4242 poly->firstReceived = (oBool*) leaf_alloc(sizeof(oBool) * poly->maxNumVoices);
4343 poly->voices = (int**) leaf_alloc(sizeof(int*) * poly->maxNumVoices);
@@ -48,7 +48,7 @@ void tPoly_init(tPoly* const poly, int maxNumVoices) · 4 unmodified lines
4848 poly->voices[i][0] = -1;
4949 poly->firstReceived[i] = OFALSE;
5050
51− tRamp_init(&poly->ramp[i], poly->glideTime, 1);
51+ tRamp_init(&poly->ramps[i], poly->glideTime, 1);
5252 }
5353
5454 poly->pitchBend = 0.0f;
@@ -64,7 +64,7 @@ void tPoly_free(tPoly* const poly) · 9 unmodified lines
6464 {
6565 for (int i = 0; i < poly->maxNumVoices; i++)
6666 {
67− tRamp_free(&poly->ramp[i]);
67+ tRamp_free(&poly->ramps[i]);
6868 leaf_free(poly->voices[i]);
6969 }
7070 tRamp_free(&poly->pitchBendRamp);
@@ -72,11 +72,9 @@ void tPoly_free(tPoly* const poly) · 1 unmodified line
7272 tStack_free(&poly->orderStack);
7373
7474 leaf_free(poly->voices);
75− leaf_free(poly->ramp);
75+ leaf_free(poly->ramps);
7676 leaf_free(poly->rampVals);
7777 leaf_free(poly->firstReceived);
78−
79−
8078 }
8179
8280 void tPoly_tickPitch(tPoly* poly)
@@ -89,7 +87,7 @@ void tPoly_tickPitchGlide(tPoly* poly) · 6 unmodified lines
8987 {
9088 for (int i = 0; i < poly->maxNumVoices; ++i)
9189 {
92− tRamp_tick(&poly->ramp[i]);
90+ tRamp_tick(&poly->ramps[i]);
9391 }
9492 }
9593
@@ -122,7 +120,7 @@ int tPoly_noteOn(tPoly* const poly, int note, uint8_t vel) · 26 unmodified lines
122120 {
123121 if (!poly->firstReceived[i] || !poly->pitchGlideIsActive)
124122 {
125− tRamp_setVal(&poly->ramp[i], note);
123+ tRamp_setVal(&poly->ramps[i], note);
126124 poly->firstReceived[i] = OTRUE;
127125 }
128126
@@ -134,7 +132,7 @@ int tPoly_noteOn(tPoly* const poly, int note, uint8_t vel) · 5 unmodified lines
134132 poly->notes[note][0] = vel;
135133 poly->notes[note][1] = i;
136134
137− tRamp_setDest(&poly->ramp[i], poly->voices[i][0]);
135+ tRamp_setDest(&poly->ramps[i], poly->voices[i][0]);
138136
139137 alteredVoice = i;
140138 break;
@@ -158,8 +156,8 @@ int tPoly_noteOn(tPoly* const poly, int note, uint8_t vel) · 17 unmodified lines
158156 poly->notes[note][0] = vel;
159157 poly->notes[note][1] = whichVoice;
160158
161− tRamp_setTime(&poly->ramp[whichVoice], poly->glideTime);
162− tRamp_setDest(&poly->ramp[whichVoice], poly->voices[whichVoice][0]);
159+ tRamp_setTime(&poly->ramps[whichVoice], poly->glideTime);
160+ tRamp_setDest(&poly->ramps[whichVoice], poly->voices[whichVoice][0]);
163161
164162 alteredVoice = whichVoice;
165163
@@ -214,7 +212,7 @@ int tPoly_noteOff(tPoly* const poly, uint8_t note) · 48 unmodified lines
214212 if (poly->notes[noteToTest][1] < 0) //if there is a stolen note waiting (marked inactive but on the stack)
215213 {
216214 poly->voices[deactivatedVoice][0] = noteToTest; //set the newly free voice to use the old stolen note
217− tRamp_setDest(&poly->ramp[deactivatedVoice], poly->voices[deactivatedVoice][0]);
215+ tRamp_setDest(&poly->ramps[deactivatedVoice], poly->voices[deactivatedVoice][0]);
218216 poly->voices[deactivatedVoice][1] = poly->notes[noteToTest][0]; // set the velocity of the voice to be the velocity of that note
219217 poly->notes[noteToTest][1] = deactivatedVoice; //mark that it is no longer stolen and is now active
220218 return -1;
@@ -278,7 +276,7 @@ void tPoly_setPitchGlideTime(tPoly* const poly, float t) · 57 unmodified lines
278276 poly->glideTime = t;
279277 for (int i = 0; i < poly->maxNumVoices; ++i)
280278 {
281− tRamp_setTime(&poly->ramp[i], poly->glideTime);
279+ tRamp_setTime(&poly->ramps[i], poly->glideTime);
282280 }
283281 }
284282
@@ -289,7 +287,7 @@ int tPoly_getNumVoices(tPoly* const poly) · 4 unmodified lines
289287
290288 float tPoly_getPitch(tPoly* const poly, uint8_t voice)
291289 {
292− return tRamp_sample(&poly->ramp[voice]) + tRamp_sample(&poly->pitchBendRamp);
290+ return tRamp_sample(&poly->ramps[voice]) + tRamp_sample(&poly->pitchBendRamp);
293291 }
294292
295293 int tPoly_getKey(tPoly* const poly, uint8_t voice)
LEAF/Src/leaf-oscillator.c+17−16
@@ -57,8 +57,6 @@ void tNeuron_init(tNeuron* const n) · 56 unmodified lines
5757 void tNeuron_free(tNeuron* const n)
5858 {
5959 tPoleZero_free(&n->f);
60−
61− leaf_free(n);
6260 }
6361
6462 void tNeuron_reset(tNeuron* const n)
@@ -226,7 +224,7 @@ void tCycle_init(tCycle* const c) · 161 unmodified lines
226224
227225 void tCycle_free(tCycle* const c)
228226 {
229− leaf_free(c);
227+
230228 }
231229
232230 int tCycle_setFreq(tCycle* const c, float freq)
@@ -266,6 +264,17 @@ void tPhasorSampleRateChanged (tPhasor* const p) · 33 unmodified lines
266264 p->inc = p->freq * leaf.invSampleRate;
267265 };
268266
267+void tPhasor_init(tPhasor* const p)
268+{
269+ p->phase = 0.0f;
270+ p->inc = 0.0f;
271+}
272+
273+void tPhasor_free(tPhasor* const p)
274+{
275+
276+}
277+
269278 int tPhasor_setFreq(tPhasor* const p, float freq)
270279 {
271280 if (freq < 0.0f) freq = 0.0f;
@@ -285,16 +294,7 @@ float tPhasor_tick(tPhasor* const p) · 13 unmodified lines
285294 return p->phase;
286295 }
287296
288−void tPhasor_init(tPhasor* const p)
289−{
290− p->phase = 0.0f;
291− p->inc = 0.0f;
292−}
293297
294−void tPhasor_free(tPhasor* const p)
295−{
296− leaf_free(p);
297−}
298298
299299 void tSawtooth_init(tSawtooth* const c)
300300 {
@@ -304,7 +304,7 @@ void tSawtooth_init(tSawtooth* const c) · 3 unmodified lines
304304
305305 void tSawtooth_free(tSawtooth* const c)
306306 {
307− leaf_free(c);
307+
308308 }
309309
310310 int tSawtooth_setFreq(tSawtooth* const c, float freq)
@@ -411,7 +411,8 @@ void tTriangle_init(tTriangle* const c) · 100 unmodified lines
411411
412412 void tTriangle_free(tTriangle* const c)
413413 {
414− leaf_free(c);}
414+
415+}
415416
416417 int tTriangle_setFreq(tTriangle* const c, float freq)
417418 {
@@ -513,7 +514,7 @@ void tSquare_init(tSquare* const c) · 95 unmodified lines
513514
514515 void tSquare_free(tSquare* const c)
515516 {
516− leaf_free(c);
517+
517518 }
518519
519520 int tSquare_setFreq(tSquare* const c, float freq)
@@ -614,7 +615,7 @@ void tNoise_init(tNoise* const n, NoiseType type) · 94 unmodified lines
614615
615616 void tNoise_free(tNoise* const n)
616617 {
617− leaf_free(n);
618+
618619 }
619620
620621 float tNoise_tick(tNoise* const n)
LEAF/Src/leaf-oversampler.c+0−1
@@ -41,7 +41,6 @@ void tOversampler_free(tOversampler* const os) · 40 unmodified lines
4141 {
4242 leaf_free(os->upState);
4343 leaf_free(os->downState);
44− leaf_free(os);
4544 }
4645
4746 float tOversampler_tick(tOversampler* const os, float input, float (*effectTick)(float))
LEAF/Src/leaf-pitch.c+0−7
@@ -51,8 +51,6 @@ void tPitchShifter_free(tPitchShifter* const ps) · 50 unmodified lines
5151 tSNAC_free(&ps->snac);
5252 tSOLAD_free(&ps->sola);
5353 tHighpass_free(&ps->hp);
54−
55− leaf_free(ps);
5654 }
5755
5856 float tPitchShifter_tick(tPitchShifter* ps, float sample)
@@ -94,7 +92,6 @@ float tPitchShifter_tick(tPitchShifter* ps, float sample) · 35 unmodified lines
9492 tSOLAD_setPitchFactor(&ps->sola, ps->pitchFactor);
9593 tSOLAD_ioSamples(&ps->sola, &(ps->inBuffer[i]), &(ps->outBuffer[i]), ps->frameSize);
9694
97−
9895 }
9996
10097 return out;
@@ -368,8 +365,6 @@ void tPeriod_free (tPeriod* const p) · 267 unmodified lines
368365 {
369366 tEnv_free(&p->env);
370367 tSNAC_free(&p->snac);
371−
372− leaf_free(p);
373368 }
374369
375370 float tPeriod_findPeriod (tPeriod* p, float sample)
@@ -470,8 +465,6 @@ void tPitchShift_free(tPitchShift* const ps) · 94 unmodified lines
470465 {
471466 tSOLAD_free(&ps->sola);
472467 tHighpass_free(&ps->hp);
473−
474− leaf_free(ps);
475468 }
476469
477470 float tPitchShift_shift (tPitchShift* ps)
LEAF/Src/leaf-reverb.c+4−5
@@ -58,7 +58,6 @@ void tPRCRev_free(tPRCRev* const r) · 57 unmodified lines
5858 tDelay_free(&r->allpassDelays[0]);
5959 tDelay_free(&r->allpassDelays[1]);
6060 tDelay_free(&r->combDelay);
61− leaf_free(r);
6261 }
6362
6463 void tPRCRev_setT60(tPRCRev* const r, float t60)
@@ -167,8 +166,6 @@ void tNRev_free(tNRev* const r) · 102 unmodified lines
167166 {
168167 tDelay_free(&r->allpassDelays[i]);
169168 }
170−
171− leaf_free(r);
172169 }
173170
174171 void tNRev_setT60(tNRev* const r, float t60)
@@ -334,6 +331,8 @@ void tDattorro_free (tDattorro* const r) · 159 unmodified lines
334331
335332 tOnePole_free(&r->f1_filter);
336333
334+ tHighpass_free(&r->f2_hp);
335+
337336 tCycle_free(&r->f1_lfo);
338337
339338 // FEEDBACK 2
@@ -345,9 +344,9 @@ void tDattorro_free (tDattorro* const r) · 5 unmodified lines
345344
346345 tOnePole_free(&r->f2_filter);
347346
348− tCycle_free(&r->f2_lfo);
347+ tHighpass_free(&r->f2_hp);
349348
350− leaf_free(r);
349+ tCycle_free(&r->f2_lfo);
351350 }
352351
353352 float tDattorro_tick (tDattorro* const r, float input)
LEAF/Src/leaf-sample.c+0−2
@@ -39,7 +39,6 @@ void tBuffer_init (tBuffer* const s, uint32_t length) · 38 unmodified lines
3939 void tBuffer_free (tBuffer* const s)
4040 {
4141 leaf_free(s->buff);
42− leaf_free(s);
4342 }
4443
4544 void tBuffer_tick (tBuffer* const s, float sample)
@@ -136,7 +135,6 @@ void tSampler_init(tSampler* const p, tBuffer* const s) · 90 unmodified lines
136135 void tSampler_free (tSampler* const p)
137136 {
138137 tRamp_free(&p->gain);
139− leaf_free(p);
140138 }
141139
142140 float tSampler_tick (tSampler* const p)
LEAF/Src/leaf-string.c+0−4
@@ -38,8 +38,6 @@ void tPluck_free (tPluck* const p) · 37 unmodified lines
3838 tOnePole_free(&p->pickFilter);
3939 tOneZero_free(&p->loopFilter);
4040 tDelayA_free(&p->delayLine);
41−
42− leaf_free(p);
4341 }
4442
4543 float tPluck_getLastOut (tPluck *p)
@@ -149,8 +147,6 @@ void tStifKarp_free (tStifKarp* const p) · 103 unmodified lines
149147 {
150148 tBiQuad_free(&p->biquad[i]);
151149 }
152−
153− leaf_free(p);
154150 }
155151
156152 float tStifKarp_getLastOut (tStifKarp* const p)
LEAF/Src/leaf-tables.c+2−2
@@ -3,11 +3,11 @@ · 2 unmodified lines
33 #if _WIN32 || _WIN64
44
55 #include "..\Inc\leaf-tables.h"
6−#include "..\Inc\leaf-globals.h"
6+#include "..\Inc\leaf-global.h"
77 #else
88
99 #include "../Inc/leaf-tables.h"
10−#include "../Inc/leaf-globals.h"
10+#include "../Inc/leaf-global.h"
1111
1212 #endif
1313
LEAF/Src/leaf-utilities.c+84−16
@@ -126,7 +126,7 @@ void tEnv_init(tEnv* const x, int ws, int hs, int bs) · 125 unmodified lines
126126
127127 void tEnv_free (tEnv* const x)
128128 {
129− leaf_free(x);
129+
130130 }
131131
132132 float tEnv_tick (tEnv* const x)
@@ -204,6 +204,11 @@ void tCompressor_init(tCompressor* const c) · 71 unmodified lines
204204 c->W = 1.0f; // decibel Make-up gain
205205 }
206206
207+void tCompressor_free(tCompressor* const c)
208+{
209+
210+}
211+
207212 int ccount = 0;
208213 float tCompressor_tick(tCompressor* const c, float in)
209214 {
@@ -306,7 +311,7 @@ void tEnvelope_init(tEnvelope* const env, float attack, float decay, oBool lo · 96 unmodified lines
306311
307312 void tEnvelope_free(tEnvelope* const env)
308313 {
309− leaf_free(env);
314+
310315 }
311316
312317 int tEnvelope_setAttack(tEnvelope* const env, float attack)
@@ -498,6 +503,11 @@ void tADSR_init(tADSR* const adsr, float attack, float decay, float sustain, · 185 unmodified lines
498503 adsr->rampInc = adsr->inc_buff[rampIndex];
499504 }
500505
506+void tADSR_free(tADSR* const adsr)
507+{
508+
509+}
510+
501511 int tADSR_setAttack(tADSR* const adsr, float attack)
502512 {
503513 int32_t attackIndex;
@@ -683,6 +693,11 @@ void tEnvelopeFollower_init(tEnvelopeFollower* const e, float attackThreshold · 179 unmodified lines
683693 e->d_coeff = decayCoeff;
684694 }
685695
696+void tEnvelopeFollower_free(tEnvelopeFollower* const e)
697+{
698+
699+}
700+
686701 float tEnvelopeFollower_tick(tEnvelopeFollower* const ef, float x)
687702 {
688703 if (x < 0.0f ) x = -x; /* Absolute value. */
@@ -729,6 +744,11 @@ void tRamp_init(tRamp* const ramp, float time, int samples_per_tick) · 40 unmodified lines
729744 ramp->inc = ((ramp->dest - ramp->curr) / ramp->time * ramp->inv_sr_ms) * (float)ramp->samples_per_tick;
730745 }
731746
747+void tRamp_free(tRamp* const ramp)
748+{
749+
750+}
751+
732752 int tRamp_setTime(tRamp* const r, float time)
733753 {
734754 if (time < r->minimum_time)
@@ -791,6 +811,11 @@ void tExpSmooth_init(tExpSmooth* const smooth, float val, float factor) · 56 unmodified lines
791811 smooth->oneminusfactor=1.0f-factor;
792812 }
793813
814+void tExpSmooth_free(tExpSmooth* const smooth)
815+{
816+
817+}
818+
794819 int tExpSmooth_setFactor(tExpSmooth* const smooth, float factor)
795820 { // factor is usually a value between 0 and 0.1. Lower value is slower. 0.01 for example gives you a smoothing time of about 10ms
796821 if (factor<0)
@@ -835,6 +860,11 @@ void tPwrFollow_init(tPwrFollow* const p, float factor) · 38 unmodified lines
835860 p->oneminusfactor=1.0f-factor;
836861 }
837862
863+void tPwrFollow_free(tPwrFollow* const p)
864+{
865+
866+}
867+
838868 int tPwrFollow_setFactor(tPwrFollow* const p, float factor)
839869 {
840870 if (factor<0) factor=0;
@@ -866,6 +896,11 @@ void tFBleveller_init(tFBleveller* const p, float targetLevel, float factor, · 25 unmodified lines
866896 p->strength=strength;
867897 }
868898
899+void tFBleveller_free(tFBleveller* const p)
900+{
901+ tPwrFollow_free(&p->pwrFlw);
902+}
903+
869904 int tFBleveller_setStrength(tFBleveller* const p, float strength)
870905 { // strength is how strongly level diff is affecting the amp ratio
871906 // try 0.125 for a start
@@ -972,6 +1007,15 @@ void tSimpleLivingString_init(tSimpleLivingString* const p, float freq, float · 100 unmodified lines
9721007 p->levMode=levMode;
9731008 }
9741009
1010+void tSimpleLivingString_free(tSimpleLivingString* const p)
1011+{
1012+ tExpSmooth_free(&p->wlSmooth);
1013+ tDelayL_free(&p->delayLine);
1014+ tOnePole_free(&p->bridgeFilter);
1015+ tHighpass_free(&p->DCblocker);
1016+ tFBleveller_free(&p->fbLev);
1017+}
1018+
9751019 int tSimpleLivingString_setFreq(tSimpleLivingString* const p, float freq)
9761020 {
9771021 if (freq<20) freq=20;
@@ -1068,6 +1112,24 @@ void tLivingString_init(tLivingString* const p, float freq, float pickPos, fl · 90 unmodified lines
10681112 p->levMode=levMode;
10691113 }
10701114
1115+void tLivingString_free(tLivingString* const p)
1116+{
1117+ tExpSmooth_free(&p->wlSmooth);
1118+ tExpSmooth_free(&p->ppSmooth);
1119+ tDelayL_free(&p->delLF);
1120+ tDelayL_free(&p->delUF);
1121+ tDelayL_free(&p->delUB);
1122+ tDelayL_free(&p->delLB);
1123+ tOnePole_free(&p->bridgeFilter);
1124+ tOnePole_free(&p->nutFilter);
1125+ tOnePole_free(&p->prepFilterU);
1126+ tOnePole_free(&p->prepFilterL);
1127+ tHighpass_free(&p->DCblockerU);
1128+ tHighpass_free(&p->DCblockerL);
1129+ tFBleveller_free(&p->fbLevU);
1130+ tFBleveller_free(&p->fbLevL);
1131+}
1132+
10711133 int tLivingString_setFreq(tLivingString* const p, float freq)
10721134 { // NOTE: It is faster to set wavelength in samples directly
10731135 if (freq<20) freq=20;
@@ -1189,6 +1251,21 @@ float tLivingString_sample(tLivingString* const p) · 115 unmodified lines
11891251
11901252 /* Stack */
11911253
1254+void tStack_init(tStack* const ns)
1255+{
1256+ ns->ordered = OFALSE;
1257+ ns->size = 0;
1258+ ns->pos = 0;
1259+ ns->capacity = STACK_SIZE;
1260+
1261+ for (int i = 0; i < STACK_SIZE; i++) ns->data[i] = -1;
1262+}
1263+
1264+void tStack_free(tStack* const ns)
1265+{
1266+
1267+}
1268+
11921269 // If stack contains note, returns index. Else returns -1;
11931270 int tStack_contains(tStack* const ns, uint16_t noteVal)
11941271 {
@@ -1382,17 +1459,6 @@ int tStack_first(tStack* const ns) · 187 unmodified lines
13821459 {
13831460 return ns->data[0];
13841461 }
1385−
1386−void tStack_init(tStack* const ns)
1387−{
1388− ns->ordered = OFALSE;
1389− ns->size = 0;
1390− ns->pos = 0;
1391− ns->capacity = STACK_SIZE;
1392−
1393− for (int i = 0; i < STACK_SIZE; i++) ns->data[i] = -1;
1394−}
1395−
13961462 /******************************************************************************/
13971463 /***************** static function declarations *******************************/
13981464 /******************************************************************************/
@@ -1416,7 +1482,6 @@ void tSOLAD_init(tSOLAD* const w) · 17 unmodified lines
14161482
14171483 void tSOLAD_free(tSOLAD* const w)
14181484 {
1419− leaf_free(w);
14201485 }
14211486
14221487 // send one block of input samples, receive one block of output samples
@@ -1750,7 +1815,10 @@ void tSNAC_init(tSNAC* const s, int overlaparg) · 327 unmodified lines
17501815
17511816 void tSNAC_free(tSNAC* const s)
17521817 {
1753− leaf_free(s);
1818+ leaf_free(s->inputbuf);
1819+ leaf_free(s->processbuf);
1820+ leaf_free(s->spectrumbuf);
1821+ leaf_free(s->biasbuf);
17541822 }
17551823 /******************************************************************************/
17561824 /************************** public access functions****************************/
@@ -2058,7 +2126,7 @@ void tAtkDtk_init_expanded(tAtkDtk* const a, int blocksize, int atk, int rel) · 301 unmodified lines
20582126
20592127 void tAtkDtk_free(tAtkDtk *a)
20602128 {
2061− leaf_free(a);
2129+
20622130 }
20632131
20642132 /*******Public Functions***********/
LEAF/Src/leaf-vocoder.c+5−3
@@ -51,8 +51,6 @@ void tTalkbox_free(tTalkbox* const v) · 50 unmodified lines
5151 leaf_free(v->window);
5252 leaf_free(v->buf0);
5353 leaf_free(v->buf1);
54−
55− leaf_free(v);
5654 }
5755
5856 void tTalkbox_update(tTalkbox* const v) ///update internal parameters...
@@ -227,7 +225,6 @@ void tTalkbox_setQuality(tTalkbox* const v, float quality) · 168 unmodified lines
227225 v->O = (int32_t)((0.0001f + 0.0004f * v->param[3]) * leaf.sampleRate);
228226 }
229227
230−
231228 void tVocoder_init (tVocoder* const v)
232229 {
233230 v->param[0] = 0.33f; //input select
@@ -242,6 +239,11 @@ void tVocoder_init (tVocoder* const v) · 8 unmodified lines
242239 tVocoder_update(v);
243240 }
244241
242+void tVocoder_free (tVocoder* const v)
243+{
244+
245+}
246+
245247 void tVocoder_update (tVocoder* const v)
246248 {
247249 float tpofs = 6.2831853f * leaf.invSampleRate;
LEAF/Src/leaf-wavefolder.c+5−0
@@ -23,6 +23,11 @@ void tLockhartWavefolder_init(tLockhartWavefolder* const w) · 22 unmodified lines
2323 w->xn1 = 0.0f;
2424 }
2525
26+void tLockhardWavefolder_free(tLockhartWavefolder* const w)
27+{
28+
29+}
30+
2631 double tLockhartWavefolderLambert(double x, double ln)
2732 {
2833 double thresh, w, expw, p, r, s, err;
LEAF/leaf.h+4−2
@@ -19,8 +19,9 @@ · 18 unmodified lines
1919
2020 #if _WIN32 || _WIN64
2121
22−#include ".\Inc\leaf-globals.h"
22+#include ".\Inc\leaf-global.h"
2323 #include ".\Inc\leaf-math.h"
24+#include ".\Inc\leaf-mempool.h"
2425 #include ".\Inc\leaf-utilities.h"
2526 #include ".\Inc\leaf-delay.h"
2627 #include ".\Inc\leaf-filter.h"
@@ -40,8 +41,9 @@ · 13 unmodified lines
4041
4142 #else
4243
43−#include "./Inc/leaf-globals.h"
44+#include "./Inc/leaf-global.h"
4445 #include "./Inc/leaf-math.h"
46+#include "./Inc/leaf-mempool.h"
4547 #include "./Inc/leaf-utilities.h"
4648 #include "./Inc/leaf-delay.h"
4749 #include "./Inc/leaf-filter.h"
LEAF_JUCEPlugin/LEAF.jucer+1−1
@@ -23,7 +23,7 @@ · 22 unmodified lines
2323 <FILE id="Hu4b98" name="trigtbl.h" compile="0" resource="0" file="../LEAF/Externals/trigtbl.h"/>
2424 </GROUP>
2525 <GROUP id="{0E2E673D-2AE5-AECB-4E28-A1EE29180BD2}" name="Inc">
26− <FILE id="xaaxl7" name="leaf-globals.h" compile="0" resource="0" file="../LEAF/Inc/leaf-globals.h"/>
26+ <FILE id="IwBoc4" name="leaf-global.h" compile="0" resource="0" file="../LEAF/Inc/leaf-global.h"/>
2727 <FILE id="cmehFw" name="leaf-math.h" compile="0" resource="0" file="../LEAF/Inc/leaf-math.h"/>
2828 <FILE id="XQTGHV" name="leaf-mempool.h" compile="0" resource="0" file="../LEAF/Inc/leaf-mempool.h"/>
2929 <FILE id="k0yQ8k" name="leaf-808.h" compile="0" resource="0" file="../LEAF/Inc/leaf-808.h"/>

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