Showing the changes to TestPlugin/Source/MyTest.cpp (1 of 7 files). Show all
Unified · Split
| @@ -33,6 +33,8 @@ tMBSaw bsaw; · 32 unmodified lines | ||
| 33 | 33 | tMBTriangle btri; |
| 34 | 34 | tMBPulse bpulse; |
| 35 | 35 | |
| 36 | +tPitchDetector detector; | |
| 37 | + | |
| 36 | 38 | float gain; |
| 37 | 39 | float freq; |
| 38 | 40 | float dtime; |
| @@ -42,7 +44,7 @@ float x = 0.0f; · 3 unmodified lines | ||
| 42 | 44 | float y = 0.0f; |
| 43 | 45 | float a, b, c, d; |
| 44 | 46 | |
| 45 | −#define MSIZE 50000 | |
| 47 | +#define MSIZE 500000 | |
| 46 | 48 | char memory[MSIZE]; |
| 47 | 49 | |
| 48 | 50 | void LEAFTest_init (float sampleRate, int blockSize) |
| @@ -52,6 +54,8 @@ void LEAFTest_init (float sampleRate, int blockSize) · 3 unmodified lines | ||
| 52 | 54 | tMBSaw_init(&bsaw); |
| 53 | 55 | tMBTriangle_init(&btri); |
| 54 | 56 | tMBPulse_init(&bpulse); |
| 57 | + | |
| 58 | + tPitchDetector_init(&detector, 1000.0f, 5000.0f, 0.0f); | |
| 55 | 59 | } |
| 56 | 60 | |
| 57 | 61 | inline double getSawFall(double angle) { |
| @@ -65,22 +69,30 @@ inline double getSawFall(double angle) { · 7 unmodified lines | ||
| 65 | 69 | |
| 66 | 70 | float LEAFTest_tick (float input) |
| 67 | 71 | { |
| 68 | − tMBSaw_setFreq(&bsaw, x); | |
| 69 | − tMBTriangle_setFreq(&btri, x); | |
| 70 | − tMBPulse_setFreq(&bpulse, x); | |
| 71 | − | |
| 72 | − tMBTriangle_setWidth(&btri, y); | |
| 73 | − tMBPulse_setWidth(&bpulse, y); | |
| 74 | − | |
| 75 | −// return tMBSaw_tick(&bsaw); | |
| 76 | −// return tMBTriangle_tick(&btri); | |
| 77 | − return tMBPulse_tick(&bpulse); | |
| 72 | +// tMBSaw_setFreq(&bsaw, x); | |
| 73 | +// tMBTriangle_setFreq(&btri, x); | |
| 74 | +// tMBPulse_setFreq(&bpulse, x); | |
| 75 | +// | |
| 76 | +// tMBTriangle_setWidth(&btri, y); | |
| 77 | +// tMBPulse_setWidth(&bpulse, y); | |
| 78 | +// | |
| 79 | +//// return tMBSaw_tick(&bsaw); | |
| 80 | +//// return tMBTriangle_tick(&btri); | |
| 81 | +// return tMBPulse_tick(&bpulse); | |
| 82 | + | |
| 83 | + tPitchDetector_tick(&detector, input); | |
| 84 | + | |
| 85 | + tMBTriangle_setFreq(&btri, tPitchDetector_getFrequency(&detector)); | |
| 86 | + | |
| 87 | + return input + tMBTriangle_tick(&btri) * 0.25; | |
| 78 | 88 | } |
| 79 | 89 | |
| 80 | 90 | int firstFrame = 1; |
| 81 | 91 | bool lastState = false, lastPlayState = false; |
| 82 | 92 | void LEAFTest_block (void) |
| 83 | 93 | { |
| 94 | + DBG(tPitchDetector_getFrequency(&detector)); | |
| 95 | + DBG(tPitchDetector_getPeriodicity(&detector)); | |
| 84 | 96 | // if (firstFrame == 1) |
| 85 | 97 | // { |
| 86 | 98 | // tBuffer_record(&buff); // starts recording |
| @@ -94,15 +106,15 @@ void LEAFTest_block (void) · 7 unmodified lines | ||
| 94 | 106 | |
| 95 | 107 | // a = val * tBuffer_getBufferLength(&buff); |
| 96 | 108 | |
| 97 | − DBG("start: " + String(a)); | |
| 109 | +// DBG("start: " + String(a)); | |
| 98 | 110 | |
| 99 | 111 | val = getSliderValue("mod depth"); |
| 100 | 112 | |
| 101 | 113 | y = val * 2.0f - 1.0f; |
| 102 | − DBG(String(y)); | |
| 114 | +// DBG(String(y)); | |
| 103 | 115 | // b = val * tBuffer_getBufferLength(&buff); |
| 104 | 116 | |
| 105 | − DBG("rate: " + String(b)); | |
| 117 | +// DBG("rate: " + String(b)); | |
| 106 | 118 | // |
| 107 | 119 | // tSampler_setStart(&samp, a); |
| 108 | 120 | // tSampler_setEnd(&samp, b); |