134 mono_float tick_increment = 1.0f / num_samples;
139 poly_float current_low_pre_coefficient = low_pre_coefficient_;
140 poly_float current_high_pre_coefficient = high_pre_coefficient_;
141 poly_float current_low_coefficient = low_coefficient_;
142 poly_float current_low_amplitude = low_amplitude_;
143 poly_float current_high_coefficient = high_coefficient_;
144 poly_float current_high_amplitude = high_amplitude_;
150 poly_float delta_wet = (wet_ - current_wet) * tick_increment;
151 poly_float delta_dry = (dry_ - current_dry) * tick_increment;
167 poly_float delta_low_pre_coefficient = (low_pre_coefficient_ - current_low_pre_coefficient) * tick_increment;
168 poly_float delta_high_pre_coefficient = (high_pre_coefficient_ - current_high_pre_coefficient) * tick_increment;
179 poly_float delta_low_coefficient = (low_coefficient_ - current_low_coefficient) * tick_increment;
180 poly_float delta_high_coefficient = (high_coefficient_ - current_high_coefficient) * tick_increment;
189 poly_float delta_low_amplitude = (low_amplitude_ - current_low_amplitude) * tick_increment;
190 poly_float delta_high_amplitude = (high_amplitude_ - current_high_amplitude) * tick_increment;
199 mono_float* feedback_lookups1[] = { feedback_lookups_[0], feedback_lookups_[1],
200 feedback_lookups_[2], feedback_lookups_[3] };
201 mono_float* feedback_lookups2[] = { feedback_lookups_[4], feedback_lookups_[5],
202 feedback_lookups_[6], feedback_lookups_[7] };
203 mono_float* feedback_lookups3[] = { feedback_lookups_[8], feedback_lookups_[9],
204 feedback_lookups_[10], feedback_lookups_[11] };
205 mono_float* feedback_lookups4[] = { feedback_lookups_[12], feedback_lookups_[13],
206 feedback_lookups_[14], feedback_lookups_[15] };
214 poly_float decay_period = size_mult / decay_samples;
229 poly_float delta_decay1 = (decays_[0] - current_decay1) * tick_increment;
230 poly_float delta_decay2 = (decays_[1] - current_decay2) * tick_increment;
231 poly_float delta_decay3 = (decays_[2] - current_decay3) * tick_increment;
232 poly_float delta_decay4 = (decays_[3] - current_decay4) * tick_increment;
235 poly_int delay_offset(0, -1, -2, -3);
237 delay_offset += poly_float::kSize;
246 mono_float chorus_phase_increment = chorus_frequency / sample_rate;
251 poly_float container_phase = phase_offset + chorus_phase_ * 2.0f *
kPi;
252 chorus_phase_ += num_samples * chorus_phase_increment;
253 chorus_phase_ -= std::floor(chorus_phase_);
268 poly_float current_chorus_amount = chorus_amount_;
272 chorus_amount_ =
utils::min(chorus_amount_, delay1 - 8 * poly_float::kSize);
273 chorus_amount_ =
utils::min(chorus_amount_, delay2 - 8 * poly_float::kSize);
274 chorus_amount_ =
utils::min(chorus_amount_, delay3 - 8 * poly_float::kSize);
275 chorus_amount_ =
utils::min(chorus_amount_, delay4 - 8 * poly_float::kSize);
276 poly_float delta_chorus_amount = (chorus_amount_ - current_chorus_amount) * tick_increment;
277 current_chorus_amount = current_chorus_amount * size_mult;
280 poly_float current_sample_delay = sample_delay_;
281 poly_float current_delay_increment = sample_delay_increment_;
282 poly_float end_target = current_sample_delay + current_delay_increment * num_samples;
284 target_delay =
utils::interpolate(sample_delay_, target_delay, kSampleDelayMultiplier);
285 poly_float makeup_delay = target_delay - end_target;
286 poly_float delta_delay_increment = makeup_delay / (0.5f * num_samples * num_samples) * kSampleIncrementMultiplier;
288 for (
int i = 0; i < num_samples; ++i) {
290 current_chorus_amount += delta_chorus_amount;
292 auto old_real = current_chorus_real;
293 current_chorus_real = current_chorus_real * chorus_increment_real -
294 current_chorus_imaginary * chorus_increment_imaginary;
295 current_chorus_imaginary = current_chorus_imaginary * chorus_increment_real +
296 old_real * chorus_increment_imaginary;
299 poly_float feedback_offset1 = delay1 + current_chorus_real * current_chorus_amount;
300 poly_float feedback_offset2 = delay2 - current_chorus_real * current_chorus_amount;
301 poly_float feedback_offset3 = delay3 + current_chorus_imaginary * current_chorus_amount;
302 poly_float feedback_offset4 = delay4 - current_chorus_imaginary * current_chorus_amount;
316 filtered_input = low_pre_filter_.
tickBasic(
input, current_low_pre_coefficient) - filtered_input;
317 poly_float scaled_input = filtered_input * 0.25f;
331 int allpass_write_index = write_index_ & poly_allpass_mask_;
332 allpass_lookups_[0][allpass_write_index] = scaled_input + allpass_delay_input1;
333 allpass_lookups_[1][allpass_write_index] = scaled_input + allpass_delay_input2;
334 allpass_lookups_[2][allpass_write_index] = scaled_input + allpass_delay_input3;
335 allpass_lookups_[3][allpass_write_index] = scaled_input + allpass_delay_input4;
344 poly_float total_rows = allpass_output1 + allpass_output2 + allpass_output3 + allpass_output4;
348 poly_float write1 = other_feedback + allpass_output1;
349 poly_float write2 = other_feedback + allpass_output2;
350 poly_float write3 = other_feedback + allpass_output3;
351 poly_float write4 = other_feedback + allpass_output4;
355 allpass_output3.
value, allpass_output4.
value);
356 poly_float adjacent_feedback = (allpass_output1 + allpass_output2 + allpass_output3 + allpass_output4) * -0.5f;
358 write1 += adjacent_feedback[0];
359 write2 += adjacent_feedback[1];
360 write3 += adjacent_feedback[2];
361 write4 += adjacent_feedback[3];
364 poly_float high_filtered1 = high_shelf_filters_[0].
tickBasic(write1, current_high_coefficient);
365 poly_float high_filtered2 = high_shelf_filters_[1].
tickBasic(write2, current_high_coefficient);
366 poly_float high_filtered3 = high_shelf_filters_[2].
tickBasic(write3, current_high_coefficient);
367 poly_float high_filtered4 = high_shelf_filters_[3].
tickBasic(write4, current_high_coefficient);
368 write1 = high_filtered1 + current_high_amplitude * (write1 - high_filtered1);
369 write2 = high_filtered2 + current_high_amplitude * (write2 - high_filtered2);
370 write3 = high_filtered3 + current_high_amplitude * (write3 - high_filtered3);
371 write4 = high_filtered4 + current_high_amplitude * (write4 - high_filtered4);
374 poly_float low_filtered1 = low_shelf_filters_[0].
tickBasic(write1, current_low_coefficient);
375 poly_float low_filtered2 = low_shelf_filters_[1].
tickBasic(write2, current_low_coefficient);
376 poly_float low_filtered3 = low_shelf_filters_[2].
tickBasic(write3, current_low_coefficient);
377 poly_float low_filtered4 = low_shelf_filters_[3].
tickBasic(write4, current_low_coefficient);
378 write1 -= low_filtered1 * current_low_amplitude;
379 write2 -= low_filtered2 * current_low_amplitude;
380 write3 -= low_filtered3 * current_low_amplitude;
381 write4 -= low_filtered4 * current_low_amplitude;
384 current_decay1 += delta_decay1;
385 current_decay2 += delta_decay2;
386 current_decay3 += delta_decay3;
387 current_decay4 += delta_decay4;
396 feedback_lookups1[0][write_index_] = store1[0];
397 feedback_lookups1[1][write_index_] = store1[1];
398 feedback_lookups1[2][write_index_] = store1[2];
399 feedback_lookups1[3][write_index_] = store1[3];
400 feedback_lookups2[0][write_index_] = store2[0];
401 feedback_lookups2[1][write_index_] = store2[1];
402 feedback_lookups2[2][write_index_] = store2[2];
403 feedback_lookups2[3][write_index_] = store2[3];
404 feedback_lookups3[0][write_index_] = store3[0];
405 feedback_lookups3[1][write_index_] = store3[1];
406 feedback_lookups3[2][write_index_] = store3[2];
407 feedback_lookups3[3][write_index_] = store3[3];
408 feedback_lookups4[0][write_index_] = store4[0];
409 feedback_lookups4[1][write_index_] = store4[1];
410 feedback_lookups4[2][write_index_] = store4[2];
411 feedback_lookups4[3][write_index_] = store4[3];
413 write_index_ = (write_index_ + 1) & feedback_mask_;
416 poly_float total_allpass = store1 + store2 + store3 + store4;
419 poly_float feed_forward1 = other_feedback_allpass + store1;
420 poly_float feed_forward2 = other_feedback_allpass + store2;
421 poly_float feed_forward3 = other_feedback_allpass + store3;
422 poly_float feed_forward4 = other_feedback_allpass + store4;
425 poly_float adjacent_feedback_allpass = (store1 + store2 + store3 + store4) * -0.5f;
427 feed_forward1 += adjacent_feedback_allpass[0];
428 feed_forward2 += adjacent_feedback_allpass[1];
429 feed_forward3 += adjacent_feedback_allpass[2];
430 feed_forward4 += adjacent_feedback_allpass[3];
433 poly_float total = write1 + write2 + write3 + write4;
434 total += (feed_forward1 * current_decay1 + feed_forward2 * current_decay2 +
435 feed_forward3 * current_decay3 + feed_forward4 * current_decay4) * 0.125f;
438 audio_out[i] = current_wet * memory_->get(current_sample_delay) + current_dry *
input;
441 current_delay_increment += delta_delay_increment;
442 current_sample_delay += current_delay_increment;
446 current_dry += delta_dry;
447 current_wet += delta_wet;
448 current_high_coefficient += delta_high_coefficient;
449 current_high_amplitude += delta_high_amplitude;
453 sample_delay_increment_ = current_delay_increment;
454 sample_delay_ = current_sample_delay;