614
void scanner_vibrato::reset()
617
for (int i = 0; i < ScannerSize; i++)
622
void scanner_vibrato::process(organ_parameters *parameters, float (*data)[2], unsigned int len, float sample_rate)
627
int vtype = (int)parameters->lfo_type;
628
if (!vtype || vtype > organ_enums::lfotype_cvfull)
630
legacy.process(parameters, data, len, sample_rate);
634
// I bet the original components of the line box had some tolerance,
635
// hence two different values of cutoff frequency
636
scanner[0].set_lp_rbj(4000, 0.707, sample_rate);
637
scanner[1].set_lp_rbj(4200, 0.707, sample_rate);
638
for (int t = 2; t < ScannerSize; t ++)
640
scanner[t].copy_coeffs(scanner[t & 1]);
643
float lfo_phase2 = lfo_phase + parameters->lfo_phase * (1.0 / 360.0);
644
if (lfo_phase2 >= 1.0)
646
float vib_wet = parameters->lfo_wet;
647
float dphase = parameters->lfo_rate / sample_rate;
648
static const int v1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 8 };
649
static const int v2[] = { 0, 1, 2, 4, 6, 8, 9, 10, 12 };
650
static const int v3[] = { 0, 1, 3, 6, 11, 12, 15, 17, 18, 18, 18 };
651
static const int vfull[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 18 };
652
static const int *vtypes[] = { NULL, v1, v2, v3, vfull };
653
const int *vib = vtypes[vtype];
655
float vibamt = 8 * parameters->lfo_amt;
656
if (vtype == organ_enums::lfotype_cvfull)
657
vibamt = 17 * parameters->lfo_amt;
658
for (unsigned int i = 0; i < len; i++)
660
float line[ScannerSize + 1];
661
float v0 = (data[i][0] + data[i][1]) * 0.5;
664
for (int t = 0; t < ScannerSize; t++)
665
line[t + 1] = scanner[t].process(line[t]) * 1.03;
667
float lfo1 = lfo_phase < 0.5 ? 2 * lfo_phase : 2 - 2 * lfo_phase;
668
float lfo2 = lfo_phase2 < 0.5 ? 2 * lfo_phase2 : 2 - 2 * lfo_phase2;
670
float pos = vibamt * lfo1;
672
float vl = lerp(line[vib[ipos]], line[vib[ipos + 1]], pos - ipos);
676
float vr = lerp(line[vib[ipos]], line[vib[ipos + 1]], pos - ipos);
679
if (lfo_phase >= 1.0)
681
lfo_phase2 += dphase;
682
if (lfo_phase2 >= 1.0)
685
data[i][0] += (vl - v0) * vib_wet;
686
data[i][1] += (vr - v0) * vib_wet;
688
for (int t = 0; t < ScannerSize; t++)
690
scanner[t].sanitize();
614
693
//////////////////////////////////////////////////////////////////////////////////////////////////////
616
695
void organ_voice::update_pitch()