arcsinh_t

allocate 16bit table with hyperbolic arcsine shape in SDRAM memory, -128.00 .. 127.99
Author: Sputnki
License: BSD
Github: sptnk/table/arcsinh_t.axo

Inlets

None

Outlets

None

Attributes

combo size

spinner value

Declaration
static const uint32_t LENGTHPOW = (attr_size);
static const uint32_t LENGTH = (1 << attr_size);
static const uint32_t LENGTHMASK = ((1 << attr_size) - 1);
static const uint32_t BITS = 16;
static const uint32_t GAIN = 12;
int16_t *array;
Init
static int16_t _array[attr_poly][LENGTH] __attribute__((section(".sdram")));
array = &_array[parent->polyIndex][0];
{
  int i;
  for (i = 0; i < LENGTH; i++)
    array[i] = 0;
}

int i;
double d;
double x;
double range;

float a = -attr_value /
          4; // these two parameters will serve as a range for the function
float b = -a;

for (i = 0; i < LENGTH; i++) {
  x = i;
  x = (x * (b - a) / LENGTH + a); // bonding the domain from [a,b] to [0,length]

  if (x <= -2) {
    x = x + 2.5;
    d = -1.64723 + x / 2.692582404 + (x * x) / 15.61697794 +
        (x * x * x) / 73.8411457 + (x * x * x * x) / 345.6283802 +
        (x * x * x * x * x) / 1797.972408;
  } else if (x >= 2) {
    x = x - 2.5;
    d = 1.64723 + x / 2.692582404 - (x * x) / 15.61697794 +
        (x * x * x) / 73.8411457 - (x * x * x * x) / 345.6283802 +
        (x * x * x * x * x) / 1797.972408;
  } else if ((x <= -1) && (x > -2)) {
    x = x + 1;
    d = -0.8813736 + x / 1.414213 + (x * x) / 5.656854 +
        (x * x * x) / 33.94112 - (x * x * x * x) / 90.50967 -
        (x * x * x * x * x) / 69.6228;
  } else if ((x >= 1) && (x < 2)) {
    x = x - 1;
    d = 0.8813736 + x / 1.414213 - (x * x) / 5.656854 + (x * x * x) / 33.94112 +
        (x * x * x * x) / 90.50967 - (x * x * x * x * x) / 69.6228;
  } else
    d = x - (x * x * x) / 6 + (x * x * x * x * x) * 3 / 40;

  if (i == 0)
    range = -d;
  d = d * 32768 / range; // bonding the codomain
  array[i] = d;
}

Privacy

© 2024 Zrna Research