History

Merge branch 'master' of https://github.com/spiricom/leaf

Jeff Snyder committed 7 years ago

Commit 84de0e32 parents ae6880a ad69b2310 files · +265 −210Browse files

Unified · Split

10 files
  1. LEAF/Inc/leaf-crusher.h +1 −1
  2. LEAF/Inc/leaf-globals.h +3 −3
  3. LEAF/Inc/leaf-sample.h +1 −0
  4. LEAF/Src/leaf-crusher.c +1 −1
  5. LEAF/Src/leaf-sample.c +61 −53
  6. LEAF_JUCEPlugin/.DS_Store +0 −0
  7. LEAF_JUCEPlugin/JuceLibraryCode/AppConfig.h +6 −0
  8. LEAF_JUCEPlugin/LEAF.jucer +1 −1
  9. LEAF_JUCEPlugin/Source/LEAFLink.cpp +3 −4
  10. LEAF_JUCEPlugin/Source/MyTest.cpp +189 −148
LEAF/Inc/leaf-crusher.h+1−1
@@ -61,4 +61,4 @@ void tCrusher_setSamplingRatio (tCrusher* const, float ratio); · 60 unmodified lines
61 61
62#endif // LEAF_WAVEFOLDER_H_INCLUDED62#endif // LEAF_WAVEFOLDER_H_INCLUDED
63 63
64//==============================================================================64//==============================================================================
LEAF/Inc/leaf-globals.h+3−3
@@ -25,12 +25,12 @@ typedef struct _LEAF · 24 unmodified lines
25 float invSampleRate;25 float invSampleRate;
26 int blockSize;26 int blockSize;
27 27
28 /*28
29 float* sinewave;29 float* sinewave;
30 float* sawtooth[11];30 float* sawtooth[11];
31 float* square[11];31 float* square[11];
32 float* triangle[11];32 float* triangle[11];
33 */33
34 34
35 float (*random)(void);35 float (*random)(void);
36} LEAF;36} LEAF;
@@ -57,7 +57,7 @@ extern const float shaper1[SHAPER1_TABLE_SIZE]; · 20 unmodified lines
57 // Feel free to change to suit memory constraints or desired delay max length / functionality.57 // Feel free to change to suit memory constraints or desired delay max length / functionality.
58 58
59 59
60 60#define TALKBOX_BUFFER_LENGTH 1600 // Every talkbox instance introduces 5 buffers of this size
61 61
62union unholy_t { /* a union between a float and an integer */62union unholy_t { /* a union between a float and an integer */
63 float f;63 float f;
LEAF/Inc/leaf-sample.h+1−0
@@ -77,6 +77,7 @@ extern "C" { · 76 unmodified lines
77 77
78 float idx;78 float idx;
79 float inc;79 float inc;
80 float last;
80 float iinc;81 float iinc;
81 int8_t dir;82 int8_t dir;
82 int8_t flip;83 int8_t flip;
LEAF/Src/leaf-crusher.c+1−1
@@ -81,4 +81,4 @@ void tCrusher_setRound (tCrusher* const c, float rnd) · 80 unmodified lines
81void tCrusher_setSamplingRatio (tCrusher* const c, float ratio)81void tCrusher_setSamplingRatio (tCrusher* const c, float ratio)
82{82{
83 c->srr = ratio;83 c->srr = ratio;
84}84}
LEAF/Src/leaf-sample.c+61−53
@@ -141,8 +141,13 @@ void tSampler_free (tSampler* const p) · 140 unmodified lines
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) return 0.f;
145 145
146 if ((p->inc == 0.0f) || (p->len < 4))
147 {
148 return p->last;
149 }
150
146 float sample = 0.f;151 float sample = 0.f;
147 float cfxsample = 0.f;152 float cfxsample = 0.f;
148 int numsamps;153 int numsamps;
@@ -162,7 +167,7 @@ float tSampler_tick (tSampler* const p) · 13 unmodified lines
162 }167 }
163 else168 else
164 {169 {
165 idx = (int) (p->idx + 1.f); // we think this is because flooring on int works different when reading backwards170 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;171 alpha = (p->idx+1.f) - idx;
167 }172 }
168 173
@@ -173,52 +178,53 @@ float tSampler_tick (tSampler* const p) · 4 unmodified lines
173 end = p->start;178 end = p->start;
174 }179 }
175 180
176 // Check dir (direction) to interpolate properly181 // Check dir (direction) to interpolate properly
177 if (dir > 0)182 if (dir > 0)
178 {183 {
179 // FORWARD NORMAL SAMPLE184 // FORWARD NORMAL SAMPLE
180 int i1 = idx-1;185 int i1 = ((idx-1) + p->len) % p->len;
181 int i3 = idx+1;186 int i3 = (idx+1) % p->len;
182 int i4 = idx+2;187 int i4 = (idx+2) % p->len;
183 188
184 sample = LEAF_interpolate_hermite (buff[i1],189 sample = LEAF_interpolate_hermite (buff[i1],
185 buff[idx],190 buff[idx],
186 buff[i3],191 buff[i3],
187 buff[i4],192 buff[i4],
188 alpha);193 alpha);
189 194
190 // num samples to end of loop195 // num samples to end of loop
191 numsamps = (dir > 0) ? (end - idx) : (idx - start);196 numsamps = (idx - start) / p->inc;
192 numsamps *= p->iinc;197 //numsamps = (dir > 0) ? (end - idx) : (idx - start);
193 198 //numsamps *= p->iinc;
194 if (p->mode == PlayLoop)199
195 {200 if (p->mode == PlayLoop)
196 if (numsamps <= p->cfxlen)201 {
197 {202 if (numsamps <= p->cfxlen)
198 // CROSSFADE SAMPLE203 {
199 float idxx = p->idx - p->len;204 // CROSSFADE SAMPLE
200 int cdx = (int)(idxx);205 float idxx = p->idx - p->len;
201 206 int cdx = ((int)(idxx) + p->len) % p->len;
202 i1 = cdx-1;207
203 i3 = cdx+1;208 i1 = ((cdx-1) + p->len) % p->len;
204 i4 = cdx+2;209 i3 = (cdx+1) % p->len;
205 210 i4 = (cdx+2) % p->len;
206 cfxsample = LEAF_interpolate_hermite (buff[i1],211
207 buff[cdx],212 cfxsample = LEAF_interpolate_hermite (buff[i1],
208 buff[i3],213 buff[cdx],
209 buff[i4],214 buff[i3],
210 alpha);215 buff[i4],
211 216 alpha);
212 g2 = (float) (p->cfxlen - numsamps) / (float) p->cfxlen;217
213 }218 g2 = (float) (p->cfxlen - numsamps) / (float) p->cfxlen;
214 }219 }
215 }220 }
216 else221 }
222 else
217 {223 {
218 // REVERSE224 // REVERSE
219 int i1 = idx+1;225 int i1 = (idx+1) % p->len;
220 int i3 = idx-1;226 int i3 = ((idx-1) + p->len) % p->len;
221 int i4 = idx-2;227 int i4 = ((idx-2) + p->len) % p->len;
222 228
223 sample = LEAF_interpolate_hermite (buff[i1],229 sample = LEAF_interpolate_hermite (buff[i1],
224 buff[idx],230 buff[idx],
@@ -234,12 +240,12 @@ float tSampler_tick (tSampler* const p) · 9 unmodified lines
234 {240 {
235 // CROSSFADE SAMPLE241 // CROSSFADE SAMPLE
236 float idxx = p->idx + p->len + 1.f;242 float idxx = p->idx + p->len + 1.f;
237 int cdx = (int)(idxx);243 int cdx = ((int)(idxx)) % p->len;
238 alpha = idxx - cdx;244 alpha = idxx - cdx;
239 245
240 i1 = cdx+1;246 i1 = (cdx+1) % p->len;
241 i3 = cdx-1;247 i3 = ((cdx-1) + p->len) % p->len;
242 i4 = cdx-2;248 i4 = ((cdx-2) + p->len) % p->len;
243 249
244 cfxsample = LEAF_interpolate_hermite (buff[i1],250 cfxsample = LEAF_interpolate_hermite (buff[i1],
245 buff[cdx],251 buff[cdx],
@@ -322,7 +328,9 @@ float tSampler_tick (tSampler* const p) · 76 unmodified lines
322 }328 }
323 }329 }
324 330
325 return sample;331 p->last = sample;
332
333 return p->last;
326}334}
327 335
328void tSampler_setSample (tSampler* const p, tBuffer* s)336void tSampler_setSample (tSampler* const p, tBuffer* s)
LEAF_JUCEPlugin/.DS_Store+0−0

Binary file not shown.

LEAF_JUCEPlugin/JuceLibraryCode/AppConfig.h+6−0
@@ -451,6 +451,12 @@ · 450 unmodified lines
451#ifndef JucePlugin_IAAName451#ifndef JucePlugin_IAAName
452 #define JucePlugin_IAAName "pumusic: LEAF"452 #define JucePlugin_IAAName "pumusic: LEAF"
453#endif453#endif
454#ifndef JucePlugin_VSTNumMidiInputs
455 #define JucePlugin_VSTNumMidiInputs 16
456#endif
457#ifndef JucePlugin_VSTNumMidiOutputs
458 #define JucePlugin_VSTNumMidiOutputs 16
459#endif
454#ifndef JucePlugin_MaxNumInputChannels460#ifndef JucePlugin_MaxNumInputChannels
455 #define JucePlugin_MaxNumInputChannels 2461 #define JucePlugin_MaxNumInputChannels 2
456#endif462#endif
LEAF_JUCEPlugin/LEAF.jucer+1−1
@@ -8,7 +8,7 @@ · 7 unmodified lines
8 pluginIsSynth="0" pluginWantsMidiIn="1" pluginProducesMidiOut="0"8 pluginIsSynth="0" pluginWantsMidiIn="1" pluginProducesMidiOut="0"
9 pluginIsMidiEffectPlugin="0" pluginEditorRequiresKeys="0" pluginAUExportPrefix="LEAFAU"9 pluginIsMidiEffectPlugin="0" pluginEditorRequiresKeys="0" pluginAUExportPrefix="LEAFAU"
10 pluginRTASCategory="" aaxIdentifier="com.pumusic.LEAF" pluginAAXCategory="2"10 pluginRTASCategory="" aaxIdentifier="com.pumusic.LEAF" pluginAAXCategory="2"
11 jucerVersion="5.4.1" companyName="Princeton University" companyEmail="mrmulshine@gmail.com"11 jucerVersion="5.4.3" companyName="Princeton University" companyEmail="mrmulshine@gmail.com"
12 displaySplashScreen="1" reportAppUsage="1" splashScreenColour="Dark"12 displaySplashScreen="1" reportAppUsage="1" splashScreenColour="Dark"
13 buildStandalone="1" enableIAA="0" cppLanguageStandard="11" companyCopyright="Princeton University"13 buildStandalone="1" enableIAA="0" cppLanguageStandard="11" companyCopyright="Princeton University"
14 pluginFormats="buildVST,buildAU,buildStandalone" pluginCharacteristicsValue="pluginWantsMidiIn">14 pluginFormats="buildVST,buildAU,buildStandalone" pluginCharacteristicsValue="pluginWantsMidiIn">
LEAF_JUCEPlugin/Source/LEAFLink.cpp+3−4
@@ -15,14 +15,13 @@ · 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 "record"
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 "gain",23 "mod freq",
24 "frequency",24 "mod depth"
25 "distortion"
26};25};
27 26
28std::vector<juce::String> cComboBoxNames = std::vector<juce::String>27std::vector<juce::String> cComboBoxNames = std::vector<juce::String>
LEAF_JUCEPlugin/Source/MyTest.cpp+189−148
@@ -1,153 +1,194 @@
1/*1/*
2 ==============================================================================2 ==============================================================================
3 3
4 FM.c4 FM.c
5 Created: 23 Jan 2017 9:39:38am5 Created: 23 Jan 2017 9:39:38am
6 Author: Michael R Mulshine6 Author: Michael R Mulshine
7 7
8 ==============================================================================8 ==============================================================================
9*/9*/
10 10
11#include "LEAFTest.h"11#include "LEAFTest.h"
12#include "MyTest.h"12#include "MyTest.h"
13 13
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
19float gain, freqVal;19float mix = 0.f;
20float clipThreshold = 1.f;20float fx = 1.f;
21 21
22tCycle test;22#define NUM_GRAINS 20
23tOversampler2x os2;23
24tOversampler4x os4;24
25 25
26void LEAFTest_init (float sampleRate, int blockSize)26tTapeDelay delay;
27{27
28 LEAF_init(sampleRate, blockSize, &randomNumberGenerator);28float feedback = 0.f;
29 29
30 tCycle_init(&test);30tBuffer buff;
31 tOversampler2x_init(&os2);31tSampler samp;
32 tOversampler4x_init(&os4);32
33 33tCycle osc;
34 leaf_pool_report();34
35}35void LEAFTest_init (float sampleRate, int blockSize)
36 36{
37 37 LEAF_init(sampleRate, blockSize, &getRandomFloat);
38float softClip(float sample)38
39{39 // Init and set record
40 return LEAF_softClip(sample, clipThreshold);40 tBuffer_init (&buff, leaf.sampleRate * 1.f); // init, 1 second buffer
41}41 tBuffer_setRecordMode (&buff, RecordOneShot); // RecordOneShot records once through
42 42 tBuffer_record(&buff); // starts recording
43float lastOut;43
44 44 // Init and set play
45float LEAFTest_tick (float input)45 tSampler_init (&samp, &buff); // init, give address of record buffer
46{46 tSampler_setMode (&samp, PlayLoop); //set in Loop Mode
47 tCycle_setFreq(&test, freqVal);47 tSampler_setRate(&samp, 1.f); // Rate of 1.0
48 float sample = tCycle_tick(&test);48 tSampler_play(&samp); // start spitting samples out
49 49
50 sample = tOversampler4x_tick(&os4, sample, &softClip);50 tCycle_init(&osc);
51 51
52 return sample * gain;52 leaf_pool_report();
53}
54
55bool lastState = false, lastPlayState = false;
56void LEAFTest_block (void)
57{
58 clipThreshold = (1.f - getSliderValue("distortion")) * 0.3f;
59 gain = getSliderValue("gain") * 0.5f;
60 freqVal = getSliderValue("frequency") * 18000.f;
61}
62
63void LEAFTest_controllerInput (int cnum, float cval)
64{
65
66}
67
68void LEAFTest_pitchBendInput (int pitchBend)
69{
70
71}
72
73int lastNote;
74void LEAFTest_noteOn (int note, float velocity)
75{
76}
77
78
79void LEAFTest_noteOff (int note)
80{
81}53}
82 54
83 55float depth = 1.0f;
84 56
85void LEAFTest_end (void)57float LEAFTest_tick (float input)
86{58{
87 59 float sample = 0.f;
88}60
89 61 tBuffer_tick(&buff, input); // ticking the buffer records in to buffer
90// LEAF POOL UTILITIES62
91 63 tSampler_setRate(&samp, tCycle_tick(&osc) * depth);
92void leaf_pool_report(void)64
93{65 // dont tick sampler if buffer not active (not recording)
94 DBG(String(leaf_pool_get_used()) + " of " + String(leaf_pool_get_size()));66 if (buff.active == 0)
95}67 {
96 68 sample = tSampler_tick(&samp); // ticking sampler loops sample
97void leaf_pool_dump(void)69 }
98{70
99 float* buff = (float*)leaf_pool_get_pool();71
100 int siz = leaf_pool_get_size();72 return sample;
101 siz /= sizeof(float);73}
102 for (int i = 0; i < siz; i++)74
103 {75bool lastState = false, lastPlayState = false;
104 DBG(String(buff[i]));76void LEAFTest_block (void)
105 }77{
106}78 bool state = getButtonState("record");
107 79
108static void run_pool_test(void)80 if (state)
109{
110 leaf_pool_report();
111
112 DBG("ALLOC BUFFER 1");
113 int size = 50;
114 float* buffer;
115 buffer = (float*) leaf_alloc(sizeof(float) * size);
116
117 for (int i = 0; i < size; i++)
118 {
119 buffer[i] = (float)i;
120
121 }
122
123 leaf_pool_report();
124
125 DBG("ALLOC BUFFER 2");
126 size = 25;
127
128 buffer = (float*) leaf_alloc(sizeof(float) * size);
129
130 leaf_pool_report();
131
132 for (int i = 0; i < size; i++)
133 {81 {
134 buffer[i] = (float)(i*2);82 setButtonState("record", false);
83 tBuffer_record(&buff);
135 }84 }
136 leaf_free(buffer);
137
138 leaf_pool_report();
139
140 DBG("ALLOC BUFFER 3");
141 size = 15;
142 85
143 buffer = (float*) leaf_alloc(sizeof(float) * size);86 float val = getSliderValue("mod freq");
144 87
145 for (int i = 0; i < size; i++)88 float freq = 0.1 + 999.9 * val;
146 {89
147 buffer[i] = (float)(i*3);90 tCycle_setFreq(&osc, freq);
148 }91
149 92 DBG("mod freq: " + String(freq));
150 leaf_pool_report();93
151 94 val = getSliderValue("mod depth");
152 leaf_pool_dump();95
153}96 depth = 0.1 + val * 15.9f;
97
98 DBG("mod depth: " + String(depth));
99
100
101}
102
103void LEAFTest_controllerInput (int cnum, float cval)
104{
105
106}
107
108void LEAFTest_pitchBendInput (int pitchBend)
109{
110
111}
112
113int lastNote;
114void LEAFTest_noteOn (int note, float velocity)
115{
116}
117
118
119void LEAFTest_noteOff (int note)
120{
121}
122
123
124
125void LEAFTest_end (void)
126{
127
128}
129
130// LEAF POOL UTILITIES
131
132void leaf_pool_report(void)
133{
134 DBG(String(leaf_pool_get_used()) + " of " + String(leaf_pool_get_size()));
135}
136
137void leaf_pool_dump(void)
138{
139 float* buff = (float*)leaf_pool_get_pool();
140 int siz = leaf_pool_get_size();
141 siz /= sizeof(float);
142 for (int i = 0; i < siz; i++)
143 {
144 DBG(String(buff[i]));
145 }
146}
147
148static void run_pool_test(void)
149{
150 leaf_pool_report();
151
152 DBG("ALLOC BUFFER 1");
153 int size = 50;
154 float* buffer;
155 buffer = (float*) leaf_alloc(sizeof(float) * size);
156
157 for (int i = 0; i < size; i++)
158 {
159 buffer[i] = (float)i;
160
161 }
162
163 leaf_pool_report();
164
165 DBG("ALLOC BUFFER 2");
166 size = 25;
167
168 buffer = (float*) leaf_alloc(sizeof(float) * size);
169
170 leaf_pool_report();
171
172 for (int i = 0; i < size; i++)
173 {
174 buffer[i] = (float)(i*2);
175 }
176 leaf_free(buffer);
177
178 leaf_pool_report();
179
180 DBG("ALLOC BUFFER 3");
181 size = 15;
182
183 buffer = (float*) leaf_alloc(sizeof(float) * size);
184
185 for (int i = 0; i < size; i++)
186 {
187 buffer[i] = (float)(i*3);
188 }
189
190 leaf_pool_report();
191
192 leaf_pool_dump();
193}
194

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