analyzer 24

spectral analyzer made out of two 2nd order bandpass filters per band, decibel scale (vertical), steeper filters
Author: Johannes Taelman
License: BSD
Github: spectral/analyzer 24.axo

Inlets

frac32buffer input

Outlets

None

Displays

frac32.vbar.db v0

frac32.vbar.db v1

frac32.vbar.db v2

frac32.vbar.db v3

frac32.vbar.db v4

frac32.vbar.db v5

frac32.vbar.db v6

frac32.vbar.db v7

frac32.vbar.db v8

frac32.vbar.db v9

frac32.vbar.db v10

frac32.vbar.db v11

frac32.vbar.db v12

frac32.vbar.db v13

frac32.vbar.db v14

frac32.vbar.db v15

frac32.vbar.db v16

frac32.vbar.db v17

frac32.vbar.db v18

frac32.vbar.db v19

vscale

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;
  disp_v0 = 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;
  disp_v1 = 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;
  disp_v2 = 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;
  disp_v3 = 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;
  disp_v4 = 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;
  disp_v5 = 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;
  disp_v6 = 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;
  disp_v7 = 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;
  disp_v8 = 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;
  disp_v9 = 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;
  disp_v10 = 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;
  disp_v11 = 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;
  disp_v12 = 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;
  disp_v13 = 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;
  disp_v14 = 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;
  disp_v15 = 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;
  disp_v16 = 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;
  disp_v17 = 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;
  disp_v18 = 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;
  disp_v19 = val[19];
}

Privacy

© 2024 Zrna Research