vocoderFollow

spectral analyzer turned into 20-band peakfollower with outputs for each band
Author: Remco van der Most
License: BSD
Github: sss/fx/vocoderFollow.axo

Inlets

frac32buffer input

Outlets

frac32 out01

frac32 out02

frac32 out03

frac32 out04

frac32 out05

frac32 out06

frac32 out07

frac32 out08

frac32 out09

frac32 out10

frac32 out11

frac32 out12

frac32 out13

frac32 out14

frac32 out15

frac32 out16

frac32 out17

frac32 out18

frac32 out19

frac32 out20

Declaration
biquad_state bs1[20];
biquad_state bs2[20];
biquad_coefficients bc1[20];
biquad_coefficients bc2[20];
int32_t val[20];
Init
int i;
for (i = 0; i < 20; i++) {
  int32_t pitch = (-20 + (i * 4)) << 21;
  int32_t freq;
  MTOF(pitch, freq);
  biquad_bp_coefs(&bc1[i], freq, INT_MAX - ((56 << 21) << 4));
  biquad_clearstate(&bs1[i]);
  int32_t pitch2 = pitch + (2 << 21);
  int32_t freq2;
  MTOF(pitch2, freq2);
  biquad_bp_coefs(&bc2[i], freq2, INT_MAX - ((56 << 21) << 4));
  biquad_clearstate(&bs2[i]);
}
Control Rate
{
  int32buffer t1;
  biquad_dsp(&bs1[0], &bc1[0], inlet_in, t1);
  int32buffer t2;
  biquad_dsp(&bs2[0], &bc2[0], t1, t2);
  long int accu = 0;
  int i;
  for (i = 0; i < BUFSIZE; i++)
    accu += (t2[i] > 0 ? t2[i] : -t2[i]) >> 2;
  val[0] -= val[0] >> 6;
  val[0] += accu >> 8;
  outlet_out01 = val[0];
}
{
  int32buffer t1;
  biquad_dsp(&bs1[1], &bc1[1], inlet_in, t1);
  int32buffer t2;
  biquad_dsp(&bs2[1], &bc2[1], t1, t2);
  long int accu = 0;
  int i;
  for (i = 0; i < BUFSIZE; i++)
    accu += (t2[i] > 0 ? t2[i] : -t2[i]) >> 2;
  val[1] -= val[1] >> 6;
  val[1] += accu >> 8;
  outlet_out02 = val[1];
}
{
  int32buffer t1;
  biquad_dsp(&bs1[2], &bc1[2], inlet_in, t1);
  int32buffer t2;
  biquad_dsp(&bs2[2], &bc2[2], t1, t2);
  long int accu = 0;
  int i;
  for (i = 0; i < BUFSIZE; i++)
    accu += (t2[i] > 0 ? t2[i] : -t2[i]) >> 2;
  val[2] -= val[2] >> 6;
  val[2] += accu >> 8;
  outlet_out03 = val[2];
}
{
  int32buffer t1;
  biquad_dsp(&bs1[3], &bc1[3], inlet_in, t1);
  int32buffer t2;
  biquad_dsp(&bs2[3], &bc2[3], t1, t2);
  long int accu = 0;
  int i;
  for (i = 0; i < BUFSIZE; i++)
    accu += (t2[i] > 0 ? t2[i] : -t2[i]) >> 2;
  val[3] -= val[3] >> 6;
  val[3] += accu >> 8;
  outlet_out04 = val[3];
}
{
  int32buffer t1;
  biquad_dsp(&bs1[4], &bc1[4], inlet_in, t1);
  int32buffer t2;
  biquad_dsp(&bs2[4], &bc2[4], t1, t2);
  long int accu = 0;
  int i;
  for (i = 0; i < BUFSIZE; i++)
    accu += (t2[i] > 0 ? t2[i] : -t2[i]) >> 2;
  val[4] -= val[4] >> 6;
  val[4] += accu >> 8;
  outlet_out05 = val[4];
}
{
  int32buffer t1;
  biquad_dsp(&bs1[5], &bc1[5], inlet_in, t1);
  int32buffer t2;
  biquad_dsp(&bs2[5], &bc2[5], t1, t2);
  long int accu = 0;
  int i;
  for (i = 0; i < BUFSIZE; i++)
    accu += (t2[i] > 0 ? t2[i] : -t2[i]) >> 2;
  val[5] -= val[5] >> 6;
  val[5] += accu >> 8;
  outlet_out06 = val[5];
}
{
  int32buffer t1;
  biquad_dsp(&bs1[6], &bc1[6], inlet_in, t1);
  int32buffer t2;
  biquad_dsp(&bs2[6], &bc2[6], t1, t2);
  long int accu = 0;
  int i;
  for (i = 0; i < BUFSIZE; i++)
    accu += (t2[i] > 0 ? t2[i] : -t2[i]) >> 2;
  val[6] -= val[6] >> 6;
  val[6] += accu >> 8;
  outlet_out07 = val[6];
}
{
  int32buffer t1;
  biquad_dsp(&bs1[7], &bc1[7], inlet_in, t1);
  int32buffer t2;
  biquad_dsp(&bs2[7], &bc2[7], t1, t2);
  long int accu = 0;
  int i;
  for (i = 0; i < BUFSIZE; i++)
    accu += (t2[i] > 0 ? t2[i] : -t2[i]) >> 2;
  val[7] -= val[7] >> 6;
  val[7] += accu >> 8;
  outlet_out08 = val[7];
}
{
  int32buffer t1;
  biquad_dsp(&bs1[8], &bc1[8], inlet_in, t1);
  int32buffer t2;
  biquad_dsp(&bs2[8], &bc2[8], t1, t2);
  long int accu = 0;
  int i;
  for (i = 0; i < BUFSIZE; i++)
    accu += (t2[i] > 0 ? t2[i] : -t2[i]) >> 2;
  val[8] -= val[8] >> 6;
  val[8] += accu >> 8;
  outlet_out09 = val[8];
}
{
  int32buffer t1;
  biquad_dsp(&bs1[9], &bc1[9], inlet_in, t1);
  int32buffer t2;
  biquad_dsp(&bs2[9], &bc2[9], t1, t2);
  long int accu = 0;
  int i;
  for (i = 0; i < BUFSIZE; i++)
    accu += (t2[i] > 0 ? t2[i] : -t2[i]) >> 2;
  val[9] -= val[9] >> 6;
  val[9] += accu >> 8;
  outlet_out10 = val[9];
}
{
  int32buffer t1;
  biquad_dsp(&bs1[10], &bc1[10], inlet_in, t1);
  int32buffer t2;
  biquad_dsp(&bs2[10], &bc2[10], t1, t2);
  long int accu = 0;
  int i;
  for (i = 0; i < BUFSIZE; i++)
    accu += (t2[i] > 0 ? t2[i] : -t2[i]) >> 2;
  val[10] -= val[10] >> 6;
  val[10] += accu >> 8;
  outlet_out11 = val[10];
}
{
  int32buffer t1;
  biquad_dsp(&bs1[11], &bc1[11], inlet_in, t1);
  int32buffer t2;
  biquad_dsp(&bs2[11], &bc2[11], t1, t2);
  long int accu = 0;
  int i;
  for (i = 0; i < BUFSIZE; i++)
    accu += (t2[i] > 0 ? t2[i] : -t2[i]) >> 2;
  val[11] -= val[11] >> 6;
  val[11] += accu >> 8;
  outlet_out12 = val[11];
}
{
  int32buffer t1;
  biquad_dsp(&bs1[12], &bc1[12], inlet_in, t1);
  int32buffer t2;
  biquad_dsp(&bs2[12], &bc2[12], t1, t2);
  long int accu = 0;
  int i;
  for (i = 0; i < BUFSIZE; i++)
    accu += (t2[i] > 0 ? t2[i] : -t2[i]) >> 2;
  val[12] -= val[12] >> 6;
  val[12] += accu >> 8;
  outlet_out13 = val[12];
}
{
  int32buffer t1;
  biquad_dsp(&bs1[13], &bc1[13], inlet_in, t1);
  int32buffer t2;
  biquad_dsp(&bs2[13], &bc2[13], t1, t2);
  long int accu = 0;
  int i;
  for (i = 0; i < BUFSIZE; i++)
    accu += (t2[i] > 0 ? t2[i] : -t2[i]) >> 2;
  val[13] -= val[13] >> 6;
  val[13] += accu >> 8;
  outlet_out14 = val[13];
}
{
  int32buffer t1;
  biquad_dsp(&bs1[14], &bc1[14], inlet_in, t1);
  int32buffer t2;
  biquad_dsp(&bs2[14], &bc2[14], t1, t2);
  long int accu = 0;
  int i;
  for (i = 0; i < BUFSIZE; i++)
    accu += (t2[i] > 0 ? t2[i] : -t2[i]) >> 2;
  val[14] -= val[14] >> 6;
  val[14] += accu >> 8;
  outlet_out15 = val[14];
}
{
  int32buffer t1;
  biquad_dsp(&bs1[15], &bc1[15], inlet_in, t1);
  int32buffer t2;
  biquad_dsp(&bs2[15], &bc2[15], t1, t2);
  long int accu = 0;
  int i;
  for (i = 0; i < BUFSIZE; i++)
    accu += (t2[i] > 0 ? t2[i] : -t2[i]) >> 2;
  val[15] -= val[15] >> 6;
  val[15] += accu >> 8;
  outlet_out16 = val[15];
}
{
  int32buffer t1;
  biquad_dsp(&bs1[16], &bc1[16], inlet_in, t1);
  int32buffer t2;
  biquad_dsp(&bs2[16], &bc2[16], t1, t2);
  long int accu = 0;
  int i;
  for (i = 0; i < BUFSIZE; i++)
    accu += (t2[i] > 0 ? t2[i] : -t2[i]) >> 2;
  val[16] -= val[16] >> 6;
  val[16] += accu >> 8;
  outlet_out17 = val[16];
}
{
  int32buffer t1;
  biquad_dsp(&bs1[17], &bc1[17], inlet_in, t1);
  int32buffer t2;
  biquad_dsp(&bs2[17], &bc2[17], t1, t2);
  long int accu = 0;
  int i;
  for (i = 0; i < BUFSIZE; i++)
    accu += (t2[i] > 0 ? t2[i] : -t2[i]) >> 2;
  val[17] -= val[17] >> 6;
  val[17] += accu >> 8;
  outlet_out18 = val[17];
}
{
  int32buffer t1;
  biquad_dsp(&bs1[18], &bc1[18], inlet_in, t1);
  int32buffer t2;
  biquad_dsp(&bs2[18], &bc2[18], t1, t2);
  long int accu = 0;
  int i;
  for (i = 0; i < BUFSIZE; i++)
    accu += (t2[i] > 0 ? t2[i] : -t2[i]) >> 2;
  val[18] -= val[18] >> 6;
  val[18] += accu >> 8;
  outlet_out19 = val[18];
}
{
  int32buffer t1;
  biquad_dsp(&bs1[19], &bc1[19], inlet_in, t1);
  int32buffer t2;
  biquad_dsp(&bs2[19], &bc2[19], t1, t2);
  long int accu = 0;
  int i;
  for (i = 0; i < BUFSIZE; i++)
    accu += (t2[i] > 0 ? t2[i] : -t2[i]) >> 2;
  val[19] -= val[19] >> 6;
  val[19] += accu >> 8;
  outlet_out20 = val[19];
}

Privacy

© 2024 Zrna Research