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/*1/*==============================================================================
2 ==============================================================================
3 2
4 leaf_808.h3 leaf_808.h
5 Created: 30 Nov 2018 10:24:44am4 Created: 30 Nov 2018 10:24:44am
6 Author: airship5 Author: airship
7 6
8 ==============================================================================7==============================================================================*/
9*/8
10 9#ifndef LEAF_808_H_INCLUDED
11// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~10#define LEAF_808_H_INCLUDED
12 11
13#ifdef __cplusplus12#ifdef __cplusplus
14extern "C" {13extern "C" {
15#endif14#endif
16 15
16//==============================================================================
17
17#include "leaf-globals.h"18#include "leaf-globals.h"
18#include "leaf-math.h"19#include "leaf-math.h"
19 20
@@ -21,10 +22,8 @@ extern "C" { · 1 unmodified line
21#include "leaf-utilities.h"22#include "leaf-utilities.h"
22#include "leaf-filter.h"23#include "leaf-filter.h"
23 24
24 25//==============================================================================
25 26
26// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
27
28// 808 Cowbell27// 808 Cowbell
29typedef struct _t808Cowbell {28typedef struct _t808Cowbell {
30 29
@@ -51,9 +50,8 @@ void t808Cowbell_setBandpassFreq (t808Cowbell* const, float freq); · 20 unmodified lines
51void t808Cowbell_setFreq (t808Cowbell* const, float freq);50void t808Cowbell_setFreq (t808Cowbell* const, float freq);
52void t808Cowbell_setOscMix (t808Cowbell* const, float oscMix);51void t808Cowbell_setOscMix (t808Cowbell* const, float oscMix);
53 52
54 53//==============================================================================
55// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~54
56
57// 808 Hihat55// 808 Hihat
58typedef struct _t808Hihat {56typedef struct _t808Hihat {
59 57
@@ -90,9 +88,9 @@ void t808Hihat_setStickBandPassQ (t808Hihat* const hihat, float Q); · 30 unmodified lines
90void t808Hihat_setOscFreq (t808Hihat* const, float freq);88void t808Hihat_setOscFreq (t808Hihat* const, float freq);
91void t808Hihat_setStretch (t808Hihat* const hihat, float stretch);89void t808Hihat_setStretch (t808Hihat* const hihat, float stretch);
92void t808Hihat_setFM (t808Hihat* const hihat, float FM_amount);90void t808Hihat_setFM (t808Hihat* const hihat, float FM_amount);
93 91
94// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~92//==============================================================================
95 93
96// 808 Snare94// 808 Snare
97typedef struct _t808Snare {95typedef struct _t808Snare {
98 96
@@ -133,8 +131,8 @@ void t808Snare_setToneNoiseMix (t808Snare* const, float toneNoiseMi · 34 unmodified lines
133void t808Snare_setNoiseFilterFreq (t808Snare* const, float noiseFilterFreq);131void t808Snare_setNoiseFilterFreq (t808Snare* const, float noiseFilterFreq);
134void t808Snare_setNoiseFilterQ (t808Snare* const, float noiseFilterQ);132void t808Snare_setNoiseFilterQ (t808Snare* const, float noiseFilterQ);
135 133
136// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~134//==============================================================================
137 135
138// 808 Kick136// 808 Kick
139typedef struct _t808Kick {137typedef struct _t808Kick {
140 138
@@ -173,9 +171,14 @@ void t808Kick_setToneNoiseMix (t808Kick* const, float toneNoiseMix) · 32 unmodified lines
173void t808Kick_setNoiseFilterFreq (t808Kick* const, float noiseFilterFreq);171void t808Kick_setNoiseFilterFreq (t808Kick* const, float noiseFilterFreq);
174void t808Kick_setNoiseFilterQ (t808Kick* const, float noiseFilterQ);172void t808Kick_setNoiseFilterQ (t808Kick* const, float noiseFilterQ);
175 173
174//==============================================================================
175
176#ifdef __cplusplus176#ifdef __cplusplus
177}177}
178#endif178#endif
179
180#endif // LEAF_808_H_INCLUDED
181
182//==============================================================================
179 183
180// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
181 184
LEAF/Inc/leaf-delay.h+19−18
@@ -1,27 +1,25 @@
1/*1/*==============================================================================
2 ==============================================================================
3 2
4 LEAFDelay.h3 LEAFDelay.h
5 Created: 20 Jan 2017 12:01:24pm4 Created: 20 Jan 2017 12:01:24pm
6 Author: Michael R Mulshine5 Author: Michael R Mulshine
7 6
8 ==============================================================================7==============================================================================*/
9*/
10 8
11#ifndef LEAFDELAY_H_INCLUDED9#ifndef LEAF_DELAY_H_INCLUDED
12#define LEAFDELAY_H_INCLUDED10#define LEAF_DELAY_H_INCLUDED
13 11
14#ifdef __cplusplus12#ifdef __cplusplus
15extern "C" {13extern "C" {
16#endif14#endif
17 15
18// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~16//==============================================================================
19 17
20#include "leaf-globals.h"18#include "leaf-globals.h"
21#include "leaf-math.h"19#include "leaf-math.h"
22 20
23// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~21//==============================================================================
24 22
25/* Non-interpolating delay, reimplemented from STK (Cook and Scavone). */23/* Non-interpolating delay, reimplemented from STK (Cook and Scavone). */
26typedef struct _tDelay24typedef struct _tDelay
27{25{
@@ -48,9 +46,8 @@ float tDelay_tick (tDelay* const, float sample); · 20 unmodified lines
48float tDelay_getLastOut (tDelay* const);46float tDelay_getLastOut (tDelay* const);
49float tDelay_getLastIn (tDelay* const);47float tDelay_getLastIn (tDelay* const);
50 48
51 49//==============================================================================
52// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~50
53
54/* Linearly-interpolating delay, reimplemented from STK (Cook and Scavone). */51/* Linearly-interpolating delay, reimplemented from STK (Cook and Scavone). */
55typedef struct _tDelayL52typedef struct _tDelayL
56{53{
@@ -81,8 +78,8 @@ float tDelayL_tick (tDelayL* const, float sample); · 24 unmodified lines
81float tDelayL_getLastOut (tDelayL* const);78float tDelayL_getLastOut (tDelayL* const);
82float tDelayL_getLastIn (tDelayL* const);79float tDelayL_getLastIn (tDelayL* const);
83 80
84// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~81//==============================================================================
85 82
86/* Allpass-interpolating delay, reimplemented from STK (Cook and Scavone). */83/* Allpass-interpolating delay, reimplemented from STK (Cook and Scavone). */
87typedef struct _tDelayA84typedef struct _tDelayA
88{85{
@@ -115,8 +112,8 @@ float tDelayA_tick (tDelayA* const, float sample); · 26 unmodified lines
115float tDelayA_getLastOut (tDelayA* const);112float tDelayA_getLastOut (tDelayA* const);
116float tDelayA_getLastIn (tDelayA* const);113float tDelayA_getLastIn (tDelayA* const);
117 114
118// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~115//==============================================================================
119 116
120/* Linear interpolating delay with fixed read and write pointers, variable rate. */117/* Linear interpolating delay with fixed read and write pointers, variable rate. */
121typedef struct _tTapeDelay118typedef struct _tTapeDelay
122{119{
@@ -147,8 +144,12 @@ float tTapeDelay_tick (tTapeDelay* const, float sample); · 24 unmodified lines
147float tTapeDelay_getLastOut (tTapeDelay* const);144float tTapeDelay_getLastOut (tTapeDelay* const);
148float tTapeDelay_getLastIn (tTapeDelay* const);145float tTapeDelay_getLastIn (tTapeDelay* const);
149 146
147//==============================================================================
148
150#ifdef __cplusplus149#ifdef __cplusplus
151}150}
152#endif151#endif
153 152
154#endif // LEAFDELAY_H_INCLUDED153#endif // LEAF_DELAY_H_INCLUDED
154
155//==============================================================================
LEAF/Inc/leaf-filter.h+32−41
@@ -1,22 +1,20 @@
1/*1/*==============================================================================
2 ==============================================================================
3 2
4 LEAFFilter.h3 LEAFFilter.h
5 Created: 20 Jan 2017 12:01:10pm4 Created: 20 Jan 2017 12:01:10pm
6 Author: Michael R Mulshine5 Author: Michael R Mulshine
7 6
8 ==============================================================================7==============================================================================*/
9*/
10 8
11#ifndef LEAFFILTER_H_INCLUDED9#ifndef LEAF_FILTER_H_INCLUDED
12#define LEAFFILTER_H_INCLUDED10#define LEAF_FILTER_H_INCLUDED
13 11
14#ifdef __cplusplus12#ifdef __cplusplus
15extern "C" {13extern "C" {
16#endif14#endif
17 15
18// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~16//==============================================================================
19 17
20#include "leaf-globals.h"18#include "leaf-globals.h"
21#include "leaf-math.h"19#include "leaf-math.h"
22 20
@@ -24,8 +22,8 @@ extern "C" { · 1 unmodified line
24 22
25#include "leaf-wavetables.h"23#include "leaf-wavetables.h"
26 24
27// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~25//==============================================================================
28 26
29/* tAllpass: Schroeder allpass. Comb-filter with feedforward and feedback. */27/* tAllpass: Schroeder allpass. Comb-filter with feedforward and feedback. */
30typedef struct _tAllpass28typedef struct _tAllpass
31{29{
@@ -45,8 +43,8 @@ void tAllpass_setGain (tAllpass* const, float gain); · 13 unmodified lines
45void tAllpass_setDelay (tAllpass* const f, float delay);43void tAllpass_setDelay (tAllpass* const f, float delay);
46 44
47 45
48// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~46//==============================================================================
49 47
50/* tOnePole: OnePole filter, reimplemented from STK (Cook and Scavone). */48/* tOnePole: OnePole filter, reimplemented from STK (Cook and Scavone). */
51typedef struct _tOnePole49typedef struct _tOnePole
52{50{
@@ -73,9 +71,8 @@ void tOnePole_setFreq (tOnePole* const, float freq); · 20 unmodified lines
73void tOnePole_setCoefficients(tOnePole* const, float b0, float a1);71void tOnePole_setCoefficients(tOnePole* const, float b0, float a1);
74void tOnePole_setGain (tOnePole* const, float gain);72void tOnePole_setGain (tOnePole* const, float gain);
75 73
76 74//==============================================================================
77// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~75
78
79/* TwoPole filter, reimplemented from STK (Cook and Scavone). */76/* TwoPole filter, reimplemented from STK (Cook and Scavone). */
80typedef struct _tTwoPole77typedef struct _tTwoPole
81{78{
@@ -100,10 +97,9 @@ void tTwoPole_setA2 (tTwoPole* const, float a2); · 18 unmodified lines
100void tTwoPole_setResonance (tTwoPole* const, float freq, float radius, oBool normalize);97void tTwoPole_setResonance (tTwoPole* const, float freq, float radius, oBool normalize);
101void tTwoPole_setCoefficients(tTwoPole* const, float b0, float a1, float a2);98void tTwoPole_setCoefficients(tTwoPole* const, float b0, float a1, float a2);
102void tTwoPole_setGain (tTwoPole* const, float gain);99void tTwoPole_setGain (tTwoPole* const, float gain);
103
104
105// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
106 100
101//==============================================================================
102
107/* OneZero filter, reimplemented from STK (Cook and Scavone). */103/* OneZero filter, reimplemented from STK (Cook and Scavone). */
108typedef struct _tOneZero104typedef struct _tOneZero
109{105{
@@ -123,9 +119,8 @@ void tOneZero_setCoefficients(tOneZero* const, float b0, float b1); · 13 unmodified lines
123void tOneZero_setGain (tOneZero* const, float gain);119void tOneZero_setGain (tOneZero* const, float gain);
124float tOneZero_getPhaseDelay(tOneZero *f, float frequency );120float tOneZero_getPhaseDelay(tOneZero *f, float frequency );
125 121
126 122//==============================================================================
127// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~123
128
129/* TwoZero filter, reimplemented from STK (Cook and Scavone). */124/* TwoZero filter, reimplemented from STK (Cook and Scavone). */
130typedef struct _tTwoZero125typedef struct _tTwoZero
131{126{
@@ -149,9 +144,8 @@ void tTwoZero_setNotch (tTwoZero* const, float frequency, float ra · 17 unmodified lines
149void tTwoZero_setCoefficients(tTwoZero* const, float b0, float b1, float b2);144void tTwoZero_setCoefficients(tTwoZero* const, float b0, float b1, float b2);
150void tTwoZero_setGain (tTwoZero* const, float gain);145void tTwoZero_setGain (tTwoZero* const, float gain);
151 146
152 147//==============================================================================
153// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~148
154
155/* PoleZero filter, reimplemented from STK (Cook and Scavone). */149/* PoleZero filter, reimplemented from STK (Cook and Scavone). */
156typedef struct _tPoleZero150typedef struct _tPoleZero
157{151{
@@ -175,9 +169,8 @@ void tPoleZero_setAllpass (tPoleZero* const, float coeff); · 17 unmodified lines
175void tPoleZero_setBlockZero (tPoleZero* const, float thePole);169void tPoleZero_setBlockZero (tPoleZero* const, float thePole);
176void tPoleZero_setGain (tPoleZero* const, float gain);170void tPoleZero_setGain (tPoleZero* const, float gain);
177 171
178 172//==============================================================================
179// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~173
180
181/* BiQuad filter, reimplemented from STK (Cook and Scavone). */174/* BiQuad filter, reimplemented from STK (Cook and Scavone). */
182typedef struct _tBiQuad175typedef struct _tBiQuad
183{176{
@@ -206,9 +199,8 @@ void tBiQuad_setResonance (tBiQuad* const, float freq, float radius, o · 22 unmodified lines
206void tBiQuad_setCoefficients(tBiQuad* const, float b0, float b1, float b2, float a1, float a2);199void tBiQuad_setCoefficients(tBiQuad* const, float b0, float b1, float b2, float a1, float a2);
207void tBiQuad_setGain (tBiQuad* const, float gain);200void tBiQuad_setGain (tBiQuad* const, float gain);
208 201
209 202//==============================================================================
210// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~203
211
212/* State Variable Filter, algorithm from Andy Simper. */204/* State Variable Filter, algorithm from Andy Simper. */
213typedef enum SVFType205typedef enum SVFType
214{206{
@@ -235,9 +227,8 @@ float tSVF_tick (tSVF* const, float v0); · 20 unmodified lines
235int tSVF_setFreq (tSVF* const, float freq);227int tSVF_setFreq (tSVF* const, float freq);
236int tSVF_setQ (tSVF* const, float Q);228int tSVF_setQ (tSVF* const, float Q);
237 229
238 230//==============================================================================
239// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~231
240
241/* Efficient State Variable Filter for 14-bit control input, [0, 4096). */232/* Efficient State Variable Filter for 14-bit control input, [0, 4096). */
242typedef struct _tSVFE233typedef struct _tSVFE
243{234{
@@ -255,9 +246,8 @@ float tSVFE_tick (tSVFE* const, float v0); · 11 unmodified lines
255int tSVFE_setFreq (tSVFE* const, uint16_t controlFreq);246int tSVFE_setFreq (tSVFE* const, uint16_t controlFreq);
256int tSVFE_setQ (tSVFE* const, float Q);247int tSVFE_setQ (tSVFE* const, float Q);
257 248
258 249//==============================================================================
259// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~250
260
261/* Simple Highpass filter. */251/* Simple Highpass filter. */
262typedef struct _tHighpass252typedef struct _tHighpass
263{253{
@@ -273,9 +263,8 @@ float tHighpass_tick (tHighpass* const, float x); · 9 unmodified lines
273void tHighpass_setFreq (tHighpass* const, float freq);263void tHighpass_setFreq (tHighpass* const, float freq);
274float tHighpass_getFreq (tHighpass* const);264float tHighpass_getFreq (tHighpass* const);
275 265
276 266//==============================================================================
277// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~267
278
279// Butterworth Filter268// Butterworth Filter
280#define NUM_SVF_BW 16269#define NUM_SVF_BW 16
281typedef struct _tButterworth270typedef struct _tButterworth
@@ -299,10 +288,12 @@ void tButterworth_setF1 (tButterworth* const, float in); · 17 unmodified lines
299void tButterworth_setF2 (tButterworth* const, float in);288void tButterworth_setF2 (tButterworth* const, float in);
300void tButterworth_setFreqs (tButterworth* const, float f1, float f2);289void tButterworth_setFreqs (tButterworth* const, float f1, float f2);
301 290
302// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~291//==============================================================================
303 292
304#ifdef __cplusplus293#ifdef __cplusplus
305}294}
306#endif295#endif
307 296
308#endif // LEAFFILTER_H_INCLUDED297#endif // LEAF_FILTER_H_INCLUDED
298
299//==============================================================================
LEAF/Inc/leaf-formant.h+17−12
@@ -1,24 +1,25 @@
1/*1/*==============================================================================
2 ==============================================================================
3 2
4 leaf-formant.h3 leaf-formant.h
5 Created: 30 Nov 2018 11:03:37am4 Created: 30 Nov 2018 11:03:37am
6 Author: airship5 Author: airship
7 6
8 ==============================================================================7==============================================================================*/
9*/8
9#ifndef LEAF_FORMANT_H_INCLUDED
10#define LEAF_FORMANT_H_INCLUDED
10 11
11#ifdef __cplusplus12#ifdef __cplusplus
12extern "C" {13extern "C" {
13#endif14#endif
14 15
15// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~16//==============================================================================
16 17
17#include "leaf-globals.h"18#include "leaf-globals.h"
18#include "leaf-math.h"19#include "leaf-math.h"
19 20
20// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~21//==============================================================================
21 22
22#define FORD 723#define FORD 7
23#define FORMANT_BUFFER_SIZE 204824#define FORMANT_BUFFER_SIZE 2048
24 25
@@ -51,11 +52,15 @@ void tFormantShifter_free (tFormantShifter* const); · 26 unmodified lines
51float tFormantShifter_tick (tFormantShifter* const, float input, float fwarp);52float tFormantShifter_tick (tFormantShifter* const, float input, float fwarp);
52float tFormantShifter_remove (tFormantShifter* const, float input);53float tFormantShifter_remove (tFormantShifter* const, float input);
53float tFormantShifter_add (tFormantShifter* const, float input, float fwarp);54float tFormantShifter_add (tFormantShifter* const, float input, float fwarp);
54void tFormantShifter_ioSamples (tFormantShifter* const, float* in, float* out, int size, float fwarp);55void tFormantShifter_ioSamples (tFormantShifter* const, float* in, float* out, int size, float fwarp);
55 56
56// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~57//==============================================================================
57 58
58#ifdef __cplusplus59#ifdef __cplusplus
59}60}
60#endif61#endif
62
63#endif // LEAF_FORMANT_H_INCLUDED
64
65//==============================================================================
61 66
LEAF/Inc/leaf-globals.h+30−20
@@ -1,40 +1,45 @@
1/*1/*==============================================================================
2 ==============================================================================
3 2
4 leaf-globals.h3 leaf-globals.h
5 Created: 23 Jan 2017 10:34:10pm4 Created: 23 Jan 2017 10:34:10pm
6 Author: Michael R Mulshine5 Author: Michael R Mulshine
7 6
8 ==============================================================================7==============================================================================*/
9*/
10 8
11#ifndef OPPSGLOBALS_H_INCLUDED9#ifndef LEAF_GLOBALS_H_INCLUDED
12#define OPPSGLOBALS_H_INCLUDED10#define LEAF_GLOBALS_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"
23 11
24#ifdef __cplusplus12#ifdef __cplusplus
25extern "C" {13extern "C" {
26#endif14#endif
15
16//==============================================================================
17
18#include "leaf-mempool.h"
19
20//==============================================================================
27 21
28typedef struct _LEAF22typedef struct _LEAF
29{23{
30 float sampleRate;24 float sampleRate;
31 float invSampleRate;25 float invSampleRate;
32 int blockSize;26 int blockSize;
33 27
28 /*
29 float* sinewave;
30 float* sawtooth[11];
31 float* square[11];
32 float* triangle[11];
33 */
34
34 float (*random)(void);35 float (*random)(void);
35} LEAF;36} LEAF;
37
38//==============================================================================
36 39
37extern LEAF leaf;40extern LEAF leaf; // The global instance of LEAF.
41
42//==============================================================================
38 43
39#define SHAPER1_TABLE_SIZE 6553644#define SHAPER1_TABLE_SIZE 65536
40extern const float shaper1[SHAPER1_TABLE_SIZE];45extern const float shaper1[SHAPER1_TABLE_SIZE];
@@ -54,8 +59,13 @@ extern const float shaper1[SHAPER1_TABLE_SIZE]; · 13 unmodified lines
54 59
55#define TALKBOX_BUFFER_LENGTH 1600 // Every talkbox instance introduces 5 buffers of this size60#define TALKBOX_BUFFER_LENGTH 1600 // Every talkbox instance introduces 5 buffers of this size
56 61
62
63//==============================================================================
64
57#ifdef __cplusplus65#ifdef __cplusplus
58}66}
59#endif67#endif
60 68
61#endif // OPPSGLOBALS_H_INCLUDED69#endif // LEAF_GLOBALS_H_INCLUDED
70
71//==============================================================================
LEAF/Inc/leaf-math.h+16−12
@@ -1,23 +1,23 @@
1/*1/*==============================================================================
2 ==============================================================================
3 2
4 LEAFMath.h3 LEAFMath.h
5 Created: 22 Jan 2017 7:02:56pm4 Created: 22 Jan 2017 7:02:56pm
6 Author: Michael R Mulshine5 Author: Michael R Mulshine
7 6
8 ==============================================================================7==============================================================================*/
9*/
10 8
11#ifndef LEAFMATH_H_INCLUDED9#ifndef LEAF_MATH_H_INCLUDED
12#define LEAFMATH_H_INCLUDED10#define LEAF_MATH_H_INCLUDED
11
12#ifdef __cplusplus
13extern "C" {
14#endif
13 15
14#include "math.h"16#include "math.h"
15#include "stdint.h"17#include "stdint.h"
16#include "stdlib.h"18#include "stdlib.h"
17 19
18#ifdef __cplusplus20//==============================================================================
19extern "C" {
20#endif
21 21
22typedef enum oBool22typedef enum oBool
23{23{
@@ -78,8 +78,9 @@ typedef enum oBool · 54 unmodified lines
78float LEAF_shaper (float input, float m_drive);78float LEAF_shaper (float input, float m_drive);
79float LEAF_reedTable (float input, float offset, float slope);79float LEAF_reedTable (float input, float offset, float slope);
80 80
81float LEAF_clip (float min, float val, float max);81float LEAF_clip (float min, float val, float max);
82float LEAF_softClip (float val, float thresh);82int LEAF_clipInt (int min, int val, int max);
83float LEAF_softClip (float val, float thresh);
83oBool LEAF_isPrime (uint64_t number );84oBool LEAF_isPrime (uint64_t number );
84 85
85float LEAF_midiToFrequency (float f);86float LEAF_midiToFrequency (float f);
@@ -110,9 +111,12 @@ int fastabs_int(int in); · 24 unmodified lines
110// REQUIRES: 32 bit floats111// REQUIRES: 32 bit floats
111float fastabs(float f);112float fastabs(float f);
112 113
114//==============================================================================
113 115
114#ifdef __cplusplus116#ifdef __cplusplus
115}117}
116#endif118#endif
117 119
118#endif // LEAFMATH_H_INCLUDED120#endif // LEAF_MATH_H_INCLUDED
121
122//==============================================================================
LEAF/Inc/leaf-mempool.h+24−16
@@ -1,4 +1,5 @@
1/**1/*==============================================================================
2
2 In short, mpool is distributed under so called "BSD license",3 In short, mpool is distributed under so called "BSD license",
3 4
4 Copyright (c) 2009-2010 Tatsuhiko Kubo <cubicdaiya@gmail.com>5 Copyright (c) 2009-2010 Tatsuhiko Kubo <cubicdaiya@gmail.com>
@@ -28,25 +29,29 @@ · 23 unmodified lines
28 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF29 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING30 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS31 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 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32*/33
33 34 written by C99 style
34/* written by C99 style */35==============================================================================*/
35 36
36#ifndef MPOOL_H37#ifndef LEAF_MPOOL_H_INCLUDED
37#define MPOOL_H38#define LEAF_MPOOL_H_INCLUDED
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44//==============================================================================
38 45
39#include <stdio.h>46#include <stdio.h>
40#include <stdlib.h>47#include <stdlib.h>
41#include <string.h>48#include <string.h>
42#include <stdbool.h>49#include <stdbool.h>
50
51//==============================================================================
43 52
44#define MPOOL_POOL_SIZE 50000053#define MPOOL_POOL_SIZE 1000000
45#define MPOOL_ALIGN_SIZE (8)54#define MPOOL_ALIGN_SIZE (8)
46
47#ifdef __cplusplus
48extern "C" {
49#endif
50 55
51//#define size_t unsigned long56//#define size_t unsigned long
52 57
@@ -68,7 +73,6 @@ typedef struct mpool_t { · 15 unmodified lines
68 int next;73 int next;
69} mpool_t;74} mpool_t;
70 75
71
72void mpool_create (size_t size, mpool_t* pool);76void mpool_create (size_t size, mpool_t* pool);
73 77
74void *mpool_alloc(size_t size, mpool_t* pool);78void *mpool_alloc(size_t size, mpool_t* pool);
@@ -86,12 +90,16 @@ void leaf_free(void* ptr); · 11 unmodified lines
86size_t leaf_pool_get_size(void);90size_t leaf_pool_get_size(void);
87size_t leaf_pool_get_used(void);91size_t leaf_pool_get_used(void);
88 92
89void* leaf_pool_get_pool(void);93void* leaf_pool_get_pool(void);
94
95//==============================================================================
90 96
91#ifdef __cplusplus97#ifdef __cplusplus
92}98}
93#endif99#endif
94 100
95#endif101#endif // LEAF_MPOOL_H
102
103//==============================================================================
96 104
97 105
LEAF/Inc/leaf-midi.h+19−14
@@ -1,26 +1,27 @@
1/*1/*==============================================================================
2 ==============================================================================
3 2
4 leaf-midi.h3 leaf-midi.h
5 Created: 30 Nov 2018 11:29:26am4 Created: 30 Nov 2018 11:29:26am
6 Author: airship5 Author: airship
7 6
8 ==============================================================================7==============================================================================*/
9*/8
9#ifndef LEAF_MIDI_H_INCLUDED
10#define LEAF_MIDI_H_INCLUDED
10 11
11#ifdef __cplusplus12#ifdef __cplusplus
12extern "C" {13extern "C" {
13#endif14#endif
14 15
15// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~16//==============================================================================
16 17
17#include "leaf-globals.h"18#include "leaf-globals.h"
18#include "leaf-math.h"19#include "leaf-math.h"
19 20
20#include "leaf-utilities.h"21#include "leaf-utilities.h"
21 22
22// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~23//==============================================================================
23 24
24typedef struct _tMidiNote25typedef struct _tMidiNote
25{26{
26 uint8_t pitch;27 uint8_t pitch;
@@ -38,8 +39,8 @@ typedef struct _tMidiNode · 11 unmodified lines
38 39
39} tMidiNode;40} tMidiNode;
40 41
41// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~42//==============================================================================
42 43
43/* Polyphonic Handler */44/* Polyphonic Handler */
44typedef struct _tPoly45typedef struct _tPoly
45{46{
@@ -56,8 +57,8 @@ tMidiNote* tPoly_getMidiNote(tPoly* const, int8_t voiceIndex); · 10 unmodified lines
56void tPoly_noteOn(tPoly* poly, int midiNoteNumber, float velocity);57void tPoly_noteOn(tPoly* poly, int midiNoteNumber, float velocity);
57void tPoly_noteOff(tPoly* poly, int midiNoteNumber);58void tPoly_noteOff(tPoly* poly, int midiNoteNumber);
58 59
59// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~60//==============================================================================
60 61
61/* tMPoly */62/* tMPoly */
62typedef struct _tMPoly63typedef struct _tMPoly
63{64{
@@ -110,9 +111,13 @@ float tMPoly_getPitch(tMPoly* const, uint8_t voice); · 46 unmodified lines
110int tMPoly_getVelocity(tMPoly* const, uint8_t voice);111int tMPoly_getVelocity(tMPoly* const, uint8_t voice);
111int tMPoly_isOn(tMPoly* const, uint8_t voice);112int tMPoly_isOn(tMPoly* const, uint8_t voice);
112 113
113// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~114//==============================================================================
114 115
115#ifdef __cplusplus116#ifdef __cplusplus
116}117}
117#endif118#endif
119
120#endif // LEAF_MIDI_H_INCLUDED
121
122//==============================================================================
118 123
LEAF/Inc/leaf-oscillator.h+16−16
@@ -1,28 +1,26 @@
1/*1/*==============================================================================
2 ==============================================================================
3 2
4 LEAFOscillator.h3 LEAFOscillator.h
5 Created: 20 Jan 2017 12:00:58pm4 Created: 20 Jan 2017 12:00:58pm
6 Author: Michael R Mulshine5 Author: Michael R Mulshine
7 6
8 ==============================================================================7==============================================================================*/
9*/
10 8
11#ifndef LEAFOSCILLATOR_H_INCLUDED9#ifndef LEAF_OSCILLATOR_H_INCLUDED
12#define LEAFOSCILLATOR_H_INCLUDED10#define LEAF_OSCILLATOR_H_INCLUDED
13 11
14#ifdef __cplusplus12#ifdef __cplusplus
15extern "C" {13extern "C" {
16#endif14#endif
17 15
18// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~16//==============================================================================
19 17
20#include "leaf-globals.h"18#include "leaf-globals.h"
21#include "leaf-math.h"19#include "leaf-math.h"
22 20
23#include "leaf-filter.h"21#include "leaf-filter.h"
24 22
25// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~23//==============================================================================
26 24
27/* tNeuron */25/* tNeuron */
28typedef enum NeuronMode26typedef enum NeuronMode
@@ -66,7 +64,7 @@ void tNeuron_setV2 (tNeuron* const, float V2); · 37 unmodified lines
66void tNeuron_setV3 (tNeuron* const, float V3);64void tNeuron_setV3 (tNeuron* const, float V3);
67void tNeuron_setTimeStep (tNeuron* const, float timestep);65void tNeuron_setTimeStep (tNeuron* const, float timestep);
68 66
69// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~67//==============================================================================
70 68
71/* tPhasor: Aliasing phasor [0.0, 1.0) */69/* tPhasor: Aliasing phasor [0.0, 1.0) */
72typedef struct _tPhasor70typedef struct _tPhasor
@@ -82,7 +80,7 @@ void tPhasor_free (tPhasor* const); · 9 unmodified lines
82float tPhasor_tick (tPhasor* const);80float tPhasor_tick (tPhasor* const);
83int tPhasor_setFreq (tPhasor* const, float freq);81int tPhasor_setFreq (tPhasor* const, float freq);
84 82
85// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~83//==============================================================================
86 84
87/* tCycle: Cycle/Sine waveform. Wavetable synthesis.*/85/* tCycle: Cycle/Sine waveform. Wavetable synthesis.*/
88typedef struct _tCycle86typedef struct _tCycle
@@ -99,7 +97,7 @@ void tCycle_free (tCycle* const); · 10 unmodified lines
99float tCycle_tick (tCycle* const);97float tCycle_tick (tCycle* const);
100int tCycle_setFreq (tCycle* const, float freq);98int tCycle_setFreq (tCycle* const, float freq);
101 99
102// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~100//==============================================================================
103 101
104/* tSawtooth: Anti-aliased Sawtooth waveform using wavetable interpolation. Wavetables constructed from sine components. */102/* tSawtooth: Anti-aliased Sawtooth waveform using wavetable interpolation. Wavetables constructed from sine components. */
105typedef struct _tSawtooth103typedef struct _tSawtooth
@@ -116,7 +114,7 @@ void tSawtooth_free (tSawtooth* const); · 10 unmodified lines
116float tSawtooth_tick (tSawtooth* const);114float tSawtooth_tick (tSawtooth* const);
117int tSawtooth_setFreq (tSawtooth* const, float freq);115int tSawtooth_setFreq (tSawtooth* const, float freq);
118 116
119// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~117//==============================================================================
120 118
121/* tTriangle: Anti-aliased Triangle waveform using wavetable interpolation. Wavetables constructed from sine components. */119/* tTriangle: Anti-aliased Triangle waveform using wavetable interpolation. Wavetables constructed from sine components. */
122typedef struct _tTriangle120typedef struct _tTriangle
@@ -133,7 +131,7 @@ void tTriangle_free (tTriangle* const); · 10 unmodified lines
133float tTriangle_tick (tTriangle* const);131float tTriangle_tick (tTriangle* const);
134int tTriangle_setFreq (tTriangle* const, float freq);132int tTriangle_setFreq (tTriangle* const, float freq);
135 133
136// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~134//==============================================================================
137 135
138/* tSquare: Anti-aliased Square waveform using wavetable interpolation. Wavetables constructed from sine components. */136/* tSquare: Anti-aliased Square waveform using wavetable interpolation. Wavetables constructed from sine components. */
139typedef struct _tSquare137typedef struct _tSquare
@@ -150,7 +148,7 @@ void tSquare_free (tSquare* const); · 10 unmodified lines
150float tSquare_tick (tSquare* const);148float tSquare_tick (tSquare* const);
151int tSquare_setFreq (tSquare* const, float freq);149int tSquare_setFreq (tSquare* const, float freq);
152 150
153// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~151//==============================================================================
154 152
155/* tNoise. WhiteNoise, PinkNoise. */153/* tNoise. WhiteNoise, PinkNoise. */
156typedef enum NoiseType154typedef enum NoiseType
@@ -173,10 +171,12 @@ void tNoise_free (tNoise* const); · 16 unmodified lines
173 171
174float tNoise_tick (tNoise* const);172float tNoise_tick (tNoise* const);
175 173
176// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~174//==============================================================================
177 175
178#ifdef __cplusplus176#ifdef __cplusplus
179}177}
180#endif178#endif
181 179
182#endif // LEAFOSCILLATOR_H_INCLUDED180#endif // LEAF_OSCILLATOR_H_INCLUDED
181
182//==============================================================================
LEAF/Inc/leaf-pitch.h+22−15
@@ -8,11 +8,14 @@ · 7 unmodified lines
8 ==============================================================================8 ==============================================================================
9*/9*/
10 10
11#ifndef LEAF_PITCH_H_INCLUDED
12#define LEAF_PITCH_H_INCLUDED
13
11#ifdef __cplusplus14#ifdef __cplusplus
12extern "C" {15extern "C" {
13#endif16#endif
14 17
15// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~18//==============================================================================
16 19
17#include "leaf-globals.h"20#include "leaf-globals.h"
18#include "leaf-math.h"21#include "leaf-math.h"
@@ -20,8 +23,8 @@ extern "C" { · 1 unmodified line
20#include "leaf-filter.h"23#include "leaf-filter.h"
21#include "leaf-utilities.h"24#include "leaf-utilities.h"
22 25
23// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~26//==============================================================================
24 27
25#define DEFPITCHRATIO 2.0f28#define DEFPITCHRATIO 2.0f
26#define DEFTIMECONSTANT 100.0f29#define DEFTIMECONSTANT 100.0f
27#define DEFHOPSIZE 6430#define DEFHOPSIZE 64
@@ -29,8 +32,8 @@ extern "C" { · 1 unmodified line
29#define FBA 2032#define FBA 20
30#define HPFREQ 40.0f33#define HPFREQ 40.0f
31 34
32// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~35//==============================================================================
33 36
34/* tSOLAD : pitch shifting algorithm that underlies tPitchShifter etc */37/* tSOLAD : pitch shifting algorithm that underlies tPitchShifter etc */
35#define LOOPSIZE (2048*2) // (4096*2) // loop size must be power of two38#define LOOPSIZE (2048*2) // (4096*2) // loop size must be power of two
36#define LOOPMASK (LOOPSIZE - 1)39#define LOOPMASK (LOOPSIZE - 1)
@@ -72,8 +75,8 @@ void tSOLAD_setReadLag (tSOLAD *w, float readlag); · 35 unmodified lines
72// reset state variables75// reset state variables
73void tSOLAD_resetState (tSOLAD *w);76void tSOLAD_resetState (tSOLAD *w);
74 77
75// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~78//==============================================================================
76 79
77// tSNAC: period detector80// tSNAC: period detector
78#define SNAC_FRAME_SIZE 1024 // default analysis framesize // should be the same as (or smaller than?) PS_FRAME_SIZE81#define SNAC_FRAME_SIZE 1024 // default analysis framesize // should be the same as (or smaller than?) PS_FRAME_SIZE
79#define DEFOVERLAP 1 // default overlap82#define DEFOVERLAP 1 // default overlap
@@ -112,8 +115,8 @@ void tSNAC_setMinRMS (tSNAC *s, float rms); · 32 unmodified lines
112float tSNAC_getPeriod (tSNAC *s);115float tSNAC_getPeriod (tSNAC *s);
113float tSNAC_getfidelity (tSNAC *s);116float tSNAC_getfidelity (tSNAC *s);
114 117
115// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~118//==============================================================================
116 119
117// Pitch shifter 120// Pitch shifter
118typedef struct _tPitchShifter121typedef struct _tPitchShifter
119{122{
@@ -159,8 +162,8 @@ void tPitchShifter_setHopSize (tPitchShifter* const, int hs); · 39 unmodified lines
159void tPitchShifter_setWindowSize (tPitchShifter* const, int ws);162void tPitchShifter_setWindowSize (tPitchShifter* const, int ws);
160float tPitchShifter_getPeriod (tPitchShifter* const);163float tPitchShifter_getPeriod (tPitchShifter* const);
161 164
162// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~165//==============================================================================
163 166
164// Period detection167// Period detection
165typedef struct _tPeriod168typedef struct _tPeriod
166{169{
@@ -198,8 +201,8 @@ float tPeriod_findPeriod (tPeriod* const, float sample); · 31 unmodified lines
198void tPeriod_setHopSize (tPeriod* p, int hs);201void tPeriod_setHopSize (tPeriod* p, int hs);
199void tPeriod_setWindowSize (tPeriod* p, int ws);202void tPeriod_setWindowSize (tPeriod* p, int ws);
200 203
201// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~204//==============================================================================
202 205
203// Pitch shift206// Pitch shift
204typedef struct _tPitchShift207typedef struct _tPitchShift
205{208{
@@ -229,8 +232,12 @@ float tPitchShift_shiftToFunc (tPitchShift* const, float (*fun)(fl · 23 unmodified lines
229float tPitchShift_shiftToFreq (tPitchShift* const, float freq);232float tPitchShift_shiftToFreq (tPitchShift* const, float freq);
230void tPitchShift_setPitchFactor (tPitchShift* const, float pf);233void tPitchShift_setPitchFactor (tPitchShift* const, float pf);
231 234
232// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~235//==============================================================================
233 236
234#ifdef __cplusplus237#ifdef __cplusplus
235}238}
236#endif239#endif
240
241#endif // LEAF_PITCH_H_INCLUDED
242
243//==============================================================================
LEAF/Inc/leaf-reverb.h+12−12
@@ -1,22 +1,20 @@
1/*1/*==============================================================================
2 ==============================================================================
3 2
4 LEAFReverb.h3 LEAFReverb.h
5 Created: 20 Jan 2017 12:02:04pm4 Created: 20 Jan 2017 12:02:04pm
6 Author: Michael R Mulshine5 Author: Michael R Mulshine
7 6
8 ==============================================================================7==============================================================================*/
9*/
10 8
11#ifndef LEAFREVERB_H_INCLUDED9#ifndef LEAF_REVERB_H_INCLUDED
12#define LEAFREVERB_H_INCLUDED10#define LEAF_REVERB_H_INCLUDED
13 11
14#ifdef __cplusplus12#ifdef __cplusplus
15extern "C" {13extern "C" {
16#endif14#endif
17 15
18// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~16//==============================================================================
19 17
20#include "leaf-globals.h"18#include "leaf-globals.h"
21#include "leaf-math.h"19#include "leaf-math.h"
22 20
@@ -24,7 +22,7 @@ extern "C" { · 1 unmodified line
24#include "leaf-filter.h"22#include "leaf-filter.h"
25#include "leaf-oscillator.h"23#include "leaf-oscillator.h"
26 24
27// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~25//==============================================================================
28 26
29/* PRCRev: Reverb, reimplemented from STK (Cook and Scavone). */27/* PRCRev: Reverb, reimplemented from STK (Cook and Scavone). */
30typedef struct _tPRCRev28typedef struct _tPRCRev
@@ -53,7 +51,7 @@ void tPRCRev_setT60 (tPRCRev* const, float t60); · 22 unmodified lines
53// Set mix between dry input and wet output signal.51// Set mix between dry input and wet output signal.
54void tPRCRev_setMix (tPRCRev* const, float mix);52void tPRCRev_setMix (tPRCRev* const, float mix);
55 53
56// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~54//==============================================================================
57 55
58/* NRev: Reverb, reimplemented from STK (Cook and Scavone). */56/* NRev: Reverb, reimplemented from STK (Cook and Scavone). */
59typedef struct _tNRev57typedef struct _tNRev
@@ -83,7 +81,7 @@ void tNRev_setT60 (tNRev* const, float t60); · 23 unmodified lines
83// Set mix between dry input and wet output signal.81// Set mix between dry input and wet output signal.
84void tNRev_setMix (tNRev* const, float mix);82void tNRev_setMix (tNRev* const, float mix);
85 83
86// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~84//==============================================================================
87 85
88typedef struct _tDattorro86typedef struct _tDattorro
89{87{
@@ -145,4 +143,6 @@ void tDattorro_setFeedbackGain (tDattorro* const, float gain); · 55 unmodified lines
145}143}
146#endif144#endif
147 145
148#endif // LEAFREVERB_H_INCLUDED146#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
14extern "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
8 ==============================================================================8 ==============================================================================
9*/9*/
10 10
11#ifndef LEAF_STRING_H_INCLUDED
12#define LEAF_STRING_H_INCLUDED
13
11#ifdef __cplusplus14#ifdef __cplusplus
12extern "C" {15extern "C" {
13#endif16#endif
14 17
15// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~18//==============================================================================
16 19
17#include "leaf-globals.h"20#include "leaf-globals.h"
18#include "leaf-math.h"21#include "leaf-math.h"
@@ -21,7 +24,7 @@ extern "C" { · 2 unmodified lines
21#include "leaf-filter.h"24#include "leaf-filter.h"
22#include "leaf-oscillator.h"25#include "leaf-oscillator.h"
23 26
24// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~27//==============================================================================
25 28
26/* Karplus Strong model */29/* Karplus Strong model */
27typedef struct _tPluck30typedef struct _tPluck
@@ -62,9 +65,8 @@ void tPluck_controlChange (tPluck* const, int number, float value); · 34 unmodified lines
62// tPluck Utilities.65// tPluck Utilities.
63float tPluck_getLastOut (tPluck* const);66float tPluck_getLastOut (tPluck* const);
64 67
65 68//==============================================================================
66// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~69
67
68/* Stif Karplus Strong model */70/* Stif Karplus Strong model */
69typedef struct _tStifKarp71typedef struct _tStifKarp
70{72{
@@ -130,8 +132,12 @@ void tStifKarp_setBaseLoopGain (tStifKarp* const, float aGain ); · 59 unmodified lines
130// tStifKarp utilities.132// tStifKarp utilities.
131float tStifKarp_getLastOut (tStifKarp* const);133float tStifKarp_getLastOut (tStifKarp* const);
132 134
133// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~135//==============================================================================
134 136
135#ifdef __cplusplus137#ifdef __cplusplus
136}138}
137#endif139#endif
140
141#endif // LEAF_STRING_H_INCLUDED
142
143//==============================================================================
LEAF/Inc/leaf-utilities.h+17−17
@@ -1,26 +1,24 @@
1/*1/*==============================================================================
2 ==============================================================================
3 2
4 LEAFUtilities.h3 LEAFUtilities.h
5 Created: 20 Jan 2017 12:02:17pm4 Created: 20 Jan 2017 12:02:17pm
6 Author: Michael R Mulshine5 Author: Michael R Mulshine
7 6
8 ==============================================================================7==============================================================================*/
9*/
10 8
11#ifndef LEAFUTILITIES_H_INCLUDED9#ifndef LEAF_UTILITIES_H_INCLUDED
12#define LEAFUTILITIES_H_INCLUDED10#define LEAF_UTILITIES_H_INCLUDED
13 11
14#ifdef __cplusplus12#ifdef __cplusplus
15extern "C" {13extern "C" {
16#endif14#endif
17 15
18// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~16//==============================================================================
19 17
20#include "leaf-globals.h"18#include "leaf-globals.h"
21#include "leaf-math.h"19#include "leaf-math.h"
22 20
23// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~21//==============================================================================
24 22
25// STACK implementation (fixed size)23// STACK implementation (fixed size)
26#define STACK_SIZE 12824#define STACK_SIZE 128
@@ -48,7 +46,7 @@ int tStack_contains (tStack* const, uint16_t item); · 21 unmodified lines
48int tStack_next (tStack* const);46int tStack_next (tStack* const);
49int tStack_get (tStack* const, int which);47int tStack_get (tStack* const, int which);
50 48
51// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~49//==============================================================================
52 50
53/* Ramp */51/* Ramp */
54typedef struct _tRamp {52typedef struct _tRamp {
@@ -70,7 +68,7 @@ int tRamp_setTime (tRamp* const, float time); · 15 unmodified lines
70int tRamp_setDest (tRamp* const, float dest);68int tRamp_setDest (tRamp* const, float dest);
71int tRamp_setVal (tRamp* const, float val);69int tRamp_setVal (tRamp* const, float val);
72 70
73// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~71//==============================================================================
74 72
75/* Compressor */73/* Compressor */
76typedef struct _tCompressor74typedef struct _tCompressor
@@ -88,7 +86,7 @@ void tCompressor_init (tCompressor* const); · 11 unmodified lines
88void tCompressor_free (tCompressor* const);86void tCompressor_free (tCompressor* const);
89float tCompressor_tick (tCompressor* const, float input);87float tCompressor_tick (tCompressor* const, float input);
90 88
91// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~89//==============================================================================
92 90
93/* Attack-Decay envelope */91/* Attack-Decay envelope */
94typedef struct _tEnvelope {92typedef struct _tEnvelope {
@@ -120,7 +118,7 @@ int tEnvelope_setDecay (tEnvelope* const, float decay); · 25 unmodified lines
120int tEnvelope_loop (tEnvelope* const, oBool loop);118int tEnvelope_loop (tEnvelope* const, oBool loop);
121int tEnvelope_on (tEnvelope* const, float velocity);119int tEnvelope_on (tEnvelope* const, float velocity);
122 120
123// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~121//==============================================================================
124 122
125/* ADSR */123/* ADSR */
126typedef struct _tADSR124typedef struct _tADSR
@@ -152,7 +150,7 @@ int tADSR_setRelease(tADSR* const, float release); · 25 unmodified lines
152int tADSR_on (tADSR* const, float velocity);150int tADSR_on (tADSR* const, float velocity);
153int tADSR_off (tADSR* const);151int tADSR_off (tADSR* const);
154 152
155// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~153//==============================================================================
156 154
157/* Envelope Follower */155/* Envelope Follower */
158typedef struct _tEnvelopeFollower156typedef struct _tEnvelopeFollower
@@ -170,7 +168,7 @@ float tEnvelopeFollower_tick (tEnvelopeFollower* const, float x); · 11 unmodified lines
170int tEnvelopeFollower_decayCoeff (tEnvelopeFollower* const, float decayCoeff);168int tEnvelopeFollower_decayCoeff (tEnvelopeFollower* const, float decayCoeff);
171int tEnvelopeFollower_attackThresh (tEnvelopeFollower* const, float attackThresh);169int tEnvelopeFollower_attackThresh (tEnvelopeFollower* const, float attackThresh);
172 170
173// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~171//==============================================================================
174 172
175/* tAtkDtk */173/* tAtkDtk */
176#define DEFBLOCKSIZE 1024174#define DEFBLOCKSIZE 1024
@@ -221,7 +219,7 @@ void tAtkDtk_setThreshold (tAtkDtk* const, float thres); · 44 unmodified lines
221// find largest transient in input block, return index of attack219// find largest transient in input block, return index of attack
222int tAtkDtk_detect (tAtkDtk* const, float *in);220int tAtkDtk_detect (tAtkDtk* const, float *in);
223 221
224// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~222//==============================================================================
225 223
226// ENV~ from PD, modified for LEAF224// ENV~ from PD, modified for LEAF
227#define MAXOVERLAP 32225#define MAXOVERLAP 32
@@ -246,12 +244,14 @@ void tEnv_free (tEnv* const); · 18 unmodified lines
246float tEnv_tick (tEnv* const);244float tEnv_tick (tEnv* const);
247void tEnv_processBlock (tEnv* const, float* in);245void tEnv_processBlock (tEnv* const, float* in);
248 246
249// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~247//==============================================================================
250 248
251#ifdef __cplusplus249#ifdef __cplusplus
252}250}
253#endif251#endif
254 252
255#endif // LEAFUTILITIES_H_INCLUDED253#endif // LEAF_UTILITIES_H_INCLUDED
254
255//==============================================================================
256 256
257 257
LEAF/Inc/leaf-vocoder.h+11−11
@@ -1,26 +1,24 @@
1/*1/*==============================================================================
2 ==============================================================================
3 2
4 LEAFInstrument.h3 LEAFInstrument.h
5 Created: 20 Jan 2017 12:01:54pm4 Created: 20 Jan 2017 12:01:54pm
6 Author: Michael R Mulshine5 Author: Michael R Mulshine
7 6
8 ==============================================================================7==============================================================================*/
9*/
10 8
11#ifndef LEAFINSTRUMENT_H_INCLUDED9#ifndef LEAF_VOCODER_H_INCLUDED
12#define LEAFINSTRUMENT_H_INCLUDED10#define LEAF_VOCODER_H_INCLUDED
13 11
14#ifdef __cplusplus12#ifdef __cplusplus
15extern "C" {13extern "C" {
16#endif14#endif
17 15
18// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~16//==============================================================================
19 17
20#include "leaf-globals.h"18#include "leaf-globals.h"
21#include "leaf-math.h"19#include "leaf-math.h"
22 20
23// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~21//==============================================================================
24 22
25/* tTalkbox */23/* tTalkbox */
26#define NUM_TALKBOX_PARAM 424#define NUM_TALKBOX_PARAM 4
@@ -52,7 +50,7 @@ void tTalkbox_lpcDurbin (float *r, int p, float *k, float *g); · 25 unmodified lines
52void tTalkbox_lpc (float *buf, float *car, int32_t n, int32_t o);50void tTalkbox_lpc (float *buf, float *car, int32_t n, int32_t o);
53void tTalkbox_setQuality (tTalkbox* const, float quality);51void tTalkbox_setQuality (tTalkbox* const, float quality);
54 52
55// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~53//==============================================================================
56 54
57/* tVocoder */55/* tVocoder */
58#define NUM_VOCODER_PARAM 856#define NUM_VOCODER_PARAM 8
@@ -79,10 +77,12 @@ float tVocoder_tick (tVocoder* const, float synth, float voice); · 20 unmodified lines
79void tVocoder_update (tVocoder* const);77void tVocoder_update (tVocoder* const);
80void tVocoder_suspend (tVocoder* const);78void tVocoder_suspend (tVocoder* const);
81 79
82// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~80//==============================================================================
83 81
84#ifdef __cplusplus82#ifdef __cplusplus
85}83}
86#endif84#endif
87 85
88#endif // LEAFINSTRUMENT_H_INCLUDED86#endif // LEAF_VOCODER_H_INCLUDED
87
88//==============================================================================
LEAF/Inc/leaf-wavefolder.h+15−8
@@ -1,23 +1,25 @@
1/*1/*==============================================================================
2 ==============================================================================
3 2
4 leaf-wavefolder.h3 leaf-wavefolder.h
5 Created: 30 Nov 2018 11:57:05am4 Created: 30 Nov 2018 11:57:05am
6 Author: airship5 Author: airship
7 6
8 ==============================================================================7==============================================================================*/
9*/8
9#ifndef LEAF_WAVEFOLDER_H_INCLUDED
10#define LEAF_WAVEFOLDER_H_INCLUDED
11
10 12
11#ifdef __cplusplus13#ifdef __cplusplus
12extern "C" {14extern "C" {
13#endif15#endif
14 16
15// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~17//==============================================================================
16 18
17#include "leaf-globals.h"19#include "leaf-globals.h"
18#include "leaf-math.h"20#include "leaf-math.h"
19 21
20// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~22//==============================================================================
21 23
22/* tLockhartWavefolder */24/* tLockhartWavefolder */
23#define THRESH 10e-1025#define THRESH 10e-10
@@ -45,7 +47,12 @@ void tLockhartWavefolder_free (tLockhartWavefolder* const); · 21 unmodified lines
45float tLockhartWavefolder_tick (tLockhartWavefolder* const, float samp);47float tLockhartWavefolder_tick (tLockhartWavefolder* const, float samp);
46 48
47 49
50//==============================================================================
51
48#ifdef __cplusplus52#ifdef __cplusplus
49}53}
50#endif54#endif
51// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~55
56#endif // LEAF_WAVEFOLDER_H_INCLUDED
57
58//==============================================================================
LEAF/Inc/leaf-wavetables.h+13−13
@@ -1,26 +1,24 @@
1/*1/*==============================================================================
2 ==============================================================================
3 2
4 LEAFWavetables.h3 LEAFWavetables.h
5 Created: 4 Dec 2016 9:42:41pm4 Created: 4 Dec 2016 9:42:41pm
6 Author: Michael R Mulshine5 Author: Michael R Mulshine
7 6
8 ==============================================================================7==============================================================================*/
9*/
10 8
11#ifndef WAVETABLES_H_INCLUDED9#ifndef LEAF_WAVETABLES_H_INCLUDED
12#define WAVETABLES_H_INCLUDED10#define LEAF_WAVETABLES_H_INCLUDED
13 11
14#ifdef __cplusplus12#ifdef __cplusplus
15extern "C" {13extern "C" {
16#endif14#endif
17 15
18// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~16//==============================================================================
19 17
20#include "leaf-globals.h"18#include "leaf-globals.h"
21#include "leaf-math.h"19#include "leaf-math.h"
22 20
23// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~21//==============================================================================
24 22
25 23
26#define SINE_TABLE_SIZE 204824#define SINE_TABLE_SIZE 2048
@@ -62,7 +60,7 @@ extern const float decayCoeffTable[DECAY_COEFF_TABLE_SIZE]; · 35 unmodified lines
62 60
63extern const float tanh1[TANH1_TABLE_SIZE];61extern const float tanh1[TANH1_TABLE_SIZE];
64 62
65// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~63//==============================================================================
66 64
67/* Sine wave table ripped from http://aquaticus.info/pwm-sine-wave. */65/* Sine wave table ripped from http://aquaticus.info/pwm-sine-wave. */
68extern const float sinewave[SINE_TABLE_SIZE];66extern const float sinewave[SINE_TABLE_SIZE];
@@ -73,10 +71,12 @@ extern const float triangle[11][TRI_TABLE_SIZE]; · 4 unmodified lines
73 71
74extern const float squarewave[11][SQR_TABLE_SIZE];72extern const float squarewave[11][SQR_TABLE_SIZE];
75 73
76// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~74//==============================================================================
77 75
78#ifdef __cplusplus76#ifdef __cplusplus
79}77}
80#endif78#endif
81 79
82#endif // WAVETABLES_H_INCLUDED80#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
159 } else {159 } else {
160 return val;160 return val;
161 }161 }
162}162}
163
164int 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
163 175
164oBool LEAF_isPrime(uint64_t number )176oBool LEAF_isPrime(uint64_t number )
165{177{
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
26void 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
39void tSample_free (tSample* const s)
40{
41 leaf_free(s->buff);
42 leaf_free(s);
43}
44
45void 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
67void 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
76float 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
83void tSample_start(tSample* const s)
84{
85 s->active = 1;
86 s->idx = 0;
87}
88
89void tSample_stop(tSample* const s)
90{
91 s->active = 0;
92}
93
94void tSample_setRecordMode (tSample* const s, RecordMode mode)
95{
96 s->mode = mode;
97}
98
99void 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
109void 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
128void tSamplePlayer_free (tSamplePlayer* const p)
129{
130 leaf_free(p->samp);
131 leaf_free(p);
132}
133
134float 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
188void tSamplePlayer_setSample (tSamplePlayer* const p, tSample* s)
189{
190 p->samp = s;
191}
192
193void tSamplePlayer_setMode (tSamplePlayer* const p, Mode mode)
194{
195 p->mode = mode;
196}
197
198void tSamplePlayer_play (tSamplePlayer* const p)
199{
200 p->active = 1;
201}
202
203void tSamplePlayer_stop (tSamplePlayer* const p)
204{
205 p->active = 0;
206}
207
208void 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
218void 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
228void 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
31#include ".\Inc\leaf-string.h"31#include ".\Inc\leaf-string.h"
32#include ".\Inc\leaf-pitch.h"32#include ".\Inc\leaf-pitch.h"
33#include ".\Inc\leaf-formant.h"33#include ".\Inc\leaf-formant.h"
34#include ".\Inc\leaf-midi.h"34#include ".\Inc\leaf-midi.h"
35#include ".\Inc\leaf-sample.h"
35#include ".\Inc\leaf-wavefolder.h"36#include ".\Inc\leaf-wavefolder.h"
36#include ".\Inc\leaf-wavetables.h"37#include ".\Inc\leaf-wavetables.h"
37 38
@@ -49,7 +50,8 @@ · 11 unmodified lines
49#include "./Inc/leaf-string.h"50#include "./Inc/leaf-string.h"
50#include "./Inc/leaf-pitch.h"51#include "./Inc/leaf-pitch.h"
51#include "./Inc/leaf-formant.h"52#include "./Inc/leaf-formant.h"
52#include "./Inc/leaf-midi.h"53#include "./Inc/leaf-midi.h"
54#include "./Inc/leaf-sample.h"
53#include "./Inc/leaf-wavefolder.h"55#include "./Inc/leaf-wavefolder.h"
54#include "./Inc/leaf-wavetables.h"56#include "./Inc/leaf-wavetables.h"
55 57
LEAF_JUCEPlugin/LEAF.jucer+2−0
@@ -39,6 +39,7 @@ · 38 unmodified lines
39 <FILE id="OS2D83" name="leaf-utilities.h" compile="0" resource="0"39 <FILE id="OS2D83" name="leaf-utilities.h" compile="0" resource="0"
40 file="../LEAF/Inc/leaf-utilities.h"/>40 file="../LEAF/Inc/leaf-utilities.h"/>
41 <FILE id="Szb5LP" name="leaf-vocoder.h" compile="0" resource="0" file="../LEAF/Inc/leaf-vocoder.h"/>41 <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"/>
42 <FILE id="PRkOp2" name="leaf-wavefolder.h" compile="0" resource="0"43 <FILE id="PRkOp2" name="leaf-wavefolder.h" compile="0" resource="0"
43 file="../LEAF/Inc/leaf-wavefolder.h"/>44 file="../LEAF/Inc/leaf-wavefolder.h"/>
44 <FILE id="KpGzKv" name="leaf-wavetables.h" compile="0" resource="0"45 <FILE id="KpGzKv" name="leaf-wavetables.h" compile="0" resource="0"
@@ -60,6 +61,7 @@ · 15 unmodified lines
60 <FILE id="uKHzgz" name="leaf-utilities.c" compile="1" resource="0"61 <FILE id="uKHzgz" name="leaf-utilities.c" compile="1" resource="0"
61 file="../LEAF/Src/leaf-utilities.c"/>62 file="../LEAF/Src/leaf-utilities.c"/>
62 <FILE id="u1aLLR" name="leaf-vocoder.c" compile="1" resource="0" file="../LEAF/Src/leaf-vocoder.c"/>63 <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"/>
63 <FILE id="LVoaGm" name="leaf-wavefolder.c" compile="1" resource="0"65 <FILE id="LVoaGm" name="leaf-wavefolder.c" compile="1" resource="0"
64 file="../LEAF/Src/leaf-wavefolder.c"/>66 file="../LEAF/Src/leaf-wavefolder.c"/>
65 <FILE id="HRk07h" name="leaf-wavetables.c" compile="1" resource="0"67 <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
15 15
16std::vector<juce::String> cButtonNames = std::vector<juce::String>16std::vector<juce::String> cButtonNames = std::vector<juce::String>
17{17{
18 18 "sample"
19};19};
20 20
21std::vector<juce::String> cSliderNames = std::vector<juce::String>21std::vector<juce::String> cSliderNames = std::vector<juce::String>
22{22{
23 "mix",23 "rate",
24 "predelay",24 "start",
25 "input filter",25 "end"
26 "feedback filter",
27 "feedback gain",
28 "size"
29};26};
30 27
31std::vector<juce::String> cComboBoxNames = std::vector<juce::String>28std::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
16static void leaf_pool_dump(void);16static void leaf_pool_dump(void);
17static void run_pool_test(void);17static void run_pool_test(void);
18 18
19tDattorro reverb;19tSample sample;
20
21
22tTapeDelay delay;
23
24float size;
25tRamp dtime;
26 20
21tSamplePlayer player;
27 22
28void LEAFTest_init (float sampleRate, int blockSize)23void LEAFTest_init (float sampleRate, int blockSize)
29{24{
30 LEAF_init(sampleRate, blockSize, &randomNumberGenerator);25 LEAF_init(sampleRate, blockSize, &randomNumberGenerator);
31 26
32 tDattorro_init(&reverb);27 tSample_init(&sample, leaf.sampleRate * 4);
33
34 //tTapeDelay_init(&delay, 0.5f * leaf.sampleRate, leaf.sampleRate);
35
36 tRamp_init(&dtime, 500.0f, 1);
37 28
38 29 tSamplePlayer_init(&player, &sample);
39 setSliderValue("mix", reverb.mix);30 tSamplePlayer_setMode(&player, Loop);
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);
45 31
32 leaf_pool_report();
46 33
47 leaf_pool_report();34 tSample_start(&sample);
48}35}
49 36
50int timer = 0;37int timer = 0;
51
52
53#define CLICK 0
54 38
55float LEAFTest_tick (float input)39float LEAFTest_tick (float input)
56{40{
57#if CLICK41 tSample_tick(&sample, input);
58 input = 0.0f;
59 42
60 timer++;43 timer++;
61 if (timer == (1 * leaf.sampleRate))44
45 if (timer >= leaf.sampleRate * 4)
62 {46 {
63 timer = 0;47 tSamplePlayer_play(&player);
64
65 input = 1.0f;
66 }48 }
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);
76 49
50 return tSamplePlayer_tick(&player);
77}51}
78 52
53bool lastState = false;
79void LEAFTest_block (void)54void LEAFTest_block (void)
80{55{
81 56 float val = getSliderValue("rate");
82 float val = getSliderValue("mix");
83 tDattorro_setMix(&reverb, val);
84 57
85 val = getSliderValue("predelay");58 tSamplePlayer_setRate(&player, val * 16.0f - 8.0f);
86 tDattorro_setInputDelay(&reverb, val * 200.0f);
87 59
88 val = getSliderValue("input filter");60 val = getSliderValue("start");
89 tDattorro_setInputFilter(&reverb, val * 20000.0f);61 float start = val * sample.length;
62 tSamplePlayer_setStart(&player, start);
63 DBG("start: " + String(start));
90 64
91 val = getSliderValue("feedback filter");65 val = getSliderValue("end");
92 tDattorro_setFeedbackFilter(&reverb, val * 20000.0f);66 float end = val * sample.length;
67 tSamplePlayer_setEnd(&player, end);
68 DBG("end: " + String(end));
93 69
94 val = getSliderValue("feedback gain");70 bool state = getButtonState("sample");
95 tDattorro_setFeedbackGain(&reverb, val);
96
97 val = getSliderValue("size");
98 tRamp_setDest(&dtime, val * reverb.size_max);
99 71
72 if (state && !lastState)
73 {
74 timer = 0;
75 tSamplePlayer_stop(&player);
76 tSample_start(&sample);
77 }
100 78
101 //float val = getSliderValue("size");79 lastState = state;
102 //tRamp_setDest(&dtime, val * leaf.sampleRate + 1);
103
104}80}
105 81
106void LEAFTest_controllerInput (int cnum, float cval)82void 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
144 setSliderValue(s->getName(), s->getValue());144 setSliderValue(s->getName(), s->getValue());
145}145}
146 146
147void UIComponent::buttonClicked (Button* b)147void UIComponent::buttonStateChanged (Button* b)
148{148{
149 setButtonState(b->getName(), true);149 setButtonState(b->getName(), b->getState());
150}150}
151 151
152void UIComponent::comboBoxChanged (ComboBox* cb)152void UIComponent::comboBoxChanged (ComboBox* cb)
LEAF_JUCEPlugin/Source/UIComponent.h+2−1
@@ -35,7 +35,8 @@ public: · 34 unmodified lines
35 35
36 void sliderValueChanged(Slider* s) override;36 void sliderValueChanged(Slider* s) override;
37 37
38 void buttonClicked (Button* b) override;38 void buttonClicked(Button*b) override {};
39 void buttonStateChanged(Button* b) override;
39 40
40 void textEditorTextChanged (TextEditor&) override;41 void textEditorTextChanged (TextEditor&) override;
41 42

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