| @@ -14,45 +14,228 @@ · 13 unmodified lines |
| 14 | | 14 | |
| 15 | static void leaf_pool_report(void); | 15 | static void leaf_pool_report(void); |
| 16 | static void leaf_pool_dump(void); | 16 | static void leaf_pool_dump(void); |
| 17 | static void run_pool_test(void); | 17 | static void run_pool_test(void); |
| | 18 | |
| | 19 | |
| | 20 | // INPUT |
| | 21 | tDelayL in_delay; |
| | 22 | tOnePole in_filter; |
| | 23 | tDelayA in_allpass[4]; |
| | 24 | float in_allpass_delays[4] = { 4.771f, 3.595f, 12.73f, 9.307f }; |
| | 25 | float in_allpass_gains[4] = { 0.75f, 0.75f, 0.625f, 0.625f }; |
| | 26 | |
| | 27 | // FEEDBACK 1 |
| | 28 | tDelayA f1_allpass; |
| | 29 | tDelayL f1_delay_1; |
| | 30 | tOnePole f1_filter; |
| | 31 | tDelayL f1_delay_2; |
| | 32 | tDelayL f1_delay_3; |
| | 33 | |
| | 34 | tCycle f1_lfo; |
| | 35 | |
| | 36 | // FEEDBACK 2 |
| | 37 | tDelayA f2_allpass; |
| | 38 | tDelayL f2_delay_1; |
| | 39 | tOnePole f2_filter; |
| | 40 | tDelayL f2_delay_2; |
| | 41 | tDelayL f2_delay_3; |
| | 42 | |
| | 43 | tCycle f2_lfo; |
| | 44 | |
| | 45 | float t; |
| 18 | | 46 | |
| 19 | tSquare osc; | | |
| 20 | | 47 | |
| 21 | void LEAFTest_init (float sampleRate, int blockSize) | 48 | void LEAFTest_init (float sampleRate, int blockSize) |
| 22 | { | 49 | { |
| 23 | LEAF_init(sampleRate, blockSize, &randomNumberGenerator); | 50 | LEAF_init(sampleRate, blockSize, &randomNumberGenerator); |
| 24 | | 51 | |
| 25 | tSquare_init(&osc); | 52 | t = leaf.sampleRate * 0.001f; |
| 26 | tSquare_setFreq(&osc, 110.0f); | | |
| 27 | | 53 | |
| 28 | tSquare_setTableSize(&osc, 4000); | 54 | // ==================DATTORRO=================== |
| 29 | | 55 | // INPUT |
| | 56 | tDelayL_init(&in_delay, 0.f, 200.f*t); |
| | 57 | tOnePole_init(&in_filter, 1.f); |
| | 58 | |
| | 59 | for (int i = 0; i < 4; i++) |
| | 60 | { |
| | 61 | tDelayA_init(&in_allpass[i], in_allpass_delays[i], 20.f*t); |
| | 62 | tDelayA_setGain(&in_allpass[i], in_allpass_gains[i]); |
| | 63 | } |
| | 64 | |
| | 65 | // FEEDBACK 1 |
| | 66 | tDelayA_init(&f1_allpass, 30.51f*t, 100.f*t); |
| | 67 | tDelayA_setGain(&f1_allpass, 0.7f); |
| | 68 | |
| | 69 | tDelayL_init(&f1_delay_1, 141.69f*t, 200.0f*t); |
| | 70 | tDelayL_init(&f1_delay_2, 89.24f*t, 100.0f*t); |
| | 71 | tDelayL_init(&f1_delay_3, 125.f*t, 200.0f*t); |
| | 72 | |
| | 73 | tOnePole_init(&f1_filter, 1.f); |
| | 74 | |
| | 75 | tCycle_init(&f1_lfo); |
| | 76 | tCycle_setFreq(&f1_lfo, 0.1f); |
| | 77 | |
| | 78 | // FEEDBACK 2 |
| | 79 | tDelayA_init(&f2_allpass, 22.58f*t, 100.f*t); |
| | 80 | tDelayA_setGain(&f2_allpass, 0.7f); |
| | 81 | |
| | 82 | tDelayL_init(&f2_delay_1, 149.62f*t, 200.0f*t); |
| | 83 | tDelayL_init(&f2_delay_2, 60.48f*t, 100.0f*t); |
| | 84 | tDelayL_init(&f2_delay_3, 106.28f*t, 200.0f*t); |
| | 85 | |
| | 86 | tOnePole_init(&f2_filter, 1.f); |
| | 87 | |
| | 88 | tCycle_init(&f2_lfo); |
| | 89 | tCycle_setFreq(&f2_lfo, 0.07f); |
| | 90 | |
| | 91 | // ============================================= |
| | 92 | |
| 30 | leaf_pool_report(); | 93 | leaf_pool_report(); |
| 31 | } | 94 | } |
| 32 | | 95 | |
| 33 | int timer = 0; | 96 | int timer = 0; |
| | 97 | |
| | 98 | |
| | 99 | float f1_delay_2_last; |
| | 100 | float f2_delay_2_last; |
| | 101 | |
| | 102 | float f1_last; |
| | 103 | float f2_last; |
| | 104 | |
| | 105 | |
| | 106 | float mix; |
| | 107 | float predelay = 0.f; |
| | 108 | float input_filter = 1.; |
| | 109 | float feedback_filter = 1.f; |
| | 110 | float feedback_gain = 0.0f; |
| | 111 | |
| 34 | | 112 | |
| 35 | float prev = 0.0; | | |
| 36 | | 113 | |
| 37 | float LEAFTest_tick (float input) | 114 | float LEAFTest_tick (float input) |
| 38 | { | 115 | { |
| 39 | float sample = 0.0f; | 116 | // ==================DATTORRO=================== |
| 40 | | 117 | |
| 41 | timer++; | 118 | // INPUT |
| 42 | if (timer == (1 * leaf.sampleRate)) | 119 | float in_sample = tDelayL_tick(&in_delay, input); |
| 43 | { | 120 | |
| 44 | timer = 0; | 121 | in_sample = tOnePole_tick(&in_filter, in_sample); |
| | 122 | |
| | 123 | for (int i = 0; i < 4; i++) |
| | 124 | { |
| | 125 | in_sample = tDelayA_tick(&in_allpass[i], in_sample); |
| 45 | } | 126 | } |
| | 127 | |
| | 128 | // FEEDBACK 1 |
| | 129 | float f1_sample = in_sample + f2_last; // + f2_last_out; |
| | 130 | |
| | 131 | tDelayA_setDelay(&f1_allpass, 30.51f*t + tCycle_tick(&f1_lfo) * 4.0f); |
| | 132 | |
| | 133 | f1_sample = tDelayA_tick(&f1_allpass, f1_sample); |
| | 134 | |
| | 135 | f1_sample = tDelayL_tick(&f1_delay_1, f1_sample); |
| | 136 | |
| | 137 | f1_sample = tOnePole_tick(&f1_filter, f1_sample); |
| | 138 | |
| | 139 | f1_sample = f1_sample + f1_delay_2_last * 0.5f; |
| | 140 | |
| | 141 | float f1_delay_2_sample = tDelayL_tick(&f1_delay_2, f1_sample * 0.5f); |
| | 142 | |
| | 143 | f1_delay_2_last = f1_delay_2_sample; |
| | 144 | |
| | 145 | f1_sample = f1_delay_2_last + f1_sample; |
| | 146 | |
| | 147 | f1_sample *= feedback_gain; |
| | 148 | |
| | 149 | f1_last = tDelayL_tick(&f1_delay_3, f1_sample); |
| | 150 | |
| | 151 | // FEEDBACK 2 |
| | 152 | float f2_sample = in_sample + f1_last; |
| | 153 | |
| | 154 | tDelayA_setDelay(&f2_allpass, 22.58f*t + tCycle_tick(&f2_lfo) * 4.0f); |
| | 155 | |
| | 156 | f2_sample = tDelayA_tick(&f2_allpass, f2_sample); |
| | 157 | |
| | 158 | f2_sample = tDelayL_tick(&f2_delay_1, f2_sample); |
| 46 | | 159 | |
| 47 | sample = 0.5 * tSquare_tick(&osc); | 160 | f2_sample = tOnePole_tick(&f2_filter, f2_sample); |
| | 161 | |
| | 162 | f2_sample = f2_sample + f2_delay_2_last * 0.5f; |
| | 163 | |
| | 164 | float f2_delay_2_sample = tDelayL_tick(&f2_delay_2, f2_sample * 0.5f); |
| | 165 | |
| | 166 | f2_delay_2_last = f2_delay_2_sample; |
| | 167 | |
| | 168 | f2_sample = f2_delay_2_last + f2_sample; |
| | 169 | |
| | 170 | f2_sample *= feedback_gain; |
| | 171 | |
| | 172 | f2_last = tDelayL_tick(&f2_delay_3, f2_sample); |
| | 173 | |
| | 174 | // TAP OUT 1 |
| | 175 | f1_sample = tDelayL_tapOut(&f1_delay_1, 8.9f*t) + |
| | 176 | tDelayL_tapOut(&f1_delay_1, 99.8f*t); |
| | 177 | |
| | 178 | f1_sample -= tDelayL_tapOut(&f1_delay_2, 64.2f*t); |
| | 179 | |
| | 180 | f1_sample += tDelayL_tapOut(&f1_delay_3, 67.f*t); |
| | 181 | |
| | 182 | f1_sample -= tDelayL_tapOut(&f2_delay_1, 66.8f*t); |
| | 183 | |
| | 184 | f1_sample -= tDelayL_tapOut(&f2_delay_2, 6.3f*t); |
| | 185 | |
| | 186 | f1_sample -= tDelayL_tapOut(&f2_delay_3, 35.8f*t); |
| | 187 | |
| | 188 | f1_sample *= 0.14; |
| | 189 | |
| | 190 | // TAP OUT 2 |
| | 191 | f2_sample = tDelayL_tapOut(&f2_delay_1, 11.8f*t) + |
| | 192 | tDelayL_tapOut(&f2_delay_1, 121.7f*t); |
| | 193 | |
| | 194 | f2_sample -= tDelayL_tapOut(&f2_delay_2, 6.3f*t); |
| | 195 | |
| | 196 | f2_sample += tDelayL_tapOut(&f2_delay_3, 89.7f*t); |
| | 197 | |
| | 198 | f2_sample -= tDelayL_tapOut(&f1_delay_1, 70.8f*t); |
| | 199 | |
| | 200 | f2_sample -= tDelayL_tapOut(&f1_delay_2, 11.2f*t); |
| | 201 | |
| | 202 | f2_sample -= tDelayL_tapOut(&f1_delay_3, 4.1f*t); |
| | 203 | |
| | 204 | f2_sample *= 0.14f; |
| | 205 | |
| | 206 | float sample = (f1_sample + f2_sample) * 0.5f; |
| | 207 | |
| | 208 | // ============================================= |
| 48 | | 209 | |
| 49 | return sample; | 210 | return (input * (1.0f - mix) + sample * mix); |
| 50 | | 211 | |
| 51 | } | 212 | } |
| 52 | | 213 | |
| 53 | void LEAFTest_block (void) | 214 | void LEAFTest_block (void) |
| 54 | { | 215 | { |
| 55 | float val = getSliderValue("mix"); | 216 | float val = getSliderValue("mix"); |
| | 217 | |
| | 218 | mix = val; |
| | 219 | |
| | 220 | val = getSliderValue("predelay"); |
| | 221 | |
| | 222 | predelay = (val * 200.f) * leaf.sampleRate * 0.001f; |
| | 223 | tDelayL_setDelay(&in_delay, predelay); |
| | 224 | |
| | 225 | val = getSliderValue("input filter"); |
| | 226 | |
| | 227 | input_filter = val * 20000.f; |
| | 228 | tOnePole_setFreq(&in_filter, input_filter); |
| | 229 | |
| | 230 | val = getSliderValue("feedback filter"); |
| | 231 | |
| | 232 | feedback_filter = val * 20000.f; |
| | 233 | tOnePole_setFreq(&f1_filter, feedback_filter); |
| | 234 | tOnePole_setFreq(&f2_filter, feedback_filter); |
| | 235 | |
| | 236 | val = getSliderValue("feedback gain"); |
| | 237 | |
| | 238 | feedback_gain = val; |
| 56 | } | 239 | } |
| 57 | | 240 | |
| 58 | void LEAFTest_controllerInput (int cnum, float cval) | 241 | void LEAFTest_controllerInput (int cnum, float cval) |