seg16disc3

Author: Smashed Transistors
License: LGPL
Github: tiar/kfunc/seg16disc3.axo

Inlets

frac32 in

frac32 offset

Outlets

frac32 outA

frac32 outB

frac32 outC

Attributes

text valuesA

text valuesB

text valuesC

Declaration
float Avf[32] = {attr_valuesA};
float Bvf[32] = {attr_valuesB};
float Cvf[32] = {attr_valuesC};
int32_t *Av = (int32_t *)Avf;
int32_t *Bv = (int32_t *)Bvf;
int32_t *Cv = (int32_t *)Cvf;
Init
for (int i = 0; i < 32; i += 2) {
  Av[i + 1] = arm::float_to_q(Avf[i + 1] - Avf[i], 22); // dv q28
  Av[i] = arm::float_to_q(Avf[i], 21);                  // v q27
  Bv[i + 1] = arm::float_to_q(Bvf[i + 1] - Bvf[i], 22); // dv q28
  Bv[i] = arm::float_to_q(Bvf[i], 21);                  // v q27
  Cv[i + 1] = arm::float_to_q(Cvf[i + 1] - Cvf[i], 22); // dv q28
  Cv[i] = arm::float_to_q(Cvf[i], 21);                  // v q27
}
Control Rate
int32_t in = (inlet_in + inlet_offset) & 0x07FFFFFF;
//                 q23->q31        remove sign
int32_t a = (in << (31 - (27 - 4))) & 0x7FFFFFFF; // q31
int i = in >> (27 - 4);                           //[0..15]
i <<= 1;                                          //[0..30] by 2 step
//                       q28   q31  q27
outlet_outA = ___SMMLA(Av[i + 1], a, Av[i]);
outlet_outB = ___SMMLA(Bv[i + 1], a, Bv[i]);
outlet_outC = ___SMMLA(Cv[i + 1], a, Cv[i]);

Privacy

© 2024 Zrna Research