Showing the changes to TestPlugin/Source/MyTest.cpp (1 of 6 files). Show all
Unified · Split
| @@ -18,7 +18,8 @@ tMBSaw bsaw; · 17 unmodified lines | ||
| 18 | 18 | tMBTriangle btri; |
| 19 | 19 | tMBPulse bpulse; |
| 20 | 20 | |
| 21 | −tDualPitchDetector detector; | |
| 21 | +tRetune retune; | |
| 22 | +tAutotune autotune; | |
| 22 | 23 | |
| 23 | 24 | tCompressor compressor; |
| 24 | 25 | |
| @@ -54,33 +55,8 @@ void LEAFTest_init (float sampleRate, int blockSize) · 29 unmodified lines | ||
| 54 | 55 | { |
| 55 | 56 | LEAF_init(&leaf, sampleRate, blockSize, memory, MSIZE, &getRandomFloat); |
| 56 | 57 | |
| 57 | − tMBSaw_init(&bsaw, &leaf); | |
| 58 | − tMBTriangle_init(&btri, &leaf); | |
| 59 | − tMBPulse_init(&bpulse, &leaf); | |
| 60 | − | |
| 61 | − bufIn = (float*) leaf_alloc(&leaf, sizeof(float) * 4096); | |
| 62 | − bufOut = (float*) leaf_alloc(&leaf, sizeof(float) * 4096); | |
| 63 | − | |
| 64 | − tDualPitchDetector_init(&detector, mtof(48), mtof(84), &leaf); | |
| 65 | − | |
| 66 | − tCompressor_init(&compressor, &leaf); | |
| 67 | − | |
| 68 | − tSVF_init(&lp, SVFTypeLowpass, mtof(84) * 2.0f, 1.0f, &leaf); | |
| 69 | − tSVF_init(&hp, SVFTypeHighpass, mtof(48) * 0.5f, 1.0f, &leaf); | |
| 70 | − | |
| 71 | − tPeriodDetection_init(&pd, bufIn, bufOut, 4096, 1024, &leaf); | |
| 72 | − | |
| 73 | − tZeroCrossingCounter_init(&zc, 128, &leaf); | |
| 74 | − tEnvelopeFollower_init(&ef, 0.02f, 0.9999f, &leaf); | |
| 75 | − | |
| 76 | − tTriangle_init(&tri, &leaf); | |
| 77 | − tTriangle_setFreq(&tri, 100); | |
| 78 | − | |
| 79 | − tBuffer_init(&samp, 5.0f * leaf.sampleRate, &leaf); | |
| 80 | − tMBSampler_init(&sampler, &samp, &leaf); | |
| 81 | − | |
| 82 | − tMBSampler_setMode(&sampler, PlayLoop); | |
| 83 | − tMBSampler_setEnd(&sampler, samp->bufferLength); | |
| 58 | + tRetune_init(&retune, 1, 1024, &leaf); | |
| 59 | + tAutotune_init(&autotune, 1, 1024, &leaf); | |
| 84 | 60 | } |
| 85 | 61 | |
| 86 | 62 | inline double getSawFall(double angle) { |
| @@ -94,72 +70,24 @@ inline double getSawFall(double angle) { · 7 unmodified lines | ||
| 94 | 70 | |
| 95 | 71 | float LEAFTest_tick (float input) |
| 96 | 72 | { |
| 97 | − tBuffer_tick(&samp, input); | |
| 98 | − | |
| 99 | − return tMBSampler_tick(&sampler); | |
| 100 | − | |
| 101 | − | |
| 102 | −// tMBSaw_setFreq(&bsaw, x); | |
| 103 | −// tMBTriangle_setFreq(&btri, x); | |
| 104 | −// tMBPulse_setFreq(&bpulse, x); | |
| 105 | −// | |
| 106 | −// tMBTriangle_setWidth(&btri, y); | |
| 107 | −// tMBPulse_setWidth(&bpulse, y); | |
| 108 | −// | |
| 109 | −//// return tMBSaw_tick(&bsaw); | |
| 110 | −//// return tMBTriangle_tick(&btri); | |
| 111 | −// return tMBPulse_tick(&bpulse); | |
| 112 | − | |
| 113 | −// input = tSVF_tick(&hp, tSVF_tick(&lp, tCompressor_tick(&compressor, input))); | |
| 114 | −// | |
| 115 | −//// float freq = 1.0f/tPeriodDetection_tick(&pd, input) * leaf.sampleRate; | |
| 116 | −// tDualPitchDetector_tick(&detector, input); | |
| 117 | −// float altFreq = tDualPitchDetector_getFrequency(&detector); | |
| 118 | −// | |
| 119 | −//// if (fabsf(1.0f - (freq / altFreq)) < 0.05f) | |
| 120 | −//// if (tZeroCrossingCounter_tick(&zc, input) < 0.05 && freq > 0.0f) | |
| 121 | −// if (altFreq > 0.0f) | |
| 122 | −// { | |
| 123 | −// tTriangle_setFreq(&tri, altFreq); | |
| 124 | −// } | |
| 125 | −// | |
| 126 | −// float g = tEnvelopeFollower_tick(&ef, input); | |
| 127 | −// | |
| 128 | −// return tTriangle_tick(&tri) * g; | |
| 73 | +// return tRetune_tick(&retune, input); | |
| 74 | + return tAutotune_tick(&autotune, input); | |
| 129 | 75 | } |
| 130 | 76 | |
| 131 | 77 | int firstFrame = 1; |
| 132 | 78 | bool lastState = false, lastPlayState = false; |
| 133 | 79 | void LEAFTest_block (void) |
| 134 | 80 | { |
| 135 | − float periodicity = tDualPitchDetector_getPeriodicity(&detector); | |
| 136 | − if (periodicity > 0.99f) | |
| 137 | − { | |
| 138 | − DBG(tDualPitchDetector_getFrequency(&detector)); | |
| 139 | − DBG(tDualPitchDetector_getPeriodicity(&detector)); | |
| 140 | − } | |
| 141 | − | |
| 142 | − float val = getSliderValue("on/off"); | |
| 143 | − | |
| 144 | − if (val > 0.5f && !sampler->active) | |
| 145 | − { | |
| 146 | − tBuffer_record(&samp); | |
| 147 | − tMBSampler_play(&sampler); | |
| 148 | − } | |
| 149 | − else if (val < 0.5f && sampler->active) | |
| 150 | − { | |
| 151 | − tMBSampler_stop(&sampler); | |
| 152 | − } | |
| 153 | − | |
| 154 | − val = getSliderValue("mod freq"); | |
| 155 | − | |
| 156 | − tMBSampler_setStart(&sampler, val * 5.0f * leaf.sampleRate); | |
| 81 | + float val = getSliderValue("slider1"); | |
| 82 | +// tRetune_setPitchFactor(&retune, val * 3.0f + 0.5f, 0); | |
| 83 | + tAutotune_setFreq(&autotune, 300, 0); | |
| 157 | 84 | |
| 85 | + val = getSliderValue("slider2"); | |
| 86 | +// tRetune_setPitchFactor(&retune, val * 3.0f + 0.5f, 1); | |
| 158 | 87 | |
| 159 | − val = getSliderValue("mod depth"); | |
| 160 | − | |
| 161 | − tMBSampler_setRate(&sampler, val * 8.0f - 4.0f); | |
| 162 | − | |
| 88 | + val = getSliderValue("slider3"); | |
| 89 | +// tRetune_setPitchFactor(&retune, val * 3.0f + 0.5f, 2); | |
| 90 | + | |
| 163 | 91 | } |
| 164 | 92 | |
| 165 | 93 | void LEAFTest_controllerInput (int cnum, float cval) |