matrixscalerswitch

matrix scaler
Author:
License:
Github: phi/harmony/matrixscalerswitch.axo

Inlets

int32.positive select

int32.bipolar seq

int32.bipolar octave

int32.bipolar keyafter

int32.bipolar transafter

Outlets

int32.bipolar o

Parameters

bool32.tgl in

bool32.tgl seq

bool32.tgl oct

bool32.tgl on

int32 transpose

int32.hradio C

int32.hradio Cis

int32.hradio D

int32.hradio Dis

int32.hradio E

int32.hradio F

int32.hradio Fis

int32.hradio G

int32.hradio Gis

int32.hradio A

int32.hradio Ais

int32.hradio B

Declaration
int32_t val;
int ins;
int rem;
int oct;
int scl;
Init
val = (int32_t)(GenerateRandomNumber()) >> 4;
ins = 0;
rem = 0;
oct = 0;
scl = 0;
Control Rate
ins = ((param_seq) ? inlet_seq * 0.094 : 0) + ((param_oct) ? inlet_octave : 0) +
      ((param_in) ? inlet_in : 0);
int r;
if (ins >= 0)
  r = ((unsigned int)ins) / 12;
else
  r = -(((unsigned int)(12 - ins)) / 12);
rem = ins - (r * 12);
oct = ((r * 12) - 4);

switch (rem > 0 ? rem : 0) {
case 0:
  scl = (param_C) + oct;
  break;
case 1:
  scl = (param_Cis) + oct;
  break;
case 2:
  scl = (param_D) + oct;
  break;
case 3:
  scl = (param_Dis) + oct;
  break;
case 4:
  scl = (param_E) + oct;
  break;
case 5:
  scl = (param_F) + oct;
  break;
case 6:
  scl = (param_Fis) + oct;
  break;
case 7:
  scl = (param_G) + oct;
  break;
case 8:
  scl = (param_Gis) + oct;
  break;
case 9:
  scl = (param_A) + oct;
  break;
case 10:
  scl = (param_Ais) + oct;
  break;
case 11:
  scl = (param_B) + oct;
  break;
default:
  scl = (param_C) + oct;
  break;
}
outlet_o =
    param_on
        ? (scl + (param_transpose - 12) + inlet_keyafter + inlet_transafter)
        : (ins + param_transpose + inlet_keyafter + inlet_transafter);

Privacy

© 2024 Zrna Research