History

rename LEAF_JUCEPlugin to TestPlugin

Matthew Wang committed 6 years ago

Commit a11130b1 parent 5d657f015 files · +0 −0Browse files

Showing the changes to TestPlugin/Source/MyTest.cpp (1 of 15 files). Show all

Unified · Split

TestPlugin/Source/MyTest.cpp+222−0
@@ -0,0 +1,222 @@
1/*
2 ==============================================================================
3 FM.c
4 Created: 23 Jan 2017 9:39:38am
5 Author: Michael R Mulshine
6 ==============================================================================
7 */
8
9#include "LEAFTest.h"
10#include "MyTest.h"
11
12
13static void leaf_pool_report(void);
14static void leaf_pool_dump(void);
15static void run_pool_test(void);
16
17tNoise noise;
18tSVF bp1;
19tSVF bp2;
20tFormantShifter fs;
21
22tSampler samp;
23tBuffer buff;
24tEnvelope env;
25
26tAutotune at;
27
28
29tMinBLEP minblep;
30
31tPhasor phasor;
32
33tHighpass hipass;
34
35tMBSaw saw;
36tMBPulse pulse;
37tMBTriangle tri;
38
39float gain;
40float freq;
41float dtime;
42bool buttonState;
43int ratio = 2;
44float x = 0.0f;
45float y = 0.0f;
46float a, b, c, d;
47
48#define MSIZE 500000
49char memory[MSIZE];
50
51void LEAFTest_init (float sampleRate, int blockSize)
52{
53 LEAF_init(sampleRate, blockSize, memory, MSIZE, &getRandomFloat);
54
55 tMBSaw_init(&saw);
56
57 tMBPulse_init(&pulse);
58
59 tMBTriangle_init(&tri);
60
61 tPhasor_init(&phasor);
62
63 tPhasor_setFreq(&phasor, 200);
64}
65
66inline double getSawFall(double angle) {
67
68 angle = fmod(angle + double_Pi, 2*double_Pi); // shift x
69 double sample = angle/double_Pi - double(1); // computer as remainder
70
71 return sample;
72
73}
74
75float LEAFTest_tick (float input)
76{
77
78 tMBSaw_setFreq(&saw, y);
79 tMBPulse_setWidth(&pulse, x);
80 tMBPulse_setFreq(&pulse, y);
81 tMBTriangle_setSkew(&tri, 0.0);//x*2.0f - 1.0f);
82 tMBTriangle_setFreq(&tri, y);
83
84 tPhasor_tick(&phasor);
85
86// if (phasor->phaseDidReset) tMBSaw_sync(&saw, 0.0f);
87// if (phasor->phaseDidReset) tMBPulse_sync(&pulse, 0.0f);
88 if (phasor->phaseDidReset) tMBTriangle_sync(&tri, 0.0f);
89
90// return tMBSaw_tick(&saw);
91// return tMBPulse_tick(&pulse);
92 return tMBTriangle_tick(&tri);
93}
94
95int firstFrame = 1;
96bool lastState = false, lastPlayState = false;
97void LEAFTest_block (void)
98{
99 // if (firstFrame == 1)
100 // {
101 // tBuffer_record(&buff); // starts recording
102 // tSampler_play(&samp); // start spitting samples out
103 // firstFrame = 0;
104 // }
105
106 float val = getSliderValue("mod freq");
107
108 x = val ;
109
110 // a = val * tBuffer_getBufferLength(&buff);
111
112 DBG("start: " + String(a));
113
114 val = getSliderValue("mod depth");
115
116 y = val * 5000.0f + 20.0f;
117
118 DBG(String(y));
119 // b = val * tBuffer_getBufferLength(&buff);
120
121 DBG("rate: " + String(b));
122 //
123 // tSampler_setStart(&samp, a);
124 // tSampler_setEnd(&samp, b);
125 // tSampler_setRate(&samp, b);
126
127 // tFormantShifter_setShiftFactor(&fs, x);
128 // tFormantShifter_setIntensity(&fs, y);
129
130}
131
132void LEAFTest_controllerInput (int cnum, float cval)
133{
134
135}
136
137void LEAFTest_pitchBendInput (int pitchBend)
138{
139
140}
141
142int lastNote;
143void LEAFTest_noteOn (int note, float velocity)
144{
145}
146
147
148void LEAFTest_noteOff (int note)
149{
150}
151
152
153
154void LEAFTest_end (void)
155{
156
157}
158
159// LEAF POOL UTILITIES
160
161void leaf_pool_report(void)
162{
163 DBG(String(leaf_pool_get_used()) + " of " + String(leaf_pool_get_size()));
164}
165
166void leaf_pool_dump(void)
167{
168 float* buff = (float*)leaf_pool_get_pool();
169 unsigned long siz = leaf_pool_get_size();
170 siz /= sizeof(float);
171 for (int i = 0; i < siz; i++)
172 {
173 DBG(String(buff[i]));
174 }
175}
176
177static void run_pool_test(void)
178{
179 leaf_pool_report();
180
181 DBG("ALLOC BUFFER 1");
182 int size = 50;
183 float* buffer;
184 buffer = (float*) leaf_alloc(sizeof(float) * size);
185
186 for (int i = 0; i < size; i++)
187 {
188 buffer[i] = (float)i;
189
190 }
191
192 leaf_pool_report();
193
194 DBG("ALLOC BUFFER 2");
195 size = 25;
196
197 buffer = (float*) leaf_alloc(sizeof(float) * size);
198
199 leaf_pool_report();
200
201 for (int i = 0; i < size; i++)
202 {
203 buffer[i] = (float)(i*2);
204 }
205 leaf_free((char*)buffer);
206
207 leaf_pool_report();
208
209 DBG("ALLOC BUFFER 3");
210 size = 15;
211
212 buffer = (float*) leaf_alloc(sizeof(float) * size);
213
214 for (int i = 0; i < size; i++)
215 {
216 buffer[i] = (float)(i*3);
217 }
218
219 leaf_pool_report();
220
221 leaf_pool_dump();
222}

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