Showing the changes to TestPlugin/Source/MyTest.cpp (1 of 2 files). Show all
Unified · Split
| @@ -35,6 +35,8 @@ tMBPulse bpulse; · 34 unmodified lines | ||
| 35 | 35 | |
| 36 | 36 | tPitchDetector detector; |
| 37 | 37 | |
| 38 | +tPeriodDetection pd; | |
| 39 | + | |
| 38 | 40 | float gain; |
| 39 | 41 | float freq; |
| 40 | 42 | float dtime; |
| @@ -44,6 +46,9 @@ float x = 0.0f; · 3 unmodified lines | ||
| 44 | 46 | float y = 0.0f; |
| 45 | 47 | float a, b, c, d; |
| 46 | 48 | |
| 49 | +float bufIn[4096]; | |
| 50 | +float bufOut[4096]; | |
| 51 | + | |
| 47 | 52 | #define MSIZE 500000 |
| 48 | 53 | char memory[MSIZE]; |
| 49 | 54 | |
| @@ -55,7 +60,11 @@ void LEAFTest_init (float sampleRate, int blockSize) · 5 unmodified lines | ||
| 55 | 60 | tMBTriangle_init(&btri); |
| 56 | 61 | tMBPulse_init(&bpulse); |
| 57 | 62 | |
| 58 | − tPitchDetector_init(&detector, 1000.0f, 5000.0f, 0.0f); | |
| 63 | + | |
| 64 | + // lowestFreq, highestFreq, hysteresis (width of hysteresis region around 0.0 for zero crossing detection) | |
| 65 | + tPitchDetector_init(&detector, mtof(48), mtof(84), 0.01f); | |
| 66 | + | |
| 67 | + tPeriodDetection_init(&pd, bufIn, bufOut, 4096, 1024); | |
| 59 | 68 | } |
| 60 | 69 | |
| 61 | 70 | inline double getSawFall(double angle) { |
| @@ -81,10 +90,13 @@ float LEAFTest_tick (float input) · 19 unmodified lines | ||
| 81 | 90 | // return tMBPulse_tick(&bpulse); |
| 82 | 91 | |
| 83 | 92 | tPitchDetector_tick(&detector, input); |
| 84 | − | |
| 93 | + | |
| 85 | 94 | tMBTriangle_setFreq(&btri, tPitchDetector_getFrequency(&detector)); |
| 86 | 95 | |
| 87 | − return input + tMBTriangle_tick(&btri) * 0.25; | |
| 96 | +// float freq = 1.0f/tPeriodDetection_tick(&pd, input) * leaf.sampleRate; | |
| 97 | +// tMBTriangle_setFreq(&btri, freq); | |
| 98 | + | |
| 99 | + return tMBTriangle_tick(&btri);// * 0.25; | |
| 88 | 100 | } |
| 89 | 101 | |
| 90 | 102 | int firstFrame = 1; |