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