ref: 71e82bd67cba20a233a7c5313dc803965899db97
dir: /LEAF_JUCEPlugin/Source/MyTest.cpp/
/* ============================================================================== FM.c Created: 23 Jan 2017 9:39:38am Author: Michael R Mulshine ============================================================================== */ #include "LEAFTest.h" #include "MyTest.h" static void leaf_pool_report(void); static void leaf_pool_dump(void); static void run_pool_test(void); tSine sine; tSaw saw; tTri tri; tPulse pulse; tPhasor phasor; float gain; float freq; float dtime; bool buttonState; int ratio = 2; float x = 0.0f; float y = 0.0f; float a, b, c, d; #define MSIZE 500000 char memory[MSIZE]; void LEAFTest_init (float sampleRate, int blockSize) { LEAF_init(sampleRate, blockSize, memory, MSIZE, &getRandomFloat); tSine_init(&sine, 1000); tSine_setFreq(&sine, 200); tSaw_init(&saw); tSaw_setFreq(&saw, 200); tPulse_init(&pulse); tPulse_setFreq(&pulse, 200); tTri_init(&tri); tTri_setFreq(&tri, 200); tPhasor_init(&phasor); } float LEAFTest_tick (float input) { // return tSine_tick(&sine); tSaw_setFreq(&saw, x); tPhasor_setFreq(&phasor, x); return tSaw_tick(&saw); // tTri_setFreq(&tri, x); // tTri_setSkew(&tri, (y * 2.0f) - 1.0f); // return tTri_tick(&tri); // tPulse_setFreq(&pulse, x); // tPulse_setWidth(&pulse, y); // return tPulse_tick(&pulse); } int firstFrame = 1; bool lastState = false, lastPlayState = false; void LEAFTest_block (void) { float val = getSliderValue("mod freq"); x = val * 20000; DBG(String(x)); val = getSliderValue("mod depth"); y = val;; } void LEAFTest_controllerInput (int cnum, float cval) { } void LEAFTest_pitchBendInput (int pitchBend) { } int lastNote; void LEAFTest_noteOn (int note, float velocity) { } void LEAFTest_noteOff (int note) { } void LEAFTest_end (void) { } // LEAF POOL UTILITIES void leaf_pool_report(void) { DBG(String(leaf_pool_get_used()) + " of " + String(leaf_pool_get_size())); } void leaf_pool_dump(void) { float* buff = (float*)leaf_pool_get_pool(); unsigned long siz = leaf_pool_get_size(); siz /= sizeof(float); for (int i = 0; i < siz; i++) { DBG(String(buff[i])); } } static void run_pool_test(void) { leaf_pool_report(); DBG("ALLOC BUFFER 1"); int size = 50; float* buffer; buffer = (float*) leaf_alloc(sizeof(float) * size); for (int i = 0; i < size; i++) { buffer[i] = (float)i; } leaf_pool_report(); DBG("ALLOC BUFFER 2"); size = 25; buffer = (float*) leaf_alloc(sizeof(float) * size); leaf_pool_report(); for (int i = 0; i < size; i++) { buffer[i] = (float)(i*2); } leaf_free(buffer); leaf_pool_report(); DBG("ALLOC BUFFER 3"); size = 15; buffer = (float*) leaf_alloc(sizeof(float) * size); for (int i = 0; i < size; i++) { buffer[i] = (float)(i*3); } leaf_pool_report(); leaf_pool_dump(); }