GoldRat

Golden Ratio calculator Set the total size with the "size" parameter the outputs will give the size of each next golden division of the smallest part of the previous division The buttons "next" and "prev" can be used to get to even smaller divisions based on the current size. Next will take the next smaller division and resets the control to the next smaller division Prev will take the current size and multiplies it with the golden ratio+1
Author: Remco van der Most
License: BSD
Github: sss/math/GoldRat.axo

Inlets

frac32 in

Outlets

frac32 b1

frac32 s1

frac32 b2

frac32 s2

frac32 b3

frac32 s3

frac32 b4

frac32 s4

frac32 b5

frac32 s5

frac32 b6

frac32 s6

frac32 b7

frac32 s7

frac32 b8

frac32 s8

Parameters

frac32.u.map size

bool32.mom next

bool32.mom prev

Declaration
float32_t Gratio1 = 1.61803398875;
float32_t Gratio2 = 2.61803398875;
int32_t ratioB[8];
int32_t ratioS[8];
int i;
int ntrig;
int ptrig;
Control Rate
if ((param_next > 0) && !ntrig) {
  ntrig = 1;
  PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_size],
                     ratioS[0], 0xFFFD);
} else if (param_next == 0) {
  ntrig = 0;
}

if ((param_prev > 0) && !ptrig) {
  ptrig = 1;
  PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_size],
                     param_size * Gratio2, 0xFFFD);
} else if (param_prev == 0) {
  ptrig = 0;
}

ratioS[0] = ((float32_t)(param_size)) / Gratio2;
ratioB[0] = ratioS[0] * Gratio1;

for (i = 0; i < 7; i++) {
  ratioS[i + 1] = ratioS[i] / Gratio2;
  ratioB[i + 1] = ratioS[i] - ratioS[i + 1];
}

outlet_b1 = ratioB[0];
outlet_s1 = ratioS[0];
outlet_b2 = ratioB[1];
outlet_s2 = ratioS[1];
outlet_b3 = ratioB[2];
outlet_s3 = ratioS[2];
outlet_b4 = ratioB[3];
outlet_s4 = ratioS[3];
outlet_b5 = ratioB[4];
outlet_s5 = ratioS[4];
outlet_b6 = ratioB[5];
outlet_s6 = ratioS[5];
outlet_b7 = ratioB[6];
outlet_s7 = ratioS[6];
outlet_b8 = ratioB[7];
outlet_s8 = ratioS[7];

Privacy

© 2024 Zrna Research