History

Cleaned up some file headers. Implemented tCrusher, bit/sample reduction bitcrusher / shaper.

mulshine committed 7 years ago

Commit 3ada2d41 parent b0cf3f132 files · +840 −662Browse files

Unified · Split

32 files
  1. LEAF/Inc/leaf-808.h +1 −1
  2. LEAF/Inc/leaf-crusher.h +64 −0
  3. LEAF/Inc/leaf-delay.h +1 −1
  4. LEAF/Inc/leaf-filter.h +1 −1
  5. LEAF/Inc/leaf-globals.h +5 −0
  6. LEAF/Inc/leaf-math.h +45 −41
  7. LEAF/Inc/leaf-oscillator.h +1 −1
  8. LEAF/Inc/leaf-reverb.h +1 −1
  9. LEAF/Inc/leaf-sample.h +67 −67
  10. LEAF/Inc/leaf-utilities.h +1 −1
  11. LEAF/Inc/leaf-vocoder.h +1 −1
  12. LEAF/Inc/leaf-wavefolder.h +18 −18
  13. LEAF/Inc/leaf-wavetables.h +1 −1
  14. LEAF/Src/leaf-808.c +3 −5
  15. LEAF/Src/leaf-crusher.c +84 −0
  16. LEAF/Src/leaf-delay.c +3 −5
  17. LEAF/Src/leaf-filter.c +3 −5
  18. LEAF/Src/leaf-formant.c +3 −5
  19. LEAF/Src/leaf-math.c +48 −6
  20. LEAF/Src/leaf-midi.c +3 −5
  21. LEAF/Src/leaf-oscillator.c +3 −5
  22. LEAF/Src/leaf-pitch.c +3 −5
  23. LEAF/Src/leaf-reverb.c +3 −5
  24. LEAF/Src/leaf-sample.c +406 −406
  25. LEAF/Src/leaf-string.c +3 −5
  26. LEAF/Src/leaf-utilities.c +3 −5
  27. LEAF/Src/leaf-vocoder.c +3 −5
  28. LEAF/Src/leaf-wavefolder.c +3 −5
  29. LEAF/leaf.h +4 −2
  30. LEAF_JUCEPlugin/LEAF.jucer +2 −0
  31. LEAF_JUCEPlugin/Source/LEAFLink.cpp +6 −6
  32. LEAF_JUCEPlugin/Source/MyTest.cpp +47 −48
LEAF/Inc/leaf-808.h+1−1
@@ -1,6 +1,6 @@
1/*==============================================================================1/*==============================================================================
2 2
3 leaf_808.h3 leaf-808.h
4 Created: 30 Nov 2018 10:24:44am4 Created: 30 Nov 2018 10:24:44am
5 Author: airship5 Author: airship
6 6
LEAF/Inc/leaf-crusher.h+64−0
@@ -0,0 +1,64 @@
1/*
2 ==============================================================================
3
4 leaf-crusher.h
5 Created: 7 Feb 2019 10:58:22am
6 Author: airship
7
8 ==============================================================================
9*/
10
11#ifndef LEAF_CRUSHER_H_INCLUDED
12#define LEAF_CRUSHER_H_INCLUDED
13
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19//==============================================================================
20
21#include "leaf-globals.h"
22#include "leaf-math.h"
23
24//==============================================================================
25
26typedef struct _tCrusher
27{
28 float srr;
29 float mult, div;
30 float rnd;
31
32 uint32_t op; //which bitwise operation (0-7)
33
34 float gain;
35
36} tCrusher;
37
38
39void tCrusher_init (tCrusher* const);
40void tCrusher_free (tCrusher* const);
41
42float tCrusher_tick (tCrusher* const, float input);
43
44// 0-7
45void tCrusher_setOperation (tCrusher* const, uint32_t op);
46
47// 0.0 - 1.0
48void tCrusher_setQuality (tCrusher* const, float val);
49
50// what division to round to
51void tCrusher_setRound (tCrusher* const, float rnd);
52
53// sampling ratio
54void tCrusher_setSamplingRatio (tCrusher* const, float ratio);
55
56//==============================================================================
57
58#ifdef __cplusplus
59}
60#endif
61
62#endif // LEAF_WAVEFOLDER_H_INCLUDED
63
64//==============================================================================
LEAF/Inc/leaf-delay.h+1−1
@@ -1,6 +1,6 @@
1/*==============================================================================1/*==============================================================================
2 2
3 LEAFDelay.h3 leaf-delay.h
4 Created: 20 Jan 2017 12:01:24pm4 Created: 20 Jan 2017 12:01:24pm
5 Author: Michael R Mulshine5 Author: Michael R Mulshine
6 6
LEAF/Inc/leaf-filter.h+1−1
@@ -1,6 +1,6 @@
1/*==============================================================================1/*==============================================================================
2 2
3 LEAFFilter.h3 leaf-filter.h
4 Created: 20 Jan 2017 12:01:10pm4 Created: 20 Jan 2017 12:01:10pm
5 Author: Michael R Mulshine5 Author: Michael R Mulshine
6 6
LEAF/Inc/leaf-globals.h+5−0
@@ -60,6 +60,11 @@ extern const float shaper1[SHAPER1_TABLE_SIZE]; · 59 unmodified lines
60#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
61 61
62 62
63union unholy_t { /* a union between a float and an integer */
64 float f;
65 int i;
66};
67
63//==============================================================================68//==============================================================================
64 69
65#ifdef __cplusplus70#ifdef __cplusplus
LEAF/Inc/leaf-math.h+45−41
@@ -1,22 +1,22 @@
1/*==============================================================================1/*==============================================================================
2 2
3 LEAFMath.h3 leaf-math.h
4 Created: 22 Jan 2017 7:02:56pm4 Created: 22 Jan 2017 7:02:56pm
5 Author: Michael R Mulshine5 Author: Michael R Mulshine
6 6
7==============================================================================*/7==============================================================================*/
8 8
9#ifndef LEAF_MATH_H_INCLUDED9#ifndef LEAF_MATH_H_INCLUDED
10#define LEAF_MATH_H_INCLUDED10#define LEAF_MATH_H_INCLUDED
11 11
12#ifdef __cplusplus12#ifdef __cplusplus
13extern "C" {13extern "C" {
14#endif14#endif
15 15
16#include "math.h"16#include "math.h"
17#include "stdint.h"17#include "stdint.h"
18#include "stdlib.h"18#include "stdlib.h"
19 19
20//==============================================================================20//==============================================================================
21 21
22typedef enum oBool22typedef enum oBool
@@ -76,47 +76,51 @@ typedef enum oBool · 53 unmodified lines
76 76
77// Jones shaper77// Jones shaper
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
81float LEAF_reduct (float input, float srr);
82float LEAF_round (float input, float rnd);
83float LEAF_bitwise_or(float input, uint32_t op);
80 84
81float LEAF_clip (float min, float val, float max);85float LEAF_clip (float min, float val, float max);
82int LEAF_clipInt (int min, int val, int max);86int LEAF_clipInt (int min, int val, int max);
83float LEAF_softClip (float val, float thresh);87float LEAF_softClip (float val, float thresh);
84oBool LEAF_isPrime (uint64_t number );88oBool LEAF_isPrime (uint64_t number );
85 89
86float LEAF_midiToFrequency (float f);90float LEAF_midiToFrequency (float f);
87float LEAF_frequencyToMidi(float f);91float LEAF_frequencyToMidi(float f);
88 92
89void LEAF_generate_sine (float* buffer, int size);93void LEAF_generate_sine (float* buffer, int size);
90void LEAF_generate_sawtooth (float* buffer, float basefreq, int size);94void LEAF_generate_sawtooth (float* buffer, float basefreq, int size);
91void LEAF_generate_triangle (float* buffer, float basefreq, int size);95void LEAF_generate_triangle (float* buffer, float basefreq, int size);
92void LEAF_generate_square (float* buffer, float basefreq, int size);96void LEAF_generate_square (float* buffer, float basefreq, int size);
93 97
94// dope af98// dope af
95float LEAF_chebyshevT(float in, int n);99float LEAF_chebyshevT(float in, int n);
96float LEAF_CompoundChebyshevT(float in, int n, float* amps);100float LEAF_CompoundChebyshevT(float in, int n, float* amps);
97
98
99// Hermite interpolation
100float LEAF_interpolate_hermite (float A, float B, float C, float D, float t);
101float LEAF_interpolation_linear (float A, float B, float t);
102
103float interpolate3max(float *buf, const int peakindex);
104float interpolate3phase(float *buf, const int peakindex);
105
106// alternative implementation for abs()
107// REQUIRES: 32 bit integers
108int fastabs_int(int in);
109
110// alternative implementation for abs()
111// REQUIRES: 32 bit floats
112float fastabs(float f);
113
114//==============================================================================
115
116#ifdef __cplusplus
117}
118#endif
119 101
120#endif // LEAF_MATH_H_INCLUDED102
121 103// Hermite interpolation
104float LEAF_interpolate_hermite (float A, float B, float C, float D, float t);
105float LEAF_interpolation_linear (float A, float B, float t);
106
107float interpolate3max(float *buf, const int peakindex);
108float interpolate3phase(float *buf, const int peakindex);
109
110// alternative implementation for abs()
111// REQUIRES: 32 bit integers
112int fastabs_int(int in);
113
114// alternative implementation for abs()
115// REQUIRES: 32 bit floats
116float fastabs(float f);
117
118//==============================================================================
119
120#ifdef __cplusplus
121}
122#endif
123
124#endif // LEAF_MATH_H_INCLUDED
125
122//==============================================================================126//==============================================================================
LEAF/Inc/leaf-oscillator.h+1−1
@@ -1,6 +1,6 @@
1/*==============================================================================1/*==============================================================================
2 2
3 LEAFOscillator.h3 leaf-oscillator.h
4 Created: 20 Jan 2017 12:00:58pm4 Created: 20 Jan 2017 12:00:58pm
5 Author: Michael R Mulshine5 Author: Michael R Mulshine
6 6
LEAF/Inc/leaf-reverb.h+1−1
@@ -1,6 +1,6 @@
1/*==============================================================================1/*==============================================================================
2 2
3 LEAFReverb.h3 leaf-reverb.h
4 Created: 20 Jan 2017 12:02:04pm4 Created: 20 Jan 2017 12:02:04pm
5 Author: Michael R Mulshine5 Author: Michael R Mulshine
6 6
LEAF/Inc/leaf-sample.h+67−67
@@ -17,8 +17,8 @@ extern "C" { · 16 unmodified lines
17//==============================================================================17//==============================================================================
18 18
19#include "leaf-globals.h"19#include "leaf-globals.h"
20#include "leaf-math.h"20#include "leaf-math.h"
21 21
22#include "leaf-utilities.h"22#include "leaf-utilities.h"
23 23
24//==============================================================================24//==============================================================================
@@ -34,11 +34,11 @@ extern "C" { · 9 unmodified lines
34 {34 {
35 float* buff;35 float* buff;
36 36
37 uint32_t idx;37 uint32_t idx;
38 uint32_t length;38 uint32_t length;
39 39
40 RecordMode mode;40 RecordMode mode;
41 41
42 int active;42 int active;
43 43
44 } tBuffer;44 } tBuffer;
@@ -46,72 +46,72 @@ extern "C" { · 1 unmodified line
46 void tBuffer_init (tBuffer* const, uint32_t length);46 void tBuffer_init (tBuffer* const, uint32_t length);
47 void tBuffer_free (tBuffer* const);47 void tBuffer_free (tBuffer* const);
48 48
49 void tBuffer_tick (tBuffer* const, float sample);49 void tBuffer_tick (tBuffer* const, float sample);
50 50
51 void tBuffer_read(tBuffer* const, float* buff, uint32_t len);51 void tBuffer_read(tBuffer* const, float* buff, uint32_t len);
52 52
53 float tBuffer_get (tBuffer* const, int idx);53 float tBuffer_get (tBuffer* const, int idx);
54 54
55 void tBuffer_record (tBuffer* const);55 void tBuffer_record (tBuffer* const);
56 void tBuffer_stop (tBuffer* const);56 void tBuffer_stop (tBuffer* const);
57 57
58 void tBuffer_setRecordMode (tBuffer* const, RecordMode mode);58 void tBuffer_setRecordMode (tBuffer* const, RecordMode mode);
59 59
60 void tBuffer_clear (tBuffer* const);60 void tBuffer_clear (tBuffer* const);
61 61
62//==============================================================================62//==============================================================================
63 63
64 typedef enum Mode64 typedef enum Mode
65 {65 {
66 Normal,66 Normal,
67 Loop,67 Loop,
68 BackAndForth,68 BackAndForth,
69 SampleModeNil69 SampleModeNil
70 } Mode;70 } Mode;
71 71
72 typedef struct _tSampler72 typedef struct _tSampler
73 {73 {
74 tBuffer* samp;74 tBuffer* samp;
75 75
76 tRamp gain;76 tRamp gain;
77 77
78 float idx;78 float idx;
79 float inc;79 float inc;
80 float iinc;80 float iinc;
81 int8_t dir;81 int8_t dir;
82 int8_t flip;82 int8_t flip;
83 int8_t bnf;83 int8_t bnf;
84 84
85 int32_t start;85 int32_t start;
86 int32_t end;86 int32_t end;
87 uint32_t len;87 uint32_t len;
88 uint32_t cfxlen;88 uint32_t cfxlen;
89 89
90 Mode mode;90 Mode mode;
91 int retrigger;91 int retrigger;
92 92
93 int active;93 int active;
94 94
95 } tSampler;95 } tSampler;
96 96
97 void tSampler_init (tSampler* const, tBuffer* s);97 void tSampler_init (tSampler* const, tBuffer* s);
98 void tSampler_free (tSampler* const);98 void tSampler_free (tSampler* const);
99 99
100 float tSampler_tick (tSampler* const);100 float tSampler_tick (tSampler* const);
101 101
102 void tSampler_setSample (tSampler* const, tBuffer* s);102 void tSampler_setSample (tSampler* const, tBuffer* s);
103 103
104 void tSampler_setMode (tSampler* const, Mode mode);104 void tSampler_setMode (tSampler* const, Mode mode);
105 105
106 void tSampler_play (tSampler* const);106 void tSampler_play (tSampler* const);
107 void tSampler_stop (tSampler* const);107 void tSampler_stop (tSampler* const);
108 108
109 void tSampler_setStart (tSampler* const, int32_t start);109 void tSampler_setStart (tSampler* const, int32_t start);
110 void tSampler_setEnd (tSampler* const, int32_t end);110 void tSampler_setEnd (tSampler* const, int32_t end);
111 111
112 void tSampler_setCrossfadeLength (tSampler* const p, uint32_t length);112 void tSampler_setCrossfadeLength (tSampler* const p, uint32_t length);
113 113
114 void tSampler_setRate (tSampler* const, float rate);114 void tSampler_setRate (tSampler* const, float rate);
115 115
116//==============================================================================116//==============================================================================
117 117
LEAF/Inc/leaf-utilities.h+1−1
@@ -1,6 +1,6 @@
1/*==============================================================================1/*==============================================================================
2 2
3 LEAFUtilities.h3 leaf-utilities.h
4 Created: 20 Jan 2017 12:02:17pm4 Created: 20 Jan 2017 12:02:17pm
5 Author: Michael R Mulshine5 Author: Michael R Mulshine
6 6
LEAF/Inc/leaf-vocoder.h+1−1
@@ -1,6 +1,6 @@
1/*==============================================================================1/*==============================================================================
2 2
3 LEAFInstrument.h3 leaf-vocoder.h
4 Created: 20 Jan 2017 12:01:54pm4 Created: 20 Jan 2017 12:01:54pm
5 Author: Michael R Mulshine5 Author: Michael R Mulshine
6 6
LEAF/Inc/leaf-wavefolder.h+18−18
@@ -4,14 +4,14 @@ · 3 unmodified lines
4 Created: 30 Nov 2018 11:57:05am4 Created: 30 Nov 2018 11:57:05am
5 Author: airship5 Author: airship
6 6
7==============================================================================*/7==============================================================================*/
8 8
9#ifndef LEAF_WAVEFOLDER_H_INCLUDED9#ifndef LEAF_WAVEFOLDER_H_INCLUDED
10#define LEAF_WAVEFOLDER_H_INCLUDED10#define LEAF_WAVEFOLDER_H_INCLUDED
11 11
12 12
13#ifdef __cplusplus13#ifdef __cplusplus
14extern "C" {14extern "C" {
15#endif15#endif
16 16
17//==============================================================================17//==============================================================================
@@ -45,14 +45,14 @@ void tLockhartWavefolder_init (tLockhartWavefolder* const); · 27 unmodified lines
45void tLockhartWavefolder_free (tLockhartWavefolder* const);45void tLockhartWavefolder_free (tLockhartWavefolder* const);
46 46
47float tLockhartWavefolder_tick (tLockhartWavefolder* const, float samp);47float tLockhartWavefolder_tick (tLockhartWavefolder* const, float samp);
48 48
49 49
50//==============================================================================50//==============================================================================
51 51
52#ifdef __cplusplus52#ifdef __cplusplus
53}53}
54#endif54#endif
55 55
56#endif // LEAF_WAVEFOLDER_H_INCLUDED56#endif // LEAF_WAVEFOLDER_H_INCLUDED
57 57
58//==============================================================================58//==============================================================================
LEAF/Inc/leaf-wavetables.h+1−1
@@ -1,6 +1,6 @@
1/*==============================================================================1/*==============================================================================
2 2
3 LEAFWavetables.h3 leaf-wavetables.h
4 Created: 4 Dec 2016 9:42:41pm4 Created: 4 Dec 2016 9:42:41pm
5 Author: Michael R Mulshine5 Author: Michael R Mulshine
6 6
LEAF/Src/leaf-808.c+3−5
@@ -1,12 +1,10 @@
1/*1/*==============================================================================
2 ==============================================================================
3 2
4 leaf_808.cpp3 leaf-808.c
5 Created: 30 Nov 2018 10:24:21am4 Created: 30 Nov 2018 10:24:21am
6 Author: airship5 Author: airship
7 6
8 ==============================================================================7==============================================================================*/
9*/
10 8
11#if _WIN32 || _WIN649#if _WIN32 || _WIN64
12 10
LEAF/Src/leaf-crusher.c+84−0
@@ -0,0 +1,84 @@
1/*==============================================================================
2
3 leaf-crusher.c
4 Created: 30 Nov 2018 11:56:49am
5 Author: airship
6
7==============================================================================*/
8
9#if _WIN32 || _WIN64
10
11#include "..\Inc\leaf-crusher.h"
12
13#else
14
15#include "../Inc/leaf-crusher.h"
16
17#endif
18
19//==============================================================================
20
21#define SCALAR 5000.f
22
23void tCrusher_init (tCrusher* const c)
24{
25 c->op = 4;
26 c->div = SCALAR;
27 c->rnd = 0.25f;
28 c->srr = 0.25f;
29
30 c->gain = (c->div / SCALAR) * 0.7f + 0.3f;
31}
32
33void tCrusher_free (tCrusher* const c)
34{
35 leaf_free(c);
36}
37
38float tCrusher_tick (tCrusher* const c, float input)
39{
40 float sample = input;
41
42 sample *= SCALAR; // SCALAR is 5000 by default
43
44 sample = floorf(sample);
45
46 sample /= c->div;
47
48 sample = LEAF_bitwise_or(sample, c->op << 23);
49
50 sample = LEAF_clip(-1.f, sample, 1.f);
51
52 sample = LEAF_round(sample, c->rnd);
53
54 sample = LEAF_reduct(sample, c->srr);
55
56 return sample * c->gain;
57
58}
59
60void tCrusher_setOperation (tCrusher* const c, uint32_t op)
61{
62 c->op = op % 8;
63}
64
65// 0.0 - 1.0
66void tCrusher_setQuality (tCrusher* const c, float val)
67{
68 val = LEAF_clip(0.0f, val, 1.0f);
69
70 c->div = 0.01f + val * SCALAR;
71
72 c->gain = (c->div / SCALAR) * 0.7f + 0.3f;
73}
74
75// what decimal to round to
76void tCrusher_setRound (tCrusher* const c, float rnd)
77{
78 c->rnd = fabsf(rnd);
79}
80
81void tCrusher_setSamplingRatio (tCrusher* const c, float ratio)
82{
83 c->srr = ratio;
84}
LEAF/Src/leaf-delay.c+3−5
@@ -1,12 +1,10 @@
1/*1/*==============================================================================
2 ==============================================================================
3 2
4 LEAFDelay.c3 leaf-delay.c
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#if _WIN32 || _WIN649#if _WIN32 || _WIN64
12 10
LEAF/Src/leaf-filter.c+3−5
@@ -1,12 +1,10 @@
1/*1/*==============================================================================
2 ==============================================================================
3 2
4 LEAFFilter.c3 leaf-filter.c
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#if _WIN32 || _WIN649#if _WIN32 || _WIN64
12 10
LEAF/Src/leaf-formant.c+3−5
@@ -1,12 +1,10 @@
1/*1/*==============================================================================
2 ==============================================================================
3 2
4 leaf-formant.cpp3 leaf-formant.c
5 Created: 30 Nov 2018 11:03:30am4 Created: 30 Nov 2018 11:03:30am
6 Author: airship5 Author: airship
7 6
8 ==============================================================================7==============================================================================*/
9*/
10 8
11#if _WIN32 || _WIN649#if _WIN32 || _WIN64
12 10
LEAF/Src/leaf-math.c+48−6
@@ -1,12 +1,10 @@
1/*1/*==============================================================================
2 ==============================================================================
3 2
4 LEAFMath.c3 leaf-math.c
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#if _WIN32 || _WIN649#if _WIN32 || _WIN64
12 10
@@ -24,7 +22,7 @@ · 11 unmodified lines
24#define TWO_TO_16 65536.f22#define TWO_TO_16 65536.f
25 23
26#define EXPONENTIAL_TABLE_SIZE 6553624#define EXPONENTIAL_TABLE_SIZE 65536
27 25
28 26
29float interpolate3max(float *buf, const int peakindex)27float interpolate3max(float *buf, const int peakindex)
30{28{
@@ -119,6 +117,50 @@ float LEAF_shaper(float input, float m_drive) · 88 unmodified lines
119 float shaperOut = w*(c+ 0.05f*xc2)*(m_drive + 0.75f);117 float shaperOut = w*(c+ 0.05f*xc2)*(m_drive + 0.75f);
120 shaperOut *= 0.5f; // post_scale118 shaperOut *= 0.5f; // post_scale
121 return shaperOut;119 return shaperOut;
120}
121
122// reduce sample resolution
123float LEAF_reduct (float input, float sr)
124{
125 float samp = input;
126
127 samp *= sr;
128
129 // method 1
130 samp = ceilf(samp);
131
132 samp /= sr;
133
134 /*
135 // method 2
136 samp = floorf(samp + 0.5f) - 0.5f;
137
138 samp /= srr;
139 */
140
141 return samp;
142}
143
144// round input to nearest rnd
145float LEAF_round (float input, float rnd)
146{
147 rnd = fabsf(rnd);
148
149 if (rnd <= 0.0000001f) return input;
150
151 float scale = 1.f / rnd;
152
153 return roundf(input * scale) / scale;
154}
155
156union unholy_t unholy;
157
158float LEAF_bitwise_or(float input, uint32_t op)
159{
160 unholy.f = input;
161 unholy.i = (unholy.i | op);
162
163 return unholy.f;
122}164}
123 165
124float LEAF_reedTable(float input, float offset, float slope) 166float LEAF_reedTable(float input, float offset, float slope)
LEAF/Src/leaf-midi.c+3−5
@@ -1,12 +1,10 @@
1/*1/*==============================================================================
2 ==============================================================================
3 2
4 leaf-midi.cpp3 leaf-midi.c
5 Created: 30 Nov 2018 11:29:16am4 Created: 30 Nov 2018 11:29:16am
6 Author: airship5 Author: airship
7 6
8 ==============================================================================7==============================================================================*/
9*/
10 8
11#if _WIN32 || _WIN649#if _WIN32 || _WIN64
12 10
LEAF/Src/leaf-oscillator.c+3−5
@@ -1,12 +1,10 @@
1/*1/*==============================================================================
2 ==============================================================================
3 2
4 LEAFOscillator.c3 leaf-oscillator.c
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#if _WIN32 || _WIN649#if _WIN32 || _WIN64
12 10
LEAF/Src/leaf-pitch.c+3−5
@@ -1,12 +1,10 @@
1/*1/*==============================================================================
2 ==============================================================================
3 2
4 leaf-pitch.cpp3 leaf-pitch.c
5 Created: 30 Nov 2018 11:02:59am4 Created: 30 Nov 2018 11:02:59am
6 Author: airship5 Author: airship
7 6
8 ==============================================================================7==============================================================================*/
9*/
10 8
11#if _WIN32 || _WIN649#if _WIN32 || _WIN64
12 10
LEAF/Src/leaf-reverb.c+3−5
@@ -1,12 +1,10 @@
1/*1/*==============================================================================
2 ==============================================================================
3 2
4 LEAFReverb.c3 leaf-reverb.c
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#if _WIN32 || _WIN649#if _WIN32 || _WIN64
12 10
LEAF/Src/leaf-sample.c+406−406
@@ -1,7 +1,7 @@
1/*1/*
2 ==============================================================================2 ==============================================================================
3 3
4 LEAFUtilities.c4 leaf-sample.c
5 Created: 20 Jan 2017 12:02:17pm5 Created: 20 Jan 2017 12:02:17pm
6 Author: Michael R Mulshine6 Author: Michael R Mulshine
7 7
@@ -10,7 +10,7 @@ · 2 unmodified lines
10 10
11 11
12#if _WIN32 || _WIN6412#if _WIN32 || _WIN64
13 13
14#include "..\Inc\leaf-sample.h"14#include "..\Inc\leaf-sample.h"
15#include "..\leaf.h"15#include "..\leaf.h"
16 16
@@ -19,412 +19,412 @@ · 2 unmodified lines
19#include "../Inc/leaf-sample.h"19#include "../Inc/leaf-sample.h"
20#include "../leaf.h"20#include "../leaf.h"
21 21
22#endif22#endif
23 23
24//==============================================================================24//==============================================================================
25 25
26void tBuffer_init (tBuffer* const s, uint32_t length)26void tBuffer_init (tBuffer* const s, uint32_t length)
27{27{
28 s->buff = (float*) leaf_alloc( sizeof(float) * length);28 s->buff = (float*) leaf_alloc( sizeof(float) * length);
29 29
30 30
31 s->length = length;31 s->length = length;
32 s->active = 0;32 s->active = 0;
33 s->idx = 0;33 s->idx = 0;
34 s->mode = RecordOneShot;34 s->mode = RecordOneShot;
35 35
36 tBuffer_clear(s);36 tBuffer_clear(s);
37}37}
38 38
39void tBuffer_free (tBuffer* const s)39void tBuffer_free (tBuffer* const s)
40{40{
41 leaf_free(s->buff);41 leaf_free(s->buff);
42 leaf_free(s);42 leaf_free(s);
43}43}
44 44
45void tBuffer_tick (tBuffer* const s, float sample)45void tBuffer_tick (tBuffer* const s, float sample)
46{46{
47 if (s->active == 1)47 if (s->active == 1)
48 {48 {
49 s->buff[s->idx] = sample;49 s->buff[s->idx] = sample;
50 50
51 s->idx += 1;51 s->idx += 1;
52 52
53 if (s->idx >= s->length)53 if (s->idx >= s->length)
54 {54 {
55 if (s->mode == RecordOneShot)55 if (s->mode == RecordOneShot)
56 {56 {
57 tBuffer_stop(s);57 tBuffer_stop(s);
58 }58 }
59 else if (s->mode == RecordLoop)59 else if (s->mode == RecordLoop)
60 {60 {
61 s->idx = 0;61 s->idx = 0;
62 }62 }
63 }63 }
64 }64 }
65}65}
66 66
67void tBuffer_read(tBuffer* const s, float* buff, uint32_t len)67void tBuffer_read(tBuffer* const s, float* buff, uint32_t len)
68{68{
69 for (int i = 0; i < s->length; i++)69 for (int i = 0; i < s->length; i++)
70 {70 {
71 if (i < len) s->buff[i] = buff[i];71 if (i < len) s->buff[i] = buff[i];
72 else s->buff[i] = 0.f;72 else s->buff[i] = 0.f;
73 }73 }
74}74}
75 75
76float tBuffer_get (tBuffer* const s, int idx)76float tBuffer_get (tBuffer* const s, int idx)
77{77{
78 if ((idx < 0) || (idx >= s->length)) return 0.f;78 if ((idx < 0) || (idx >= s->length)) return 0.f;
79 79
80 return s->buff[idx];80 return s->buff[idx];
81}81}
82 82
83void tBuffer_record(tBuffer* const s)83void tBuffer_record(tBuffer* const s)
84{84{
85 s->active = 1;85 s->active = 1;
86 s->idx = 0;86 s->idx = 0;
87}87}
88 88
89void tBuffer_stop(tBuffer* const s)89void tBuffer_stop(tBuffer* const s)
90{90{
91 s->active = 0;91 s->active = 0;
92}92}
93 93
94void tBuffer_setRecordMode (tBuffer* const s, RecordMode mode)94void tBuffer_setRecordMode (tBuffer* const s, RecordMode mode)
95{95{
96 s->mode = mode;96 s->mode = mode;
97}97}
98 98
99void tBuffer_clear (tBuffer* const s)99void tBuffer_clear (tBuffer* const s)
100{100{
101 for (int i = 0; i < s->length; i++)101 for (int i = 0; i < s->length; i++)
102 {102 {
103 s->buff[i] = 0.f;103 s->buff[i] = 0.f;
104 }104 }
105}105}
106 106
107//================================tSampler=====================================107//================================tSampler=====================================
108 108
109void tSampler_init (tSampler* const p, tBuffer* s)109void tSampler_init (tSampler* const p, tBuffer* s)
110{110{
111 p->samp = s;111 p->samp = s;
112 112
113 p->active = 0;113 p->active = 0;
114 114
115 p->start = 0;115 p->start = 0;
116 p->end = p->samp->length - 1;116 p->end = p->samp->length - 1;
117 117
118 p->len = p->end - p->start;118 p->len = p->end - p->start;
119 119
120 p->idx = 0.f;120 p->idx = 0.f;
121 p->inc = 1.f;121 p->inc = 1.f;
122 p->iinc = 1.f;122 p->iinc = 1.f;
123 123
124 p->dir = 1;124 p->dir = 1;
125 p->flip = 1;125 p->flip = 1;
126 p->bnf = 1;126 p->bnf = 1;
127 127
128 p->mode = Normal;128 p->mode = Normal;
129 129
130 p->cfxlen = 300; // default 300 sample crossfade130 p->cfxlen = 300; // default 300 sample crossfade
131 131
132 tRamp_init(&p->gain, 7.0f, 1);132 tRamp_init(&p->gain, 7.0f, 1);
133 tRamp_setVal(&p->gain, 0.f);133 tRamp_setVal(&p->gain, 0.f);
134}134}
135 135
136void tSampler_free (tSampler* const p)136void tSampler_free (tSampler* const p)
137{137{
138 leaf_free(p->samp);138 leaf_free(p->samp);
139 leaf_free(p);139 leaf_free(p);
140}140}
141 141
142float tSampler_tick (tSampler* const p)142float tSampler_tick (tSampler* const p)
143{143{
144 if (p->active == 0 || (p->len < 4)) return 0.f;144 if (p->active == 0 || (p->len < 4)) return 0.f;
145 145
146 float sample = 0.f;146 float sample = 0.f;
147 float cfxsample = 0.f;147 float cfxsample = 0.f;
148 int numsamps;148 int numsamps;
149 float g1 = 1.f, g2 = 0.f;149 float g1 = 1.f, g2 = 0.f;
150 150
151 float* buff = p->samp->buff;151 float* buff = p->samp->buff;
152 152
153 int dir = p->bnf * p->dir * p->flip;153 int dir = p->bnf * p->dir * p->flip;
154 154
155 int idx;155 int idx;
156 float alpha;156 float alpha;
157 157
158 if (dir > 0)158 if (dir > 0)
159 {159 {
160 idx = (int) p->idx;160 idx = (int) p->idx;
161 alpha = p->idx - idx;161 alpha = p->idx - idx;
162 }162 }
163 else163 else
164 {164 {
165 idx = (int) (p->idx + 1.f); // we think this is because flooring on int works different when reading backwards165 idx = (int) (p->idx + 1.f); // we think this is because flooring on int works different when reading backwards
166 alpha = (p->idx+1.f) - idx;166 alpha = (p->idx+1.f) - idx;
167 }167 }
168 168
169 int32_t start = p->start, end = p->end;169 int32_t start = p->start, end = p->end;
170 if (p->flip < 0)170 if (p->flip < 0)
171 {171 {
172 start = p->end;172 start = p->end;
173 end = p->start;173 end = p->start;
174 }174 }
175 175
176 // Check dir (direction) to interpolate properly176 // Check dir (direction) to interpolate properly
177 if (dir > 0)177 if (dir > 0)
178 {178 {
179 // FORWARD NORMAL SAMPLE179 // FORWARD NORMAL SAMPLE
180 int i1 = idx-1;180 int i1 = idx-1;
181 int i3 = idx+1;181 int i3 = idx+1;
182 int i4 = idx+2;182 int i4 = idx+2;
183 183
184 sample = LEAF_interpolate_hermite (buff[i1],184 sample = LEAF_interpolate_hermite (buff[i1],
185 buff[idx],185 buff[idx],
186 buff[i3],186 buff[i3],
187 buff[i4],187 buff[i4],
188 alpha);188 alpha);
189 189
190 // num samples to end of loop190 // num samples to end of loop
191 numsamps = (dir > 0) ? (end - idx) : (idx - start);191 numsamps = (dir > 0) ? (end - idx) : (idx - start);
192 numsamps *= p->iinc;192 numsamps *= p->iinc;
193 193
194 if (p->mode == Loop)194 if (p->mode == Loop)
195 {195 {
196 if (numsamps <= p->cfxlen)196 if (numsamps <= p->cfxlen)
197 {197 {
198 // CROSSFADE SAMPLE198 // CROSSFADE SAMPLE
199 float idxx = p->idx - p->len;199 float idxx = p->idx - p->len;
200 int cdx = (int)(idxx);200 int cdx = (int)(idxx);
201 201
202 i1 = cdx-1;202 i1 = cdx-1;
203 i3 = cdx+1;203 i3 = cdx+1;
204 i4 = cdx+2;204 i4 = cdx+2;
205 205
206 cfxsample = LEAF_interpolate_hermite (buff[i1],206 cfxsample = LEAF_interpolate_hermite (buff[i1],
207 buff[cdx],207 buff[cdx],
208 buff[i3],208 buff[i3],
209 buff[i4],209 buff[i4],
210 alpha);210 alpha);
211 211
212 g2 = (float) (p->cfxlen - numsamps) / (float) p->cfxlen;212 g2 = (float) (p->cfxlen - numsamps) / (float) p->cfxlen;
213 }213 }
214 }214 }
215 }215 }
216 else216 else
217 {217 {
218 // REVERSE218 // REVERSE
219 int i1 = idx+1;219 int i1 = idx+1;
220 int i3 = idx-1;220 int i3 = idx-1;
221 int i4 = idx-2;221 int i4 = idx-2;
222 222
223 sample = LEAF_interpolate_hermite (buff[i1],223 sample = LEAF_interpolate_hermite (buff[i1],
224 buff[idx],224 buff[idx],
225 buff[i3],225 buff[i3],
226 buff[i4],226 buff[i4],
227 1.0f-alpha);227 1.0f-alpha);
228 228
229 numsamps = (idx - start) / p->inc;229 numsamps = (idx - start) / p->inc;
230 230
231 if (p->mode == Loop)231 if (p->mode == Loop)
232 {232 {
233 if (numsamps <= p->cfxlen)233 if (numsamps <= p->cfxlen)
234 {234 {
235 // CROSSFADE SAMPLE235 // CROSSFADE SAMPLE
236 float idxx = p->idx + p->len + 1.f;236 float idxx = p->idx + p->len + 1.f;
237 int cdx = (int)(idxx);237 int cdx = (int)(idxx);
238 alpha = idxx - cdx;238 alpha = idxx - cdx;
239 239
240 i1 = cdx+1;240 i1 = cdx+1;
241 i3 = cdx-1;241 i3 = cdx-1;
242 i4 = cdx-2;242 i4 = cdx-2;
243 243
244 cfxsample = LEAF_interpolate_hermite (buff[i1],244 cfxsample = LEAF_interpolate_hermite (buff[i1],
245 buff[cdx],245 buff[cdx],
246 buff[i3],246 buff[i3],
247 buff[i4],247 buff[i4],
248 1.f-alpha);248 1.f-alpha);
249 249
250 g2 = (float) (p->cfxlen - numsamps) / (float) p->cfxlen;250 g2 = (float) (p->cfxlen - numsamps) / (float) p->cfxlen;
251 }251 }
252 }252 }
253 }253 }
254 254
255 p->idx += (dir * p->inc);255 p->idx += (dir * p->inc);
256 256
257 if (p->mode == Normal)257 if (p->mode == Normal)
258 {258 {
259 if (numsamps < (0.007f * leaf.sampleRate))259 if (numsamps < (0.007f * leaf.sampleRate))
260 {260 {
261 tRamp_setDest(&p->gain, 0.f);261 tRamp_setDest(&p->gain, 0.f);
262 p->active = -1;262 p->active = -1;
263 }263 }
264 }264 }
265 else if (p->mode == Loop ) // == Normal or Loop265 else if (p->mode == Loop ) // == Normal or Loop
266 {266 {
267 if (idx <= start)267 if (idx <= start)
268 {268 {
269 p->idx += (float)(p->len);269 p->idx += (float)(p->len);
270 }270 }
271 else if (idx >= end)271 else if (idx >= end)
272 {272 {
273 p->idx -= (float)(p->len);273 p->idx -= (float)(p->len);
274 }274 }
275 }275 }
276 else // == BackAndForth276 else // == BackAndForth
277 {277 {
278 if (p->idx < start)278 if (p->idx < start)
279 {279 {
280 p->bnf = -p->bnf;280 p->bnf = -p->bnf;
281 p->idx = start;281 p->idx = start;
282 }282 }
283 else if (p->idx > end)283 else if (p->idx > end)
284 {284 {
285 p->bnf = -p->bnf;285 p->bnf = -p->bnf;
286 p->idx = end;286 p->idx = end;
287 }287 }
288 }288 }
289 289
290 g1 = 1.f - g2;290 g1 = 1.f - g2;
291 291
292 sample = sample * g1 + cfxsample * g2;292 sample = sample * g1 + cfxsample * g2;
293 293
294 sample = sample * tRamp_tick(&p->gain);294 sample = sample * tRamp_tick(&p->gain);
295 295
296 if (p->active < 0)296 if (p->active < 0)
297 {297 {
298 if (tRamp_sample(&p->gain) <= 0.00001f)298 if (tRamp_sample(&p->gain) <= 0.00001f)
299 {299 {
300 if (p->retrigger == 1)300 if (p->retrigger == 1)
301 {301 {
302 p->active = 1;302 p->active = 1;
303 p->retrigger = 0;303 p->retrigger = 0;
304 tRamp_setDest(&p->gain, 1.f);304 tRamp_setDest(&p->gain, 1.f);
305 305
306 if (p->dir > 0)306 if (p->dir > 0)
307 {307 {
308 if (p->flip > 0) p->idx = p->start;308 if (p->flip > 0) p->idx = p->start;
309 else p->idx = p->end;309 else p->idx = p->end;
310 }310 }
311 else311 else
312 {312 {
313 if (p->flip > 0) p->idx = p->end;313 if (p->flip > 0) p->idx = p->end;
314 else p->idx = p->start;314 else p->idx = p->start;
315 }315 }
316 }316 }
317 else317 else
318 {318 {
319 p->active = 0;319 p->active = 0;
320 }320 }
321 321
322 }322 }
323 }323 }
324 324
325 return sample;325 return sample;
326}326}
327 327
328void tSampler_setSample (tSampler* const p, tBuffer* s)328void tSampler_setSample (tSampler* const p, tBuffer* s)
329{329{
330 p->samp = s;330 p->samp = s;
331}331}
332 332
333void tSampler_setMode (tSampler* const p, Mode mode)333void tSampler_setMode (tSampler* const p, Mode mode)
334{334{
335 p->mode = mode;335 p->mode = mode;
336}336}
337 337
338void tSampler_setCrossfadeLength (tSampler* const p, uint32_t length)338void tSampler_setCrossfadeLength (tSampler* const p, uint32_t length)
339{339{
340 uint32_t cfxlen = LEAF_clip(0, length, 1000);340 uint32_t cfxlen = LEAF_clip(0, length, 1000);
341 341
342 //if (cfxlen > p->len) cfxlen = p->len * 0.25f;342 //if (cfxlen > p->len) cfxlen = p->len * 0.25f;
343 343
344 p->cfxlen = cfxlen;344 p->cfxlen = cfxlen;
345}345}
346 346
347void tSampler_play (tSampler* const p)347void tSampler_play (tSampler* const p)
348{348{
349 if (p->active != 0)349 if (p->active != 0)
350 {350 {
351 p->active = -1;351 p->active = -1;
352 p->retrigger = 1;352 p->retrigger = 1;
353 353
354 tRamp_setDest(&p->gain, 0.f);354 tRamp_setDest(&p->gain, 0.f);
355 }355 }
356 else356 else
357 {357 {
358 p->active = 1;358 p->active = 1;
359 p->retrigger = 0;359 p->retrigger = 0;
360 360
361 tRamp_setDest(&p->gain, 1.f);361 tRamp_setDest(&p->gain, 1.f);
362 362
363 if (p->dir > 0)363 if (p->dir > 0)
364 {364 {
365 if (p->flip > 0) p->idx = p->start;365 if (p->flip > 0) p->idx = p->start;
366 else p->idx = p->end;366 else p->idx = p->end;
367 }367 }
368 else368 else
369 {369 {
370 if (p->flip > 0) p->idx = p->end;370 if (p->flip > 0) p->idx = p->end;
371 else p->idx = p->start;371 else p->idx = p->start;
372 }372 }
373 }373 }
374}374}
375 375
376void tSampler_stop (tSampler* const p)376void tSampler_stop (tSampler* const p)
377{377{
378 p->active = -1;378 p->active = -1;
379 379
380 tRamp_setDest(&p->gain, 0.f);380 tRamp_setDest(&p->gain, 0.f);
381}381}
382 382
383static void handleStartEndChange(tSampler* const p)383static void handleStartEndChange(tSampler* const p)
384{384{
385 p->len = abs(p->end - p->start);385 p->len = abs(p->end - p->start);
386 386
387 //if (p->len < p->cfxlen) p->cfxlen = p->len * 0.9f;387 //if (p->len < p->cfxlen) p->cfxlen = p->len * 0.9f;
388 388
389 if (p->start > p->end)389 if (p->start > p->end)
390 {390 {
391 p->flip = -1;391 p->flip = -1;
392 }392 }
393 else393 else
394 {394 {
395 p->flip = 1;395 p->flip = 1;
396 }396 }
397}397}
398 398
399void tSampler_setStart (tSampler* const p, int32_t start)399void tSampler_setStart (tSampler* const p, int32_t start)
400{400{
401 p->start = LEAF_clipInt(0, start, (p->samp->length - 1));401 p->start = LEAF_clipInt(0, start, (p->samp->length - 1));
402 402
403 handleStartEndChange(p);403 handleStartEndChange(p);
404}404}
405 405
406void tSampler_setEnd (tSampler* const p, int32_t end)406void tSampler_setEnd (tSampler* const p, int32_t end)
407{407{
408 p->end = LEAF_clipInt(0, end, (p->samp->length - 1));408 p->end = LEAF_clipInt(0, end, (p->samp->length - 1));
409 409
410 handleStartEndChange(p);410 handleStartEndChange(p);
411}411}
412 412
413void tSampler_setRate (tSampler* const p, float rate)413void tSampler_setRate (tSampler* const p, float rate)
414{414{
415 if (rate < 0.f)415 if (rate < 0.f)
416 {416 {
417 rate = -rate;417 rate = -rate;
418 p->dir = -1;418 p->dir = -1;
419 }419 }
420 else420 else
421 {421 {
422 p->dir = 1;422 p->dir = 1;
423 }423 }
424 424
425 p->inc = LEAF_clip(0.f, rate, 8.0f);425 p->inc = LEAF_clip(0.f, rate, 8.0f);
426 p->iinc = 1.f / p->inc;426 p->iinc = 1.f / p->inc;
427}427}
428 428
429 429
430//==============================================================================430//==============================================================================
LEAF/Src/leaf-string.c+3−5
@@ -1,12 +1,10 @@
1/*1/*==============================================================================
2 ==============================================================================
3 2
4 leaf-string.cpp3 leaf-string.c
5 Created: 30 Nov 2018 10:41:42am4 Created: 30 Nov 2018 10:41:42am
6 Author: airship5 Author: airship
7 6
8 ==============================================================================7==============================================================================*/
9*/
10 8
11#if _WIN32 || _WIN649#if _WIN32 || _WIN64
12 10
LEAF/Src/leaf-utilities.c+3−5
@@ -1,12 +1,10 @@
1/*1/*==============================================================================
2 ==============================================================================
3 2
4 LEAFUtilities.c3 leaf-utilities.c
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 9
12#if _WIN32 || _WIN6410#if _WIN32 || _WIN64
LEAF/Src/leaf-vocoder.c+3−5
@@ -1,12 +1,10 @@
1/*1/*==============================================================================
2 ==============================================================================
3 2
4 LEAFInstrument.c3 leaf-vocoder.c
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#if _WIN32 || _WIN649#if _WIN32 || _WIN64
12 10
LEAF/Src/leaf-wavefolder.c+3−5
@@ -1,12 +1,10 @@
1/*1/*==============================================================================
2 ==============================================================================
3 2
4 leaf-wavefolder.cpp3 leaf-wavefolder.c
5 Created: 30 Nov 2018 11:56:49am4 Created: 30 Nov 2018 11:56:49am
6 Author: airship5 Author: airship
7 6
8 ==============================================================================7==============================================================================*/
9*/
10 8
11#if _WIN32 || _WIN649#if _WIN32 || _WIN64
12 10
LEAF/leaf.h+4−2
@@ -32,7 +32,8 @@ · 31 unmodified lines
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-sample.h"
36#include ".\Inc\leaf-crusher.h"
36#include ".\Inc\leaf-wavefolder.h"37#include ".\Inc\leaf-wavefolder.h"
37#include ".\Inc\leaf-wavetables.h"38#include ".\Inc\leaf-wavetables.h"
38 39
@@ -51,7 +52,8 @@ · 12 unmodified lines
51#include "./Inc/leaf-pitch.h"52#include "./Inc/leaf-pitch.h"
52#include "./Inc/leaf-formant.h"53#include "./Inc/leaf-formant.h"
53#include "./Inc/leaf-midi.h"54#include "./Inc/leaf-midi.h"
54#include "./Inc/leaf-sample.h"55#include "./Inc/leaf-sample.h"
56#include "./Inc/leaf-crusher.h"
55#include "./Inc/leaf-wavefolder.h"57#include "./Inc/leaf-wavefolder.h"
56#include "./Inc/leaf-wavetables.h"58#include "./Inc/leaf-wavetables.h"
57 59
LEAF_JUCEPlugin/LEAF.jucer+2−0
@@ -40,6 +40,7 @@ · 39 unmodified lines
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="T6KXi7" name="leaf-sample.h" compile="0" resource="0" file="../LEAF/Inc/leaf-sample.h"/>
43 <FILE id="bpUZCA" name="leaf-crusher.h" compile="0" resource="0" file="../LEAF/Inc/leaf-crusher.h"/>
43 <FILE id="PRkOp2" name="leaf-wavefolder.h" compile="0" resource="0"44 <FILE id="PRkOp2" name="leaf-wavefolder.h" compile="0" resource="0"
44 file="../LEAF/Inc/leaf-wavefolder.h"/>45 file="../LEAF/Inc/leaf-wavefolder.h"/>
45 <FILE id="KpGzKv" name="leaf-wavetables.h" compile="0" resource="0"46 <FILE id="KpGzKv" name="leaf-wavetables.h" compile="0" resource="0"
@@ -62,6 +63,7 @@ · 16 unmodified lines
62 file="../LEAF/Src/leaf-utilities.c"/>63 file="../LEAF/Src/leaf-utilities.c"/>
63 <FILE id="u1aLLR" name="leaf-vocoder.c" compile="1" resource="0" file="../LEAF/Src/leaf-vocoder.c"/>64 <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"/>65 <FILE id="nmtoFJ" name="leaf-sample.c" compile="1" resource="0" file="../LEAF/Src/leaf-sample.c"/>
66 <FILE id="Oymcac" name="leaf-crusher.c" compile="1" resource="0" file="../LEAF/Src/leaf-crusher.c"/>
65 <FILE id="LVoaGm" name="leaf-wavefolder.c" compile="1" resource="0"67 <FILE id="LVoaGm" name="leaf-wavefolder.c" compile="1" resource="0"
66 file="../LEAF/Src/leaf-wavefolder.c"/>68 file="../LEAF/Src/leaf-wavefolder.c"/>
67 <FILE id="HRk07h" name="leaf-wavetables.c" compile="1" resource="0"69 <FILE id="HRk07h" name="leaf-wavetables.c" compile="1" resource="0"
LEAF_JUCEPlugin/Source/LEAFLink.cpp+6−6
@@ -15,16 +15,16 @@ · 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 "sample",18
19 "play"
20};19};
21 20
22std::vector<juce::String> cSliderNames = std::vector<juce::String>21std::vector<juce::String> cSliderNames = std::vector<juce::String>
23{22{
24 "rate",23 "sr",
25 "start",24 "rnd",
26 "end",25 "qual",
27 "cfxlen"26 "op",
27 "mix"
28};28};
29 29
30std::vector<juce::String> cComboBoxNames = std::vector<juce::String>30std::vector<juce::String> cComboBoxNames = std::vector<juce::String>
LEAF_JUCEPlugin/Source/MyTest.cpp+47−48
@@ -14,77 +14,76 @@ · 13 unmodified lines
14 14
15static void leaf_pool_report(void);15static void leaf_pool_report(void);
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
19tBuffer sample;19float mix = 0.f;
20float fx = 1.f;
20 21
21tSampler player;22tCrusher crusher;
22 23
23void LEAFTest_init (float sampleRate, int blockSize)24void LEAFTest_init (float sampleRate, int blockSize)
24{25{
25 LEAF_init(sampleRate, blockSize, &randomNumberGenerator);26 LEAF_init(sampleRate, blockSize, &randomNumberGenerator);
26 27
27 tBuffer_init(&sample, leaf.sampleRate * 2);28 tCrusher_init(&crusher);
28 29
29 tSampler_init(&player, &sample);30 leaf_pool_report();
30 tSampler_setMode(&player, Normal);
31
32 leaf_pool_report();
33
34 tBuffer_record(&sample);
35}31}
36 32
37int timer = 0;33int timer = 0;
38 34
39float LEAFTest_tick (float input)35float LEAFTest_tick (float input)
40{36{
41 tBuffer_tick(&sample, input);37 float sample = 0.f;
42 38
43 return tSampler_tick(&player);39 sample = (mix * tCrusher_tick(&crusher, input)) + ((1.f - mix) * input);
40
41 return sample;
44}42}
45 43
46bool lastState = false, lastPlayState = false;44bool lastState = false, lastPlayState = false;
47void LEAFTest_block (void)45void LEAFTest_block (void)
48{46{
49 float val = getSliderValue("rate");47 float val = getSliderValue("mix");
48
49 mix = val;
50
51 val = getSliderValue("sr");
52
53 tCrusher_setSamplingRatio(&crusher, val * 3.99f + 0.01f);
50 54
51 float rate = val * 16.0f - 8.0f;55 val = getSliderValue("rnd");
52 tSampler_setRate(&player, rate);
53 //DBG("rate: " + String(rate));
54 56
55 val = getSliderValue("start");57 tCrusher_setRound(&crusher, val);
56 float start = val * sample.length;
57 tSampler_setStart(&player, start);
58 //DBG("start: " + String(start));
59 58
60 val = getSliderValue("end");59 val = getSliderValue("qual");
61 float end = val * sample.length;
62 tSampler_setEnd(&player, end);
63 //DBG("end: " + String(end));
64 60
65 val = getSliderValue("cfxlen");61 tCrusher_setQuality(&crusher, val);
66 uint32_t cfxlen = val * 500;
67 tSampler_setCrossfadeLength(&player, cfxlen);
68 DBG("cfxlen: " + String(cfxlen));
69 62
70 bool state = getButtonState("sample");63 val = getSliderValue("op");
71 64
72 if (state && !lastState)65 tCrusher_setOperation(&crusher, (int)(val * 8.0f));
73 {
74 timer = 0;
75 tBuffer_record(&sample);
76 }
77 66
78 lastState = state;67 /*
68 float samp = -1.f + 2.f * val;
79 69
80 state = getButtonState("play");70 union unholy_t bw;
71 bw.f = samp;
72 bw.i = (bw.i | (op << 23));
81 73
82 if (state && !lastPlayState)74 DBG(String(samp) + " " + String(bw.f));
83 {75 */
84 tSampler_play(&player);
85 }
86 76
87 lastPlayState = state;77 // rounding test
78 /*
79 val = getSliderValue("rnd");
80
81 float to_rnd = -1.f + 2.f * val;
82
83 float rnd = LEAF_round(to_rnd, 0.3f);
84
85 DBG("to_rnd: " + String(to_rnd) + " rnd: " + String(rnd));
86 */
88}87}
89 88
90void LEAFTest_controllerInput (int cnum, float cval)89void LEAFTest_controllerInput (int cnum, float cval)
@@ -148,7 +147,7 @@ static void run_pool_test(void) · 57 unmodified lines
148 }147 }
149 148
150 leaf_pool_report();149 leaf_pool_report();
151 150
152 DBG("ALLOC BUFFER 2");151 DBG("ALLOC BUFFER 2");
153 size = 25;152 size = 25;
154 153

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