Showing the changes to TestPlugin/Source/MyTest.cpp (1 of 3 files). Show all
Unified · Split
| @@ -18,14 +18,18 @@ tMBSaw bsaw; · 17 unmodified lines | ||
| 18 | 18 | tMBTriangle btri; |
| 19 | 19 | tMBPulse bpulse; |
| 20 | 20 | |
| 21 | −tPitchDetector detector; | |
| 21 | +tDualPitchDetector detector; | |
| 22 | + | |
| 23 | +tCompressor compressor; | |
| 24 | + | |
| 25 | +tSVF lp, hp; | |
| 22 | 26 | |
| 23 | 27 | tPeriodDetection pd; |
| 24 | 28 | |
| 25 | 29 | tZeroCrossingCounter zc; |
| 26 | 30 | tEnvelopeFollower ef; |
| 27 | 31 | |
| 28 | −tCycle sine; | |
| 32 | +tTriangle tri; | |
| 29 | 33 | |
| 30 | 34 | tBuffer samp; |
| 31 | 35 | tMBSampler sampler; |
| @@ -54,16 +58,21 @@ void LEAFTest_init (float sampleRate, int blockSize) · 22 unmodified lines | ||
| 54 | 58 | |
| 55 | 59 | bufIn = (float*) leaf_alloc(sizeof(float) * 4096); |
| 56 | 60 | bufOut = (float*) leaf_alloc(sizeof(float) * 4096); |
| 57 | − // lowestFreq, highestFreq, hysteresis (width of hysteresis region around 0.0 for zero crossing detection) | |
| 58 | − tPitchDetector_init(&detector, mtof(48), mtof(84), 0.01f); | |
| 61 | + | |
| 62 | + tDualPitchDetector_init(&detector, mtof(53), mtof(77)); | |
| 63 | + | |
| 64 | + tCompressor_init(&compressor); | |
| 65 | + | |
| 66 | + tSVF_init(&lp, SVFTypeLowpass, mtof(77) * 2.0f, 1.0f); | |
| 67 | + tSVF_init(&hp, SVFTypeHighpass, mtof(48) * 0.5f, 1.0f); | |
| 59 | 68 | |
| 60 | 69 | tPeriodDetection_init(&pd, bufIn, bufOut, 4096, 1024); |
| 61 | 70 | |
| 62 | 71 | tZeroCrossingCounter_init(&zc, 128); |
| 63 | 72 | tEnvelopeFollower_init(&ef, 0.02f, 0.9999f); |
| 64 | 73 | |
| 65 | − tCycle_init(&sine); | |
| 66 | − tCycle_setFreq(&sine, 100); | |
| 74 | + tTriangle_init(&tri); | |
| 75 | + tTriangle_setFreq(&tri, 100); | |
| 67 | 76 | |
| 68 | 77 | tBuffer_init(&samp, 5.0f * leaf.sampleRate); |
| 69 | 78 | tMBSampler_init(&sampler, &samp); |
| @@ -81,12 +90,11 @@ inline double getSawFall(double angle) { · 11 unmodified lines | ||
| 81 | 90 | |
| 82 | 91 | } |
| 83 | 92 | |
| 84 | −float lastFreq; | |
| 85 | 93 | float LEAFTest_tick (float input) |
| 86 | 94 | { |
| 87 | − tBuffer_tick(&samp, input); | |
| 88 | − | |
| 89 | − return tMBSampler_tick(&sampler); | |
| 95 | +// tBuffer_tick(&samp, input); | |
| 96 | +// | |
| 97 | +// return tMBSampler_tick(&sampler); | |
| 90 | 98 | |
| 91 | 99 | |
| 92 | 100 | // tMBSaw_setFreq(&bsaw, x); |
| @@ -99,34 +107,34 @@ float LEAFTest_tick (float input) · 6 unmodified lines | ||
| 99 | 107 | //// return tMBSaw_tick(&bsaw); |
| 100 | 108 | //// return tMBTriangle_tick(&btri); |
| 101 | 109 | // return tMBPulse_tick(&bpulse); |
| 102 | − | |
| 110 | + | |
| 111 | + input = tSVF_tick(&hp, tSVF_tick(&lp, tCompressor_tick(&compressor, input))); | |
| 103 | 112 | |
| 104 | 113 | // float freq = 1.0f/tPeriodDetection_tick(&pd, input) * leaf.sampleRate; |
| 105 | −// tPitchDetector_tick(&detector, input); | |
| 106 | −// float altFreq = tPitchDetector_getFrequency(&detector); | |
| 107 | −// | |
| 114 | + tDualPitchDetector_tick(&detector, input); | |
| 115 | + float altFreq = tDualPitchDetector_getFrequency(&detector); | |
| 116 | + | |
| 108 | 117 | // if (fabsf(1.0f - (freq / altFreq)) < 0.05f) |
| 109 | −//// if (tZeroCrossingCounter_tick(&zc, input) < 0.05 && freq > 0.0f) | |
| 110 | −// { | |
| 111 | −// tCycle_setFreq(&sine, altFreq); | |
| 112 | −// } | |
| 113 | −// | |
| 114 | −// float g = tEnvelopeFollower_tick(&ef, input); | |
| 115 | −// | |
| 116 | −// lastFreq = freq; | |
| 117 | −// | |
| 118 | −// return tCycle_tick(&sine) * g * 2.0f + input; | |
| 118 | +// if (tZeroCrossingCounter_tick(&zc, input) < 0.05 && freq > 0.0f) | |
| 119 | + if (altFreq > 0.0f) | |
| 120 | + { | |
| 121 | + tTriangle_setFreq(&tri, altFreq); | |
| 122 | + } | |
| 123 | + | |
| 124 | + float g = tEnvelopeFollower_tick(&ef, input); | |
| 125 | + | |
| 126 | + return tTriangle_tick(&tri) * g; | |
| 119 | 127 | } |
| 120 | 128 | |
| 121 | 129 | int firstFrame = 1; |
| 122 | 130 | bool lastState = false, lastPlayState = false; |
| 123 | 131 | void LEAFTest_block (void) |
| 124 | 132 | { |
| 125 | − float periodicity = tPitchDetector_getPeriodicity(&detector); | |
| 133 | + float periodicity = tDualPitchDetector_getPeriodicity(&detector); | |
| 126 | 134 | if (periodicity > 0.99f) |
| 127 | 135 | { |
| 128 | − DBG(tPitchDetector_getFrequency(&detector)); | |
| 129 | − DBG(tPitchDetector_getPeriodicity(&detector)); | |
| 136 | + DBG(tDualPitchDetector_getFrequency(&detector)); | |
| 137 | + DBG(tDualPitchDetector_getPeriodicity(&detector)); | |
| 130 | 138 | } |
| 131 | 139 | |
| 132 | 140 | float val = getSliderValue("on/off"); |