History

Made tSample and tSamplePlayer classes. Loop sampler (a la groove~) close to working. Needs crossfade.

mulshine committed 7 years ago

Commit c84e0da1 parent 738fd3325 files · +718 −323Browse files

Unified · Split

25 files
  1. LEAF/Inc/leaf-808.h +25 −22
  2. LEAF/Inc/leaf-delay.h +19 −18
  3. LEAF/Inc/leaf-filter.h +32 −41
  4. LEAF/Inc/leaf-formant.h +17 −12
  5. LEAF/Inc/leaf-globals.h +30 −20
  6. LEAF/Inc/leaf-math.h +16 −12
  7. LEAF/Inc/leaf-mempool.h +24 −16
  8. LEAF/Inc/leaf-midi.h +19 −14
  9. LEAF/Inc/leaf-oscillator.h +16 −16
  10. LEAF/Inc/leaf-pitch.h +22 −15
  11. LEAF/Inc/leaf-reverb.h +12 −12
  12. LEAF/Inc/leaf-sample.h +114 −0
  13. LEAF/Inc/leaf-string.h +13 −7
  14. LEAF/Inc/leaf-utilities.h +17 −17
  15. LEAF/Inc/leaf-vocoder.h +11 −11
  16. LEAF/Inc/leaf-wavefolder.h +15 −8
  17. LEAF/Inc/leaf-wavetables.h +13 −13
  18. LEAF/Src/leaf-math.c +13 −1
  19. LEAF/Src/leaf-sample.c +244 −0
  20. LEAF/leaf.h +4 −2
  21. LEAF_JUCEPlugin/LEAF.jucer +2 −0
  22. LEAF_JUCEPlugin/Source/LEAFLink.cpp +4 −7
  23. LEAF_JUCEPlugin/Source/MyTest.cpp +32 −56
  24. LEAF_JUCEPlugin/Source/UIComponent.cpp +2 −2
  25. LEAF_JUCEPlugin/Source/UIComponent.h +2 −1
LEAF/Inc/leaf-808.h+25−22
@@ -1,19 +1,20 @@
1−/*
2− ==============================================================================
1+/*==============================================================================
32
43 leaf_808.h
54 Created: 30 Nov 2018 10:24:44am
65 Author: airship
76
8− ==============================================================================
9−*/
10−
11−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
7+==============================================================================*/
8+
9+#ifndef LEAF_808_H_INCLUDED
10+#define LEAF_808_H_INCLUDED
1211
1312 #ifdef __cplusplus
1413 extern "C" {
15−#endif
16−
14+#endif
15+
16+//==============================================================================
17+
1718 #include "leaf-globals.h"
1819 #include "leaf-math.h"
1920
@@ -21,10 +22,8 @@ extern "C" { · 1 unmodified line
2122 #include "leaf-utilities.h"
2223 #include "leaf-filter.h"
2324
24−
25−
26−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
27−
25+//==============================================================================
26+
2827 // 808 Cowbell
2928 typedef struct _t808Cowbell {
3029
@@ -51,9 +50,8 @@ void t808Cowbell_setBandpassFreq (t808Cowbell* const, float freq); · 20 unmodified lines
5150 void t808Cowbell_setFreq (t808Cowbell* const, float freq);
5251 void t808Cowbell_setOscMix (t808Cowbell* const, float oscMix);
5352
54−
55−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
56−
53+//==============================================================================
54+
5755 // 808 Hihat
5856 typedef struct _t808Hihat {
5957
@@ -90,9 +88,9 @@ void t808Hihat_setStickBandPassQ (t808Hihat* const hihat, float Q); · 30 unmodified lines
9088 void t808Hihat_setOscFreq (t808Hihat* const, float freq);
9189 void t808Hihat_setStretch (t808Hihat* const hihat, float stretch);
9290 void t808Hihat_setFM (t808Hihat* const hihat, float FM_amount);
93−
94−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
95−
91+
92+//==============================================================================
93+
9694 // 808 Snare
9795 typedef struct _t808Snare {
9896
@@ -133,8 +131,8 @@ void t808Snare_setToneNoiseMix (t808Snare* const, float toneNoiseMi · 34 unmodified lines
133131 void t808Snare_setNoiseFilterFreq (t808Snare* const, float noiseFilterFreq);
134132 void t808Snare_setNoiseFilterQ (t808Snare* const, float noiseFilterQ);
135133
136−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
137−
134+//==============================================================================
135+
138136 // 808 Kick
139137 typedef struct _t808Kick {
140138
@@ -173,9 +171,14 @@ void t808Kick_setToneNoiseMix (t808Kick* const, float toneNoiseMix) · 32 unmodified lines
173171 void t808Kick_setNoiseFilterFreq (t808Kick* const, float noiseFilterFreq);
174172 void t808Kick_setNoiseFilterQ (t808Kick* const, float noiseFilterQ);
175173
174+//==============================================================================
175+
176176 #ifdef __cplusplus
177177 }
178−#endif
178+#endif
179+
180+#endif // LEAF_808_H_INCLUDED
181+
182+//==============================================================================
179183
180−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
181184
LEAF/Inc/leaf-delay.h+19−18
@@ -1,27 +1,25 @@
1−/*
2− ==============================================================================
1+/*==============================================================================
32
43 LEAFDelay.h
54 Created: 20 Jan 2017 12:01:24pm
65 Author: Michael R Mulshine
76
8− ==============================================================================
9−*/
7+==============================================================================*/
108
11−#ifndef LEAFDELAY_H_INCLUDED
12−#define LEAFDELAY_H_INCLUDED
9+#ifndef LEAF_DELAY_H_INCLUDED
10+#define LEAF_DELAY_H_INCLUDED
1311
1412 #ifdef __cplusplus
1513 extern "C" {
1614 #endif
1715
18−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
19−
16+//==============================================================================
17+
2018 #include "leaf-globals.h"
2119 #include "leaf-math.h"
2220
23−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
24−
21+//==============================================================================
22+
2523 /* Non-interpolating delay, reimplemented from STK (Cook and Scavone). */
2624 typedef struct _tDelay
2725 {
@@ -48,9 +46,8 @@ float tDelay_tick (tDelay* const, float sample); · 20 unmodified lines
4846 float tDelay_getLastOut (tDelay* const);
4947 float tDelay_getLastIn (tDelay* const);
5048
51−
52−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
53−
49+//==============================================================================
50+
5451 /* Linearly-interpolating delay, reimplemented from STK (Cook and Scavone). */
5552 typedef struct _tDelayL
5653 {
@@ -81,8 +78,8 @@ float tDelayL_tick (tDelayL* const, float sample); · 24 unmodified lines
8178 float tDelayL_getLastOut (tDelayL* const);
8279 float tDelayL_getLastIn (tDelayL* const);
8380
84−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
85−
81+//==============================================================================
82+
8683 /* Allpass-interpolating delay, reimplemented from STK (Cook and Scavone). */
8784 typedef struct _tDelayA
8885 {
@@ -115,8 +112,8 @@ float tDelayA_tick (tDelayA* const, float sample); · 26 unmodified lines
115112 float tDelayA_getLastOut (tDelayA* const);
116113 float tDelayA_getLastIn (tDelayA* const);
117114
118−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
119−
115+//==============================================================================
116+
120117 /* Linear interpolating delay with fixed read and write pointers, variable rate. */
121118 typedef struct _tTapeDelay
122119 {
@@ -147,8 +144,12 @@ float tTapeDelay_tick (tTapeDelay* const, float sample); · 24 unmodified lines
147144 float tTapeDelay_getLastOut (tTapeDelay* const);
148145 float tTapeDelay_getLastIn (tTapeDelay* const);
149146
147+//==============================================================================
148+
150149 #ifdef __cplusplus
151150 }
152151 #endif
153152
154−#endif // LEAFDELAY_H_INCLUDED
153+#endif // LEAF_DELAY_H_INCLUDED
154+
155+//==============================================================================
LEAF/Inc/leaf-filter.h+32−41
@@ -1,22 +1,20 @@
1−/*
2− ==============================================================================
1+/*==============================================================================
32
43 LEAFFilter.h
54 Created: 20 Jan 2017 12:01:10pm
65 Author: Michael R Mulshine
76
8− ==============================================================================
9−*/
7+==============================================================================*/
108
11−#ifndef LEAFFILTER_H_INCLUDED
12−#define LEAFFILTER_H_INCLUDED
9+#ifndef LEAF_FILTER_H_INCLUDED
10+#define LEAF_FILTER_H_INCLUDED
1311
1412 #ifdef __cplusplus
1513 extern "C" {
1614 #endif
1715
18−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
19−
16+//==============================================================================
17+
2018 #include "leaf-globals.h"
2119 #include "leaf-math.h"
2220
@@ -24,8 +22,8 @@ extern "C" { · 1 unmodified line
2422
2523 #include "leaf-wavetables.h"
2624
27−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
28−
25+//==============================================================================
26+
2927 /* tAllpass: Schroeder allpass. Comb-filter with feedforward and feedback. */
3028 typedef struct _tAllpass
3129 {
@@ -45,8 +43,8 @@ void tAllpass_setGain (tAllpass* const, float gain); · 13 unmodified lines
4543 void tAllpass_setDelay (tAllpass* const f, float delay);
4644
4745
48−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
49−
46+//==============================================================================
47+
5048 /* tOnePole: OnePole filter, reimplemented from STK (Cook and Scavone). */
5149 typedef struct _tOnePole
5250 {
@@ -73,9 +71,8 @@ void tOnePole_setFreq (tOnePole* const, float freq); · 20 unmodified lines
7371 void tOnePole_setCoefficients(tOnePole* const, float b0, float a1);
7472 void tOnePole_setGain (tOnePole* const, float gain);
7573
76−
77−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
78−
74+//==============================================================================
75+
7976 /* TwoPole filter, reimplemented from STK (Cook and Scavone). */
8077 typedef struct _tTwoPole
8178 {
@@ -100,10 +97,9 @@ void tTwoPole_setA2 (tTwoPole* const, float a2); · 18 unmodified lines
10097 void tTwoPole_setResonance (tTwoPole* const, float freq, float radius, oBool normalize);
10198 void tTwoPole_setCoefficients(tTwoPole* const, float b0, float a1, float a2);
10299 void tTwoPole_setGain (tTwoPole* const, float gain);
103−
104−
105−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
106100
101+//==============================================================================
102+
107103 /* OneZero filter, reimplemented from STK (Cook and Scavone). */
108104 typedef struct _tOneZero
109105 {
@@ -123,9 +119,8 @@ void tOneZero_setCoefficients(tOneZero* const, float b0, float b1); · 13 unmodified lines
123119 void tOneZero_setGain (tOneZero* const, float gain);
124120 float tOneZero_getPhaseDelay(tOneZero *f, float frequency );
125121
126−
127−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
128−
122+//==============================================================================
123+
129124 /* TwoZero filter, reimplemented from STK (Cook and Scavone). */
130125 typedef struct _tTwoZero
131126 {
@@ -149,9 +144,8 @@ void tTwoZero_setNotch (tTwoZero* const, float frequency, float ra · 17 unmodified lines
149144 void tTwoZero_setCoefficients(tTwoZero* const, float b0, float b1, float b2);
150145 void tTwoZero_setGain (tTwoZero* const, float gain);
151146
152−
153−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
154−
147+//==============================================================================
148+
155149 /* PoleZero filter, reimplemented from STK (Cook and Scavone). */
156150 typedef struct _tPoleZero
157151 {
@@ -175,9 +169,8 @@ void tPoleZero_setAllpass (tPoleZero* const, float coeff); · 17 unmodified lines
175169 void tPoleZero_setBlockZero (tPoleZero* const, float thePole);
176170 void tPoleZero_setGain (tPoleZero* const, float gain);
177171
178−
179−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
180−
172+//==============================================================================
173+
181174 /* BiQuad filter, reimplemented from STK (Cook and Scavone). */
182175 typedef struct _tBiQuad
183176 {
@@ -206,9 +199,8 @@ void tBiQuad_setResonance (tBiQuad* const, float freq, float radius, o · 22 unmodified lines
206199 void tBiQuad_setCoefficients(tBiQuad* const, float b0, float b1, float b2, float a1, float a2);
207200 void tBiQuad_setGain (tBiQuad* const, float gain);
208201
209−
210−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
211−
202+//==============================================================================
203+
212204 /* State Variable Filter, algorithm from Andy Simper. */
213205 typedef enum SVFType
214206 {
@@ -235,9 +227,8 @@ float tSVF_tick (tSVF* const, float v0); · 20 unmodified lines
235227 int tSVF_setFreq (tSVF* const, float freq);
236228 int tSVF_setQ (tSVF* const, float Q);
237229
238−
239−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
240−
230+//==============================================================================
231+
241232 /* Efficient State Variable Filter for 14-bit control input, [0, 4096). */
242233 typedef struct _tSVFE
243234 {
@@ -255,9 +246,8 @@ float tSVFE_tick (tSVFE* const, float v0); · 11 unmodified lines
255246 int tSVFE_setFreq (tSVFE* const, uint16_t controlFreq);
256247 int tSVFE_setQ (tSVFE* const, float Q);
257248
258−
259−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
260−
249+//==============================================================================
250+
261251 /* Simple Highpass filter. */
262252 typedef struct _tHighpass
263253 {
@@ -273,9 +263,8 @@ float tHighpass_tick (tHighpass* const, float x); · 9 unmodified lines
273263 void tHighpass_setFreq (tHighpass* const, float freq);
274264 float tHighpass_getFreq (tHighpass* const);
275265
276−
277−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
278−
266+//==============================================================================
267+
279268 // Butterworth Filter
280269 #define NUM_SVF_BW 16
281270 typedef struct _tButterworth
@@ -299,10 +288,12 @@ void tButterworth_setF1 (tButterworth* const, float in); · 17 unmodified lines
299288 void tButterworth_setF2 (tButterworth* const, float in);
300289 void tButterworth_setFreqs (tButterworth* const, float f1, float f2);
301290
302−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
291+//==============================================================================
303292
304293 #ifdef __cplusplus
305294 }
306295 #endif
307296
308−#endif // LEAFFILTER_H_INCLUDED
297+#endif // LEAF_FILTER_H_INCLUDED
298+
299+//==============================================================================
LEAF/Inc/leaf-formant.h+17−12
@@ -1,24 +1,25 @@
1−/*
2− ==============================================================================
1+/*==============================================================================
32
43 leaf-formant.h
54 Created: 30 Nov 2018 11:03:37am
65 Author: airship
76
8− ==============================================================================
9−*/
7+==============================================================================*/
8+
9+#ifndef LEAF_FORMANT_H_INCLUDED
10+#define LEAF_FORMANT_H_INCLUDED
1011
1112 #ifdef __cplusplus
1213 extern "C" {
1314 #endif
1415
15−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
16−
16+//==============================================================================
17+
1718 #include "leaf-globals.h"
1819 #include "leaf-math.h"
1920
20−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
21−
21+//==============================================================================
22+
2223 #define FORD 7
2324 #define FORMANT_BUFFER_SIZE 2048
2425
@@ -51,11 +52,15 @@ void tFormantShifter_free (tFormantShifter* const); · 26 unmodified lines
5152 float tFormantShifter_tick (tFormantShifter* const, float input, float fwarp);
5253 float tFormantShifter_remove (tFormantShifter* const, float input);
5354 float tFormantShifter_add (tFormantShifter* const, float input, float fwarp);
54−void tFormantShifter_ioSamples (tFormantShifter* const, float* in, float* out, int size, float fwarp);
55−
56−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
55+void tFormantShifter_ioSamples (tFormantShifter* const, float* in, float* out, int size, float fwarp);
56+
57+//==============================================================================
5758
5859 #ifdef __cplusplus
5960 }
60−#endif
61+#endif
62+
63+#endif // LEAF_FORMANT_H_INCLUDED
64+
65+//==============================================================================
6166
LEAF/Inc/leaf-globals.h+30−20
@@ -1,40 +1,45 @@
1−/*
2− ==============================================================================
1+/*==============================================================================
32
43 leaf-globals.h
54 Created: 23 Jan 2017 10:34:10pm
65 Author: Michael R Mulshine
76
8− ==============================================================================
9−*/
7+==============================================================================*/
108
11−#ifndef OPPSGLOBALS_H_INCLUDED
12−#define OPPSGLOBALS_H_INCLUDED
13−
14−/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
15− * *
16− * If your application requires use of many instances of one component or is facing memory limitations, *
17− * use this set of defines to increase or limit the number of instances of each component. The library *
18− * will pre-allocate only the number of instances defined here. *
19− * *
20− * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
21−
22−#include "leaf-mempool.h"
9+#ifndef LEAF_GLOBALS_H_INCLUDED
10+#define LEAF_GLOBALS_H_INCLUDED
2311
2412 #ifdef __cplusplus
2513 extern "C" {
2614 #endif
15+
16+//==============================================================================
17+
18+#include "leaf-mempool.h"
19+
20+//==============================================================================
2721
2822 typedef struct _LEAF
2923 {
3024 float sampleRate;
3125 float invSampleRate;
3226 int blockSize;
33−
27+
28+ /*
29+ float* sinewave;
30+ float* sawtooth[11];
31+ float* square[11];
32+ float* triangle[11];
33+ */
34+
3435 float (*random)(void);
35−} LEAF;
36+} LEAF;
37+
38+//==============================================================================
3639
37−extern LEAF leaf;
40+extern LEAF leaf; // The global instance of LEAF.
41+
42+//==============================================================================
3843
3944 #define SHAPER1_TABLE_SIZE 65536
4045 extern const float shaper1[SHAPER1_TABLE_SIZE];
@@ -54,8 +59,13 @@ extern const float shaper1[SHAPER1_TABLE_SIZE]; · 13 unmodified lines
5459
5560 #define TALKBOX_BUFFER_LENGTH 1600 // Every talkbox instance introduces 5 buffers of this size
5661
62+
63+//==============================================================================
64+
5765 #ifdef __cplusplus
5866 }
5967 #endif
6068
61−#endif // OPPSGLOBALS_H_INCLUDED
69+#endif // LEAF_GLOBALS_H_INCLUDED
70+
71+//==============================================================================
LEAF/Inc/leaf-math.h+16−12
@@ -1,23 +1,23 @@
1−/*
2− ==============================================================================
1+/*==============================================================================
32
43 LEAFMath.h
54 Created: 22 Jan 2017 7:02:56pm
65 Author: Michael R Mulshine
76
8− ==============================================================================
9−*/
7+==============================================================================*/
108
11−#ifndef LEAFMATH_H_INCLUDED
12−#define LEAFMATH_H_INCLUDED
9+#ifndef LEAF_MATH_H_INCLUDED
10+#define LEAF_MATH_H_INCLUDED
11+
12+#ifdef __cplusplus
13+extern "C" {
14+#endif
1315
1416 #include "math.h"
1517 #include "stdint.h"
1618 #include "stdlib.h"
1719
18−#ifdef __cplusplus
19−extern "C" {
20−#endif
20+//==============================================================================
2121
2222 typedef enum oBool
2323 {
@@ -78,8 +78,9 @@ typedef enum oBool · 54 unmodified lines
7878 float LEAF_shaper (float input, float m_drive);
7979 float LEAF_reedTable (float input, float offset, float slope);
8080
81−float LEAF_clip (float min, float val, float max);
82−float LEAF_softClip (float val, float thresh);
81+float LEAF_clip (float min, float val, float max);
82+int LEAF_clipInt (int min, int val, int max);
83+float LEAF_softClip (float val, float thresh);
8384 oBool LEAF_isPrime (uint64_t number );
8485
8586 float LEAF_midiToFrequency (float f);
@@ -110,9 +111,12 @@ int fastabs_int(int in); · 24 unmodified lines
110111 // REQUIRES: 32 bit floats
111112 float fastabs(float f);
112113
114+//==============================================================================
113115
114116 #ifdef __cplusplus
115117 }
116118 #endif
117119
118−#endif // LEAFMATH_H_INCLUDED
120+#endif // LEAF_MATH_H_INCLUDED
121+
122+//==============================================================================
LEAF/Inc/leaf-mempool.h+24−16
@@ -1,4 +1,5 @@
1−/**
1+/*==============================================================================
2+
23 In short, mpool is distributed under so called "BSD license",
34
45 Copyright (c) 2009-2010 Tatsuhiko Kubo <cubicdaiya@gmail.com>
@@ -28,25 +29,29 @@ · 23 unmodified lines
2829 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
2930 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
3031 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31− SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32−*/
33−
34−/* written by C99 style */
32+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33+
34+ written by C99 style
35+==============================================================================*/
3536
36−#ifndef MPOOL_H
37−#define MPOOL_H
37+#ifndef LEAF_MPOOL_H_INCLUDED
38+#define LEAF_MPOOL_H_INCLUDED
39+
40+#ifdef __cplusplus
41+extern "C" {
42+#endif
43+
44+//==============================================================================
3845
3946 #include <stdio.h>
4047 #include <stdlib.h>
4148 #include <string.h>
42−#include <stdbool.h>
49+#include <stdbool.h>
50+
51+//==============================================================================
4352
44−#define MPOOL_POOL_SIZE 500000
53+#define MPOOL_POOL_SIZE 1000000
4554 #define MPOOL_ALIGN_SIZE (8)
46−
47−#ifdef __cplusplus
48−extern "C" {
49−#endif
5055
5156 //#define size_t unsigned long
5257
@@ -68,7 +73,6 @@ typedef struct mpool_t { · 15 unmodified lines
6873 int next;
6974 } mpool_t;
7075
71−
7276 void mpool_create (size_t size, mpool_t* pool);
7377
7478 void *mpool_alloc(size_t size, mpool_t* pool);
@@ -86,12 +90,16 @@ void leaf_free(void* ptr); · 11 unmodified lines
8690 size_t leaf_pool_get_size(void);
8791 size_t leaf_pool_get_used(void);
8892
89−void* leaf_pool_get_pool(void);
93+void* leaf_pool_get_pool(void);
94+
95+//==============================================================================
9096
9197 #ifdef __cplusplus
9298 }
9399 #endif
94100
95−#endif
101+#endif // LEAF_MPOOL_H
102+
103+//==============================================================================
96104
97105
LEAF/Inc/leaf-midi.h+19−14
@@ -1,26 +1,27 @@
1−/*
2− ==============================================================================
1+/*==============================================================================
32
43 leaf-midi.h
54 Created: 30 Nov 2018 11:29:26am
65 Author: airship
76
8− ==============================================================================
9−*/
7+==============================================================================*/
8+
9+#ifndef LEAF_MIDI_H_INCLUDED
10+#define LEAF_MIDI_H_INCLUDED
1011
1112 #ifdef __cplusplus
1213 extern "C" {
1314 #endif
1415
15−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
16−
16+//==============================================================================
17+
1718 #include "leaf-globals.h"
1819 #include "leaf-math.h"
1920
2021 #include "leaf-utilities.h"
2122
22−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
23−
23+//==============================================================================
24+
2425 typedef struct _tMidiNote
2526 {
2627 uint8_t pitch;
@@ -38,8 +39,8 @@ typedef struct _tMidiNode · 11 unmodified lines
3839
3940 } tMidiNode;
4041
41−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
42−
42+//==============================================================================
43+
4344 /* Polyphonic Handler */
4445 typedef struct _tPoly
4546 {
@@ -56,8 +57,8 @@ tMidiNote* tPoly_getMidiNote(tPoly* const, int8_t voiceIndex); · 10 unmodified lines
5657 void tPoly_noteOn(tPoly* poly, int midiNoteNumber, float velocity);
5758 void tPoly_noteOff(tPoly* poly, int midiNoteNumber);
5859
59−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
60−
60+//==============================================================================
61+
6162 /* tMPoly */
6263 typedef struct _tMPoly
6364 {
@@ -110,9 +111,13 @@ float tMPoly_getPitch(tMPoly* const, uint8_t voice); · 46 unmodified lines
110111 int tMPoly_getVelocity(tMPoly* const, uint8_t voice);
111112 int tMPoly_isOn(tMPoly* const, uint8_t voice);
112113
113−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
114+//==============================================================================
114115
115116 #ifdef __cplusplus
116117 }
117−#endif
118+#endif
119+
120+#endif // LEAF_MIDI_H_INCLUDED
121+
122+//==============================================================================
118123
LEAF/Inc/leaf-oscillator.h+16−16
@@ -1,28 +1,26 @@
1−/*
2− ==============================================================================
1+/*==============================================================================
32
43 LEAFOscillator.h
54 Created: 20 Jan 2017 12:00:58pm
65 Author: Michael R Mulshine
76
8− ==============================================================================
9−*/
7+==============================================================================*/
108
11−#ifndef LEAFOSCILLATOR_H_INCLUDED
12−#define LEAFOSCILLATOR_H_INCLUDED
9+#ifndef LEAF_OSCILLATOR_H_INCLUDED
10+#define LEAF_OSCILLATOR_H_INCLUDED
1311
1412 #ifdef __cplusplus
1513 extern "C" {
1614 #endif
1715
18−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
16+//==============================================================================
1917
2018 #include "leaf-globals.h"
2119 #include "leaf-math.h"
2220
2321 #include "leaf-filter.h"
2422
25−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
23+//==============================================================================
2624
2725 /* tNeuron */
2826 typedef enum NeuronMode
@@ -66,7 +64,7 @@ void tNeuron_setV2 (tNeuron* const, float V2); · 37 unmodified lines
6664 void tNeuron_setV3 (tNeuron* const, float V3);
6765 void tNeuron_setTimeStep (tNeuron* const, float timestep);
6866
69−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
67+//==============================================================================
7068
7169 /* tPhasor: Aliasing phasor [0.0, 1.0) */
7270 typedef struct _tPhasor
@@ -82,7 +80,7 @@ void tPhasor_free (tPhasor* const); · 9 unmodified lines
8280 float tPhasor_tick (tPhasor* const);
8381 int tPhasor_setFreq (tPhasor* const, float freq);
8482
85−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
83+//==============================================================================
8684
8785 /* tCycle: Cycle/Sine waveform. Wavetable synthesis.*/
8886 typedef struct _tCycle
@@ -99,7 +97,7 @@ void tCycle_free (tCycle* const); · 10 unmodified lines
9997 float tCycle_tick (tCycle* const);
10098 int tCycle_setFreq (tCycle* const, float freq);
10199
102−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
100+//==============================================================================
103101
104102 /* tSawtooth: Anti-aliased Sawtooth waveform using wavetable interpolation. Wavetables constructed from sine components. */
105103 typedef struct _tSawtooth
@@ -116,7 +114,7 @@ void tSawtooth_free (tSawtooth* const); · 10 unmodified lines
116114 float tSawtooth_tick (tSawtooth* const);
117115 int tSawtooth_setFreq (tSawtooth* const, float freq);
118116
119−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
117+//==============================================================================
120118
121119 /* tTriangle: Anti-aliased Triangle waveform using wavetable interpolation. Wavetables constructed from sine components. */
122120 typedef struct _tTriangle
@@ -133,7 +131,7 @@ void tTriangle_free (tTriangle* const); · 10 unmodified lines
133131 float tTriangle_tick (tTriangle* const);
134132 int tTriangle_setFreq (tTriangle* const, float freq);
135133
136−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
134+//==============================================================================
137135
138136 /* tSquare: Anti-aliased Square waveform using wavetable interpolation. Wavetables constructed from sine components. */
139137 typedef struct _tSquare
@@ -150,7 +148,7 @@ void tSquare_free (tSquare* const); · 10 unmodified lines
150148 float tSquare_tick (tSquare* const);
151149 int tSquare_setFreq (tSquare* const, float freq);
152150
153−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
151+//==============================================================================
154152
155153 /* tNoise. WhiteNoise, PinkNoise. */
156154 typedef enum NoiseType
@@ -173,10 +171,12 @@ void tNoise_free (tNoise* const); · 16 unmodified lines
173171
174172 float tNoise_tick (tNoise* const);
175173
176−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
174+//==============================================================================
177175
178176 #ifdef __cplusplus
179177 }
180178 #endif
181179
182−#endif // LEAFOSCILLATOR_H_INCLUDED
180+#endif // LEAF_OSCILLATOR_H_INCLUDED
181+
182+//==============================================================================
LEAF/Inc/leaf-pitch.h+22−15
@@ -8,11 +8,14 @@ · 7 unmodified lines
88 ==============================================================================
99 */
1010
11+#ifndef LEAF_PITCH_H_INCLUDED
12+#define LEAF_PITCH_H_INCLUDED
13+
1114 #ifdef __cplusplus
1215 extern "C" {
1316 #endif
1417
15−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
18+//==============================================================================
1619
1720 #include "leaf-globals.h"
1821 #include "leaf-math.h"
@@ -20,8 +23,8 @@ extern "C" { · 1 unmodified line
2023 #include "leaf-filter.h"
2124 #include "leaf-utilities.h"
2225
23−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
24−
26+//==============================================================================
27+
2528 #define DEFPITCHRATIO 2.0f
2629 #define DEFTIMECONSTANT 100.0f
2730 #define DEFHOPSIZE 64
@@ -29,8 +32,8 @@ extern "C" { · 1 unmodified line
2932 #define FBA 20
3033 #define HPFREQ 40.0f
3134
32−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
33−
35+//==============================================================================
36+
3437 /* tSOLAD : pitch shifting algorithm that underlies tPitchShifter etc */
3538 #define LOOPSIZE (2048*2) // (4096*2) // loop size must be power of two
3639 #define LOOPMASK (LOOPSIZE - 1)
@@ -72,8 +75,8 @@ void tSOLAD_setReadLag (tSOLAD *w, float readlag); · 35 unmodified lines
7275 // reset state variables
7376 void tSOLAD_resetState (tSOLAD *w);
7477
75−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
76−
78+//==============================================================================
79+
7780 // tSNAC: period detector
7881 #define SNAC_FRAME_SIZE 1024 // default analysis framesize // should be the same as (or smaller than?) PS_FRAME_SIZE
7982 #define DEFOVERLAP 1 // default overlap
@@ -112,8 +115,8 @@ void tSNAC_setMinRMS (tSNAC *s, float rms); · 32 unmodified lines
112115 float tSNAC_getPeriod (tSNAC *s);
113116 float tSNAC_getfidelity (tSNAC *s);
114117
115−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
116−
118+//==============================================================================
119+
117120 // Pitch shifter
118121 typedef struct _tPitchShifter
119122 {
@@ -159,8 +162,8 @@ void tPitchShifter_setHopSize (tPitchShifter* const, int hs); · 39 unmodified lines
159162 void tPitchShifter_setWindowSize (tPitchShifter* const, int ws);
160163 float tPitchShifter_getPeriod (tPitchShifter* const);
161164
162−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
163−
165+//==============================================================================
166+
164167 // Period detection
165168 typedef struct _tPeriod
166169 {
@@ -198,8 +201,8 @@ float tPeriod_findPeriod (tPeriod* const, float sample); · 31 unmodified lines
198201 void tPeriod_setHopSize (tPeriod* p, int hs);
199202 void tPeriod_setWindowSize (tPeriod* p, int ws);
200203
201−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
202−
204+//==============================================================================
205+
203206 // Pitch shift
204207 typedef struct _tPitchShift
205208 {
@@ -229,8 +232,12 @@ float tPitchShift_shiftToFunc (tPitchShift* const, float (*fun)(fl · 23 unmodified lines
229232 float tPitchShift_shiftToFreq (tPitchShift* const, float freq);
230233 void tPitchShift_setPitchFactor (tPitchShift* const, float pf);
231234
232−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
235+//==============================================================================
233236
234237 #ifdef __cplusplus
235238 }
236−#endif
239+#endif
240+
241+#endif // LEAF_PITCH_H_INCLUDED
242+
243+//==============================================================================
LEAF/Inc/leaf-reverb.h+12−12
@@ -1,22 +1,20 @@
1−/*
2− ==============================================================================
1+/*==============================================================================
32
43 LEAFReverb.h
54 Created: 20 Jan 2017 12:02:04pm
65 Author: Michael R Mulshine
76
8− ==============================================================================
9−*/
7+==============================================================================*/
108
11−#ifndef LEAFREVERB_H_INCLUDED
12−#define LEAFREVERB_H_INCLUDED
9+#ifndef LEAF_REVERB_H_INCLUDED
10+#define LEAF_REVERB_H_INCLUDED
1311
1412 #ifdef __cplusplus
1513 extern "C" {
1614 #endif
1715
18−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
19−
16+//==============================================================================
17+
2018 #include "leaf-globals.h"
2119 #include "leaf-math.h"
2220
@@ -24,7 +22,7 @@ extern "C" { · 1 unmodified line
2422 #include "leaf-filter.h"
2523 #include "leaf-oscillator.h"
2624
27−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
25+//==============================================================================
2826
2927 /* PRCRev: Reverb, reimplemented from STK (Cook and Scavone). */
3028 typedef struct _tPRCRev
@@ -53,7 +51,7 @@ void tPRCRev_setT60 (tPRCRev* const, float t60); · 22 unmodified lines
5351 // Set mix between dry input and wet output signal.
5452 void tPRCRev_setMix (tPRCRev* const, float mix);
5553
56−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
54+//==============================================================================
5755
5856 /* NRev: Reverb, reimplemented from STK (Cook and Scavone). */
5957 typedef struct _tNRev
@@ -83,7 +81,7 @@ void tNRev_setT60 (tNRev* const, float t60); · 23 unmodified lines
8381 // Set mix between dry input and wet output signal.
8482 void tNRev_setMix (tNRev* const, float mix);
8583
86−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
84+//==============================================================================
8785
8886 typedef struct _tDattorro
8987 {
@@ -145,4 +143,6 @@ void tDattorro_setFeedbackGain (tDattorro* const, float gain); · 55 unmodified lines
145143 }
146144 #endif
147145
148−#endif // LEAFREVERB_H_INCLUDED
146+#endif // LEAF_REVERB_H_INCLUDED
147+
148+//==============================================================================
LEAF/Inc/leaf-sample.h+114−0
@@ -0,0 +1,114 @@
1+/*==============================================================================
2+
3+ leaf-sample.h
4+ Created: 23 Jan 2019 11:22:09am
5+ Author: Mike Mulshine
6+
7+==============================================================================*/
8+
9+
10+#ifndef LEAF_SAMPLE_H_INCLUDED
11+#define LEAF_SAMPLE_H_INCLUDED
12+
13+#ifdef __cplusplus
14+extern "C" {
15+#endif
16+
17+//==============================================================================
18+
19+#include "leaf-globals.h"
20+#include "leaf-math.h"
21+
22+//==============================================================================
23+
24+ typedef enum RecordMode
25+ {
26+ RecordOneShot = 0,
27+ RecordLoop,
28+ RecordModeNil
29+ } RecordMode;
30+
31+ typedef struct _tSample
32+ {
33+ float* buff;
34+
35+ uint32_t idx;
36+ uint32_t length;
37+
38+ RecordMode mode;
39+
40+ int active;
41+
42+ } tSample;
43+
44+ void tSample_init (tSample* const, uint32_t length);
45+ void tSample_free (tSample* const);
46+
47+ void tSample_tick (tSample* const, float sample);
48+
49+ void tSample_read(tSample* const, float* buff, uint32_t len);
50+
51+ float tSample_get (tSample* const, int idx);
52+
53+ void tSample_start (tSample* const);
54+ void tSample_stop (tSample* const);
55+
56+ void tSample_setRecordMode (tSample* const, RecordMode mode);
57+
58+ void tSample_clear (tSample* const);
59+
60+//==============================================================================
61+
62+ typedef enum Mode
63+ {
64+ Normal,
65+ Loop,
66+ BackAndForth,
67+ ModeNil
68+ } Mode;
69+
70+ typedef struct _tSamplePlayer
71+ {
72+ tSample* samp;
73+
74+ float idx;
75+ float inc;
76+ int dir;
77+
78+ int32_t start;
79+ int32_t end;
80+ uint32_t len;
81+
82+ Mode mode;
83+
84+ int active;
85+
86+ float gain;
87+ } tSamplePlayer;
88+
89+ void tSamplePlayer_init (tSamplePlayer* const, tSample* s);
90+ void tSamplePlayer_free (tSamplePlayer* const);
91+
92+ float tSamplePlayer_tick (tSamplePlayer* const);
93+
94+ void tSamplePlayer_setSample (tSamplePlayer* const, tSample* s);
95+
96+ void tSamplePlayer_setMode (tSamplePlayer* const, Mode mode);
97+
98+ void tSamplePlayer_play (tSamplePlayer* const);
99+ void tSamplePlayer_stop (tSamplePlayer* const);
100+
101+ void tSamplePlayer_setStart (tSamplePlayer* const, int32_t start);
102+ void tSamplePlayer_setEnd (tSamplePlayer* const, int32_t end);
103+
104+ void tSamplePlayer_setRate (tSamplePlayer* const, float rate);
105+
106+//==============================================================================
107+
108+#ifdef __cplusplus
109+}
110+#endif
111+
112+#endif // LEAF_SAMPLE_H_INCLUDED
113+
114+//==============================================================================
LEAF/Inc/leaf-string.h+13−7
@@ -8,11 +8,14 @@ · 7 unmodified lines
88 ==============================================================================
99 */
1010
11+#ifndef LEAF_STRING_H_INCLUDED
12+#define LEAF_STRING_H_INCLUDED
13+
1114 #ifdef __cplusplus
1215 extern "C" {
1316 #endif
1417
15−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
18+//==============================================================================
1619
1720 #include "leaf-globals.h"
1821 #include "leaf-math.h"
@@ -21,7 +24,7 @@ extern "C" { · 2 unmodified lines
2124 #include "leaf-filter.h"
2225 #include "leaf-oscillator.h"
2326
24−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
27+//==============================================================================
2528
2629 /* Karplus Strong model */
2730 typedef struct _tPluck
@@ -62,9 +65,8 @@ void tPluck_controlChange (tPluck* const, int number, float value); · 34 unmodified lines
6265 // tPluck Utilities.
6366 float tPluck_getLastOut (tPluck* const);
6467
65−
66−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
67−
68+//==============================================================================
69+
6870 /* Stif Karplus Strong model */
6971 typedef struct _tStifKarp
7072 {
@@ -130,8 +132,12 @@ void tStifKarp_setBaseLoopGain (tStifKarp* const, float aGain ); · 59 unmodified lines
130132 // tStifKarp utilities.
131133 float tStifKarp_getLastOut (tStifKarp* const);
132134
133−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
135+//==============================================================================
134136
135137 #ifdef __cplusplus
136138 }
137−#endif
139+#endif
140+
141+#endif // LEAF_STRING_H_INCLUDED
142+
143+//==============================================================================
LEAF/Inc/leaf-utilities.h+17−17
@@ -1,26 +1,24 @@
1−/*
2− ==============================================================================
1+/*==============================================================================
32
43 LEAFUtilities.h
54 Created: 20 Jan 2017 12:02:17pm
65 Author: Michael R Mulshine
76
8− ==============================================================================
9−*/
7+==============================================================================*/
108
11−#ifndef LEAFUTILITIES_H_INCLUDED
12−#define LEAFUTILITIES_H_INCLUDED
9+#ifndef LEAF_UTILITIES_H_INCLUDED
10+#define LEAF_UTILITIES_H_INCLUDED
1311
1412 #ifdef __cplusplus
1513 extern "C" {
1614 #endif
1715
18−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
16+//==============================================================================
1917
2018 #include "leaf-globals.h"
2119 #include "leaf-math.h"
2220
23−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
21+//==============================================================================
2422
2523 // STACK implementation (fixed size)
2624 #define STACK_SIZE 128
@@ -48,7 +46,7 @@ int tStack_contains (tStack* const, uint16_t item); · 21 unmodified lines
4846 int tStack_next (tStack* const);
4947 int tStack_get (tStack* const, int which);
5048
51−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
49+//==============================================================================
5250
5351 /* Ramp */
5452 typedef struct _tRamp {
@@ -70,7 +68,7 @@ int tRamp_setTime (tRamp* const, float time); · 15 unmodified lines
7068 int tRamp_setDest (tRamp* const, float dest);
7169 int tRamp_setVal (tRamp* const, float val);
7270
73−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
71+//==============================================================================
7472
7573 /* Compressor */
7674 typedef struct _tCompressor
@@ -88,7 +86,7 @@ void tCompressor_init (tCompressor* const); · 11 unmodified lines
8886 void tCompressor_free (tCompressor* const);
8987 float tCompressor_tick (tCompressor* const, float input);
9088
91−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
89+//==============================================================================
9290
9391 /* Attack-Decay envelope */
9492 typedef struct _tEnvelope {
@@ -120,7 +118,7 @@ int tEnvelope_setDecay (tEnvelope* const, float decay); · 25 unmodified lines
120118 int tEnvelope_loop (tEnvelope* const, oBool loop);
121119 int tEnvelope_on (tEnvelope* const, float velocity);
122120
123−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
121+//==============================================================================
124122
125123 /* ADSR */
126124 typedef struct _tADSR
@@ -152,7 +150,7 @@ int tADSR_setRelease(tADSR* const, float release); · 25 unmodified lines
152150 int tADSR_on (tADSR* const, float velocity);
153151 int tADSR_off (tADSR* const);
154152
155−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
153+//==============================================================================
156154
157155 /* Envelope Follower */
158156 typedef struct _tEnvelopeFollower
@@ -170,7 +168,7 @@ float tEnvelopeFollower_tick (tEnvelopeFollower* const, float x); · 11 unmodified lines
170168 int tEnvelopeFollower_decayCoeff (tEnvelopeFollower* const, float decayCoeff);
171169 int tEnvelopeFollower_attackThresh (tEnvelopeFollower* const, float attackThresh);
172170
173−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
171+//==============================================================================
174172
175173 /* tAtkDtk */
176174 #define DEFBLOCKSIZE 1024
@@ -221,7 +219,7 @@ void tAtkDtk_setThreshold (tAtkDtk* const, float thres); · 44 unmodified lines
221219 // find largest transient in input block, return index of attack
222220 int tAtkDtk_detect (tAtkDtk* const, float *in);
223221
224−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
222+//==============================================================================
225223
226224 // ENV~ from PD, modified for LEAF
227225 #define MAXOVERLAP 32
@@ -246,12 +244,14 @@ void tEnv_free (tEnv* const); · 18 unmodified lines
246244 float tEnv_tick (tEnv* const);
247245 void tEnv_processBlock (tEnv* const, float* in);
248246
249−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
247+//==============================================================================
250248
251249 #ifdef __cplusplus
252250 }
253251 #endif
254252
255−#endif // LEAFUTILITIES_H_INCLUDED
253+#endif // LEAF_UTILITIES_H_INCLUDED
254+
255+//==============================================================================
256256
257257
LEAF/Inc/leaf-vocoder.h+11−11
@@ -1,26 +1,24 @@
1−/*
2− ==============================================================================
1+/*==============================================================================
32
43 LEAFInstrument.h
54 Created: 20 Jan 2017 12:01:54pm
65 Author: Michael R Mulshine
76
8− ==============================================================================
9−*/
7+==============================================================================*/
108
11−#ifndef LEAFINSTRUMENT_H_INCLUDED
12−#define LEAFINSTRUMENT_H_INCLUDED
9+#ifndef LEAF_VOCODER_H_INCLUDED
10+#define LEAF_VOCODER_H_INCLUDED
1311
1412 #ifdef __cplusplus
1513 extern "C" {
1614 #endif
1715
18−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
16+//==============================================================================
1917
2018 #include "leaf-globals.h"
2119 #include "leaf-math.h"
2220
23−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
21+//==============================================================================
2422
2523 /* tTalkbox */
2624 #define NUM_TALKBOX_PARAM 4
@@ -52,7 +50,7 @@ void tTalkbox_lpcDurbin (float *r, int p, float *k, float *g); · 25 unmodified lines
5250 void tTalkbox_lpc (float *buf, float *car, int32_t n, int32_t o);
5351 void tTalkbox_setQuality (tTalkbox* const, float quality);
5452
55−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
53+//==============================================================================
5654
5755 /* tVocoder */
5856 #define NUM_VOCODER_PARAM 8
@@ -79,10 +77,12 @@ float tVocoder_tick (tVocoder* const, float synth, float voice); · 20 unmodified lines
7977 void tVocoder_update (tVocoder* const);
8078 void tVocoder_suspend (tVocoder* const);
8179
82−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
80+//==============================================================================
8381
8482 #ifdef __cplusplus
8583 }
8684 #endif
8785
88−#endif // LEAFINSTRUMENT_H_INCLUDED
86+#endif // LEAF_VOCODER_H_INCLUDED
87+
88+//==============================================================================
LEAF/Inc/leaf-wavefolder.h+15−8
@@ -1,23 +1,25 @@
1−/*
2− ==============================================================================
1+/*==============================================================================
32
43 leaf-wavefolder.h
54 Created: 30 Nov 2018 11:57:05am
65 Author: airship
76
8− ==============================================================================
9−*/
7+==============================================================================*/
8+
9+#ifndef LEAF_WAVEFOLDER_H_INCLUDED
10+#define LEAF_WAVEFOLDER_H_INCLUDED
11+
1012
1113 #ifdef __cplusplus
1214 extern "C" {
1315 #endif
1416
15−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
17+//==============================================================================
1618
1719 #include "leaf-globals.h"
1820 #include "leaf-math.h"
1921
20−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
22+//==============================================================================
2123
2224 /* tLockhartWavefolder */
2325 #define THRESH 10e-10
@@ -45,7 +47,12 @@ void tLockhartWavefolder_free (tLockhartWavefolder* const); · 21 unmodified lines
4547 float tLockhartWavefolder_tick (tLockhartWavefolder* const, float samp);
4648
4749
50+//==============================================================================
51+
4852 #ifdef __cplusplus
4953 }
50−#endif
51−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
54+#endif
55+
56+#endif // LEAF_WAVEFOLDER_H_INCLUDED
57+
58+//==============================================================================
LEAF/Inc/leaf-wavetables.h+13−13
@@ -1,26 +1,24 @@
1−/*
2− ==============================================================================
1+/*==============================================================================
32
43 LEAFWavetables.h
54 Created: 4 Dec 2016 9:42:41pm
65 Author: Michael R Mulshine
76
8− ==============================================================================
9−*/
7+==============================================================================*/
108
11−#ifndef WAVETABLES_H_INCLUDED
12−#define WAVETABLES_H_INCLUDED
9+#ifndef LEAF_WAVETABLES_H_INCLUDED
10+#define LEAF_WAVETABLES_H_INCLUDED
1311
1412 #ifdef __cplusplus
1513 extern "C" {
16−#endif
17−
18−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
14+#endif
15+
16+//==============================================================================
1917
2018 #include "leaf-globals.h"
2119 #include "leaf-math.h"
2220
23−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
21+//==============================================================================
2422
2523
2624 #define SINE_TABLE_SIZE 2048
@@ -62,7 +60,7 @@ extern const float decayCoeffTable[DECAY_COEFF_TABLE_SIZE]; · 35 unmodified lines
6260
6361 extern const float tanh1[TANH1_TABLE_SIZE];
6462
65−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
63+//==============================================================================
6664
6765 /* Sine wave table ripped from http://aquaticus.info/pwm-sine-wave. */
6866 extern const float sinewave[SINE_TABLE_SIZE];
@@ -73,10 +71,12 @@ extern const float triangle[11][TRI_TABLE_SIZE]; · 4 unmodified lines
7371
7472 extern const float squarewave[11][SQR_TABLE_SIZE];
7573
76−// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
74+//==============================================================================
7775
7876 #ifdef __cplusplus
7977 }
8078 #endif
8179
82−#endif // WAVETABLES_H_INCLUDED
80+#endif // LEAF_WAVETABLES_H_INCLUDED
81+
82+//==============================================================================
LEAF/Src/leaf-math.c+13−1
@@ -159,7 +159,19 @@ float LEAF_clip(float min, float val, float max) · 158 unmodified lines
159159 } else {
160160 return val;
161161 }
162−}
162+}
163+
164+int LEAF_clipInt(int min, int val, int max)
165+{
166+ if (val < min) {
167+ return min;
168+ } else if (val > max) {
169+ return max;
170+ } else {
171+ return val;
172+ }
173+}
174+
163175
164176 oBool LEAF_isPrime(uint64_t number )
165177 {
LEAF/Src/leaf-sample.c+244−0
@@ -0,0 +1,244 @@
1+/*
2+ ==============================================================================
3+
4+ LEAFUtilities.c
5+ Created: 20 Jan 2017 12:02:17pm
6+ Author: Michael R Mulshine
7+
8+ ==============================================================================
9+*/
10+
11+
12+#if _WIN32 || _WIN64
13+
14+#include "..\Inc\leaf-sample.h"
15+#include "..\leaf.h"
16+
17+#else
18+
19+#include "../Inc/leaf-sample.h"
20+#include "../leaf.h"
21+
22+#endif
23+
24+//==============================================================================
25+
26+void tSample_init (tSample* const s, uint32_t length)
27+{
28+ s->buff = (float*) leaf_alloc( sizeof(float) * length);
29+
30+
31+ s->length = length;
32+ s->active = 0;
33+ s->idx = 0;
34+ s->mode = RecordOneShot;
35+
36+ tSample_clear(s);
37+}
38+
39+void tSample_free (tSample* const s)
40+{
41+ leaf_free(s->buff);
42+ leaf_free(s);
43+}
44+
45+void tSample_tick (tSample* const s, float sample)
46+{
47+ if (s->active == 1)
48+ {
49+ s->buff[s->idx] = sample;
50+
51+ s->idx += 1;
52+
53+ if (s->idx >= s->length)
54+ {
55+ if (s->mode == RecordOneShot)
56+ {
57+ tSample_stop(s);
58+ }
59+ else if (s->mode == RecordLoop)
60+ {
61+ s->idx = 0;
62+ }
63+ }
64+ }
65+}
66+
67+void tSample_read(tSample* const s, float* buff, uint32_t len)
68+{
69+ for (int i = 0; i < s->length; i++)
70+ {
71+ if (i < len) s->buff[i] = buff[i];
72+ else s->buff[i] = 0.f;
73+ }
74+}
75+
76+float tSample_get (tSample* const s, int idx)
77+{
78+ if ((idx < 0) || (idx >= s->length)) return 0.f;
79+
80+ return s->buff[idx];
81+}
82+
83+void tSample_start(tSample* const s)
84+{
85+ s->active = 1;
86+ s->idx = 0;
87+}
88+
89+void tSample_stop(tSample* const s)
90+{
91+ s->active = 0;
92+}
93+
94+void tSample_setRecordMode (tSample* const s, RecordMode mode)
95+{
96+ s->mode = mode;
97+}
98+
99+void tSample_clear (tSample* const s)
100+{
101+ for (int i = 0; i < s->length; i++)
102+ {
103+ s->buff[i] = 0.f;
104+ }
105+}
106+
107+//==============================================================================
108+
109+void tSamplePlayer_init (tSamplePlayer* const p, tSample* s)
110+{
111+ p->samp = s;
112+
113+ p->active = 0;
114+
115+ p->start = 0;
116+ p->end = p->samp->length - 1;
117+
118+ p->len = p->end - p->start;
119+
120+ p->idx = 0.f;
121+ p->inc = 1.f;
122+
123+ p->mode = Normal;
124+
125+ p->gain = 1.;
126+}
127+
128+void tSamplePlayer_free (tSamplePlayer* const p)
129+{
130+ leaf_free(p->samp);
131+ leaf_free(p);
132+}
133+
134+float tSamplePlayer_tick (tSamplePlayer* const p)
135+{
136+ if (p->active == 0 || (p->len < 4)) return 0.f;
137+
138+ float sample = 0.f;
139+
140+ float* buff = p->samp->buff;
141+
142+ int idx = (int) p->idx;
143+ float alpha = p->idx - idx;
144+
145+ int i1 = idx-1;
146+ int i3 = idx+1;
147+ int i4 = idx+2;
148+
149+ if (i1 < p->start) i1 += p->len;
150+ if (i3 > p->end) i3 -= p->len;
151+ if (i4 > p->end) i4 -= p->len;
152+
153+ sample = LEAF_interpolate_hermite (buff[i1],
154+ buff[idx],
155+ buff[i3],
156+ buff[i4],
157+ alpha);
158+
159+ p->idx += (p->dir * p->inc);
160+
161+ if (p->mode == Normal)
162+ {
163+ // FIX THIS: NORMAL MODE NOT IMPLEMENTED YET
164+ if ((p->dir == 1) && (idx > p->end))
165+ {
166+ p->active = 0;
167+ }
168+ }
169+ else if (p->mode == Loop)
170+ {
171+ if (idx < p->start) p->idx += (float)(p->len);
172+
173+ if (idx > p->end) p->idx -= (float)(p->len);
174+ }
175+ else if (p->mode == BackAndForth)
176+ {
177+ if ((idx < p->start) || (idx > p->end))
178+ {
179+ p->dir = -p->dir;
180+ p->idx += (2*p->inc);
181+ }
182+ }
183+
184+
185+ return sample * p->gain;
186+}
187+
188+void tSamplePlayer_setSample (tSamplePlayer* const p, tSample* s)
189+{
190+ p->samp = s;
191+}
192+
193+void tSamplePlayer_setMode (tSamplePlayer* const p, Mode mode)
194+{
195+ p->mode = mode;
196+}
197+
198+void tSamplePlayer_play (tSamplePlayer* const p)
199+{
200+ p->active = 1;
201+}
202+
203+void tSamplePlayer_stop (tSamplePlayer* const p)
204+{
205+ p->active = 0;
206+}
207+
208+void tSamplePlayer_setStart (tSamplePlayer* const p, int32_t start)
209+{
210+ p->start = LEAF_clipInt(0, start, (p->samp->length - 1));
211+
212+ p->len = abs(p->end - p->start);
213+
214+ if (p->start > p->end) p->dir = -1;
215+ else p->dir = 1;
216+}
217+
218+void tSamplePlayer_setEnd (tSamplePlayer* const p, int32_t end)
219+{
220+ p->end = LEAF_clipInt(0, end, (p->samp->length - 1));
221+
222+ p->len = abs(p->end - p->start);
223+
224+ if (p->start > p->end) p->dir = -1;
225+ else p->dir = 1;
226+}
227+
228+void tSamplePlayer_setRate (tSamplePlayer* const p, float rate)
229+{
230+ if (rate < 0.f)
231+ {
232+ rate = -rate;
233+ p->dir = -1;
234+ }
235+ else
236+ {
237+ p->dir = 1;
238+ }
239+
240+ p->inc = LEAF_clip(0.f, rate, 8.0f);
241+}
242+
243+
244+//==============================================================================
LEAF/leaf.h+4−2
@@ -31,7 +31,8 @@ · 30 unmodified lines
3131 #include ".\Inc\leaf-string.h"
3232 #include ".\Inc\leaf-pitch.h"
3333 #include ".\Inc\leaf-formant.h"
34−#include ".\Inc\leaf-midi.h"
34+#include ".\Inc\leaf-midi.h"
35+#include ".\Inc\leaf-sample.h"
3536 #include ".\Inc\leaf-wavefolder.h"
3637 #include ".\Inc\leaf-wavetables.h"
3738
@@ -49,7 +50,8 @@ · 11 unmodified lines
4950 #include "./Inc/leaf-string.h"
5051 #include "./Inc/leaf-pitch.h"
5152 #include "./Inc/leaf-formant.h"
52−#include "./Inc/leaf-midi.h"
53+#include "./Inc/leaf-midi.h"
54+#include "./Inc/leaf-sample.h"
5355 #include "./Inc/leaf-wavefolder.h"
5456 #include "./Inc/leaf-wavetables.h"
5557
LEAF_JUCEPlugin/LEAF.jucer+2−0
@@ -39,6 +39,7 @@ · 38 unmodified lines
3939 <FILE id="OS2D83" name="leaf-utilities.h" compile="0" resource="0"
4040 file="../LEAF/Inc/leaf-utilities.h"/>
4141 <FILE id="Szb5LP" name="leaf-vocoder.h" compile="0" resource="0" file="../LEAF/Inc/leaf-vocoder.h"/>
42+ <FILE id="T6KXi7" name="leaf-sample.h" compile="0" resource="0" file="../LEAF/Inc/leaf-sample.h"/>
4243 <FILE id="PRkOp2" name="leaf-wavefolder.h" compile="0" resource="0"
4344 file="../LEAF/Inc/leaf-wavefolder.h"/>
4445 <FILE id="KpGzKv" name="leaf-wavetables.h" compile="0" resource="0"
@@ -60,6 +61,7 @@ · 15 unmodified lines
6061 <FILE id="uKHzgz" name="leaf-utilities.c" compile="1" resource="0"
6162 file="../LEAF/Src/leaf-utilities.c"/>
6263 <FILE id="u1aLLR" name="leaf-vocoder.c" compile="1" resource="0" file="../LEAF/Src/leaf-vocoder.c"/>
64+ <FILE id="nmtoFJ" name="leaf-sample.c" compile="1" resource="0" file="../LEAF/Src/leaf-sample.c"/>
6365 <FILE id="LVoaGm" name="leaf-wavefolder.c" compile="1" resource="0"
6466 file="../LEAF/Src/leaf-wavefolder.c"/>
6567 <FILE id="HRk07h" name="leaf-wavetables.c" compile="1" resource="0"
LEAF_JUCEPlugin/Source/LEAFLink.cpp+4−7
@@ -15,17 +15,14 @@ · 14 unmodified lines
1515
1616 std::vector<juce::String> cButtonNames = std::vector<juce::String>
1717 {
18−
18+ "sample"
1919 };
2020
2121 std::vector<juce::String> cSliderNames = std::vector<juce::String>
2222 {
23− "mix",
24− "predelay",
25− "input filter",
26− "feedback filter",
27− "feedback gain",
28− "size"
23+ "rate",
24+ "start",
25+ "end"
2926 };
3027
3128 std::vector<juce::String> cComboBoxNames = std::vector<juce::String>
LEAF_JUCEPlugin/Source/MyTest.cpp+32−56
@@ -16,91 +16,67 @@ static void leaf_pool_report(void); · 15 unmodified lines
1616 static void leaf_pool_dump(void);
1717 static void run_pool_test(void);
1818
19−tDattorro reverb;
20−
21−
22−tTapeDelay delay;
23−
24−float size;
25−tRamp dtime;
19+tSample sample;
2620
21+tSamplePlayer player;
2722
2823 void LEAFTest_init (float sampleRate, int blockSize)
2924 {
3025 LEAF_init(sampleRate, blockSize, &randomNumberGenerator);
3126
32− tDattorro_init(&reverb);
33−
34− //tTapeDelay_init(&delay, 0.5f * leaf.sampleRate, leaf.sampleRate);
35−
36− tRamp_init(&dtime, 500.0f, 1);
27+ tSample_init(&sample, leaf.sampleRate * 4);
3728
38−
39− setSliderValue("mix", reverb.mix);
40− setSliderValue("predelay", reverb.predelay / 200.0f);
41− setSliderValue("input filter", reverb.input_filter / 20000.0f);
42− setSliderValue("feedback filter", reverb.feedback_filter / 20000.0f);
43− setSliderValue("feedback gain", reverb.feedback_gain);
44− setSliderValue("size", reverb.size / 4.0f);
29+ tSamplePlayer_init(&player, &sample);
30+ tSamplePlayer_setMode(&player, Loop);
4531
32+ leaf_pool_report();
4633
47− leaf_pool_report();
34+ tSample_start(&sample);
4835 }
4936
5037 int timer = 0;
51−
52−
53−#define CLICK 0
5438
5539 float LEAFTest_tick (float input)
5640 {
57−#if CLICK
58− input = 0.0f;
41+ tSample_tick(&sample, input);
5942
6043 timer++;
61− if (timer == (1 * leaf.sampleRate))
44+
45+ if (timer >= leaf.sampleRate * 4)
6246 {
63− timer = 0;
64−
65− input = 1.0f;
47+ tSamplePlayer_play(&player);
6648 }
67−#endif
68− //tTapeDelay_setDelay(&delay, tRamp_tick(&dtime));
69−
70− //return tTapeDelay_tick(&delay, input);
71−
72−
73− tDattorro_setSize(&reverb, tRamp_tick(&dtime));
74−
75− return tDattorro_tick(&reverb, input);
7649
50+ return tSamplePlayer_tick(&player);
7751 }
78−
52+
53+bool lastState = false;
7954 void LEAFTest_block (void)
8055 {
81−
82− float val = getSliderValue("mix");
83− tDattorro_setMix(&reverb, val);
56+ float val = getSliderValue("rate");
8457
85− val = getSliderValue("predelay");
86− tDattorro_setInputDelay(&reverb, val * 200.0f);
58+ tSamplePlayer_setRate(&player, val * 16.0f - 8.0f);
8759
88− val = getSliderValue("input filter");
89− tDattorro_setInputFilter(&reverb, val * 20000.0f);
60+ val = getSliderValue("start");
61+ float start = val * sample.length;
62+ tSamplePlayer_setStart(&player, start);
63+ DBG("start: " + String(start));
9064
91− val = getSliderValue("feedback filter");
92− tDattorro_setFeedbackFilter(&reverb, val * 20000.0f);
65+ val = getSliderValue("end");
66+ float end = val * sample.length;
67+ tSamplePlayer_setEnd(&player, end);
68+ DBG("end: " + String(end));
9369
94− val = getSliderValue("feedback gain");
95− tDattorro_setFeedbackGain(&reverb, val);
96−
97− val = getSliderValue("size");
98− tRamp_setDest(&dtime, val * reverb.size_max);
70+ bool state = getButtonState("sample");
9971
72+ if (state && !lastState)
73+ {
74+ timer = 0;
75+ tSamplePlayer_stop(&player);
76+ tSample_start(&sample);
77+ }
10078
101− //float val = getSliderValue("size");
102− //tRamp_setDest(&dtime, val * leaf.sampleRate + 1);
103−
79+ lastState = state;
10480 }
10581
10682 void LEAFTest_controllerInput (int cnum, float cval)
LEAF_JUCEPlugin/Source/UIComponent.cpp+2−2
@@ -144,9 +144,9 @@ void UIComponent::sliderValueChanged(Slider* s) · 143 unmodified lines
144144 setSliderValue(s->getName(), s->getValue());
145145 }
146146
147−void UIComponent::buttonClicked (Button* b)
147+void UIComponent::buttonStateChanged (Button* b)
148148 {
149− setButtonState(b->getName(), true);
149+ setButtonState(b->getName(), b->getState());
150150 }
151151
152152 void UIComponent::comboBoxChanged (ComboBox* cb)
LEAF_JUCEPlugin/Source/UIComponent.h+2−1
@@ -35,7 +35,8 @@ public: · 34 unmodified lines
3535
3636 void sliderValueChanged(Slider* s) override;
3737
38− void buttonClicked (Button* b) override;
38+ void buttonClicked(Button*b) override {};
39+ void buttonStateChanged(Button* b) override;
3940
4041 void textEditorTextChanged (TextEditor&) override;
4142

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