History

remove the global leaf instance, a user declared instance of leaf must be passed into objects; update objects accordingly

Matthew Wang committed 6 years ago

Commit 53a6d7a1 parent 179138336 files · +837 −638Browse files

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

Unified · Split

TestPlugin/Source/MyTest.cpp+25−23
@@ -45,37 +45,39 @@ float a, b, c, d; · 44 unmodified lines
4545 float* bufIn;
4646 float* bufOut;
4747
48+LEAF leaf;
49+
4850 #define MSIZE 2048000
4951 char memory[MSIZE];
5052
5153 void LEAFTest_init (float sampleRate, int blockSize)
5254 {
53− LEAF_init(sampleRate, blockSize, memory, MSIZE, &getRandomFloat);
55+ LEAF_init(&leaf, sampleRate, blockSize, memory, MSIZE, &getRandomFloat);
5456
55− tMBSaw_init(&bsaw);
56− tMBTriangle_init(&btri);
57− tMBPulse_init(&bpulse);
57+ tMBSaw_init(&bsaw, &leaf);
58+ tMBTriangle_init(&btri, &leaf);
59+ tMBPulse_init(&bpulse, &leaf);
5860
59− bufIn = (float*) leaf_alloc(sizeof(float) * 4096);
60− bufOut = (float*) leaf_alloc(sizeof(float) * 4096);
61+ bufIn = (float*) leaf_alloc(&leaf, sizeof(float) * 4096);
62+ bufOut = (float*) leaf_alloc(&leaf, sizeof(float) * 4096);
6163
62− tDualPitchDetector_init(&detector, mtof(48), mtof(84));
64+ tDualPitchDetector_init(&detector, mtof(48), mtof(84), &leaf);
6365
64− tCompressor_init(&compressor);
66+ tCompressor_init(&compressor, &leaf);
6567
66− tSVF_init(&lp, SVFTypeLowpass, mtof(84) * 2.0f, 1.0f);
67− tSVF_init(&hp, SVFTypeHighpass, mtof(48) * 0.5f, 1.0f);
68+ tSVF_init(&lp, SVFTypeLowpass, mtof(84) * 2.0f, 1.0f, &leaf);
69+ tSVF_init(&hp, SVFTypeHighpass, mtof(48) * 0.5f, 1.0f, &leaf);
6870
69− tPeriodDetection_init(&pd, bufIn, bufOut, 4096, 1024);
71+ tPeriodDetection_init(&pd, bufIn, bufOut, 4096, 1024, &leaf);
7072
71− tZeroCrossingCounter_init(&zc, 128);
72− tEnvelopeFollower_init(&ef, 0.02f, 0.9999f);
73+ tZeroCrossingCounter_init(&zc, 128, &leaf);
74+ tEnvelopeFollower_init(&ef, 0.02f, 0.9999f, &leaf);
7375
74− tTriangle_init(&tri);
76+ tTriangle_init(&tri, &leaf);
7577 tTriangle_setFreq(&tri, 100);
7678
77− tBuffer_init(&samp, 5.0f * leaf.sampleRate);
78− tMBSampler_init(&sampler, &samp);
79+ tBuffer_init(&samp, 5.0f * leaf.sampleRate, &leaf);
80+ tMBSampler_init(&sampler, &samp, &leaf);
7981
8082 tMBSampler_setMode(&sampler, PlayLoop);
8183 tMBSampler_setEnd(&sampler, samp->bufferLength);
@@ -191,13 +193,13 @@ void LEAFTest_end (void) · 109 unmodified lines
191193
192194 void leaf_pool_report(void)
193195 {
194− DBG(String(leaf_pool_get_used()) + " of " + String(leaf_pool_get_size()));
196+ DBG(String(leaf_pool_get_used(&leaf)) + " of " + String(leaf_pool_get_size(&leaf)));
195197 }
196198
197199 void leaf_pool_dump(void)
198200 {
199− float* buff = (float*)leaf_pool_get_pool();
200− unsigned long siz = leaf_pool_get_size();
201+ float* buff = (float*)leaf_pool_get_pool(&leaf);
202+ unsigned long siz = leaf_pool_get_size(&leaf);
201203 siz /= sizeof(float);
202204 for (int i = 0; i < siz; i++)
203205 {
@@ -212,7 +214,7 @@ static void run_pool_test(void) · 8 unmodified lines
212214 DBG("ALLOC BUFFER 1");
213215 int size = 50;
214216 float* buffer;
215− buffer = (float*) leaf_alloc(sizeof(float) * size);
217+ buffer = (float*) leaf_alloc(&leaf, sizeof(float) * size);
216218
217219 for (int i = 0; i < size; i++)
218220 {
@@ -225,7 +227,7 @@ static void run_pool_test(void) · 6 unmodified lines
225227 DBG("ALLOC BUFFER 2");
226228 size = 25;
227229
228− buffer = (float*) leaf_alloc(sizeof(float) * size);
230+ buffer = (float*) leaf_alloc(&leaf, sizeof(float) * size);
229231
230232 leaf_pool_report();
231233
@@ -233,14 +235,14 @@ static void run_pool_test(void) · 1 unmodified line
233235 {
234236 buffer[i] = (float)(i*2);
235237 }
236− leaf_free((char*)buffer);
238+ leaf_free(&leaf, (char*)buffer);
237239
238240 leaf_pool_report();
239241
240242 DBG("ALLOC BUFFER 3");
241243 size = 15;
242244
243− buffer = (float*) leaf_alloc(sizeof(float) * size);
245+ buffer = (float*) leaf_alloc(&leaf, sizeof(float) * size);
244246
245247 for (int i = 0; i < size; i++)
246248 {

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