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