Showing the changes to TestPlugin/Source/MyTest.cpp (1 of 3 files). Show all
Unified · Split
| @@ -82,6 +82,7 @@ inline double getSawFall(double angle) { · 81 unmodified lines | ||
| 82 | 82 | |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | +float lastFreq; | |
| 85 | 86 | float LEAFTest_tick (float input) |
| 86 | 87 | { |
| 87 | 88 | // tMBSaw_setFreq(&bsaw, x); |
| @@ -96,25 +97,25 @@ float LEAFTest_tick (float input) · 8 unmodified lines | ||
| 96 | 97 | // return tMBPulse_tick(&bpulse); |
| 97 | 98 | |
| 98 | 99 | |
| 99 | − if (x > 0.5) | |
| 100 | − { | |
| 101 | − tPitchDetector_tick(&detector, input); | |
| 102 | − if (tPitchDetector_getPeriodicity(&detector) > 0.99 && (tZeroCrossing_tick(&zc, input) < 0.05)) | |
| 103 | − { | |
| 104 | − float freq = tPitchDetector_getFrequency(&detector); | |
| 105 | − if (freq != 0.0f) | |
| 106 | − tMBTriangle_setFreq(&btri, freq); | |
| 107 | − } | |
| 100 | + float freq = 1.0f/tPeriodDetection_tick(&pd, input) * leaf.sampleRate; | |
| 101 | + tPitchDetector_tick(&detector, input); | |
| 108 | 102 | |
| 103 | + if (tPitchDetector_getPeriodicity(&detector) > 0.0) | |
| 104 | + { | |
| 105 | + float altFreq = tPitchDetector_getFrequency(&detector); | |
| 106 | + if (fabsf(lastFreq - freq) > fabsf(lastFreq - altFreq)) | |
| 107 | + freq = altFreq; | |
| 109 | 108 | } |
| 110 | − else | |
| 109 | + | |
| 110 | + if (tZeroCrossing_tick(&zc, input) < 0.05 && freq > 0.0f) | |
| 111 | 111 | { |
| 112 | − float freq = 1.0f/tPeriodDetection_tick(&pd, input) * leaf.sampleRate; | |
| 113 | − if (tZeroCrossing_tick(&zc, input) < 0.05) | |
| 114 | − tMBTriangle_setFreq(&btri, freq); | |
| 112 | + tMBTriangle_setFreq(&btri, freq); | |
| 115 | 113 | } |
| 116 | 114 | |
| 117 | 115 | float g = tEnvelopeFollower_tick(&ef, input); |
| 116 | + | |
| 117 | + lastFreq = freq; | |
| 118 | + | |
| 118 | 119 | return input + tMBTriangle_tick(&btri) * g * 10.0f; |
| 119 | 120 | } |
| 120 | 121 | |