ar

Attack/release envelope for a amplitude table (with 128 32bit elements). Does not alter the referenced table, but this object can be referenced as amplitude table.
Author: Johannes Taelman
License: BSD
Github: jt/env/table/ar.axo

Inlets

None

Outlets

None

Parameters

frac32.s.map.kdecaytime.exp attack

frac32.s.map.kdecaytime.exp release

Attributes

objref amplitude table

Declaration
static const uint32_t LENGTHPOW = 7;
static const uint32_t LENGTH = 1 << LENGTHPOW;
static const uint32_t LENGTHMASK = (1 << LENGTHPOW) - 1;
static const uint32_t BITS = 32;
static const uint32_t GAIN = 0;

int32_t array[LENGTH];
Init
int i;
for (i = 0; i < LENGTH; i++) {
  array[i] = 0;
}
Control Rate
int pa = 0x80000000 - param_attack;
int pr = 0x80000000 - param_release;
pa = pa << 2;
pr = pr << 2;

int32_t *pIn = &attr_input.array[0];
int32_t *pOut = &array[0];
int i;
for (i = 0; i < LENGTH; i += 2) {
  // registers:
  //   in1, in2
  //   out1, out2
  //   pa, pr
  //   pIn, pOut
  //   i
  // d1/d2
  int32_t in1 = *pIn++;
  int32_t in2 = *pIn++;
  int32_t out1 = *pOut++;
  int32_t out2 = *pOut--;

  int32_t d1 = in1 - out1;

  if (d1 > 0)
    out1 = __SMMLA(d1, pa, out1);
  else
    out1 = __SMMLA(d1, pr, out1);

  int32_t d2 = in2 - out2;
  if (d2 > 0)
    out2 = __SMMLA(d2, pa, out2);
  else
    out2 = __SMMLA(d2, pr, out2);

  *pOut++ = out1;
  *pOut++ = out2;
}

Privacy

© 2024 Zrna Research