oldFloat

A quantifier that simulates old float formats with limited accuracy as found on early digital synthesizers.
Author: Smashed Transistors
License: LGPL
Github: tiar/kfunc/oldFloat k.axo

Inlets

frac32 in

Outlets

frac32 out

Attributes

combo resolution

Control Rate
// __CLZ counts leading zeros
int32_t offset = 32 - __CLZ(abs(inlet_in)) - attr_resolution;
if (offset <= 0) {
  outlet_out = inlet_in;
} else {
  // erases some low bits depending of leading zeros and resolution
  outlet_out = (inlet_in >> offset) << offset;
}
/*
union Y { float f; int32_t i; } y;
y.f = arm::q_to_float(inlet_in, 27);
#if attr_resolution == 5
y.i &= 0xFFFF8000;
#elif attr_resolution == 6
y.i &= 0xFFFFC000;
#elif attr_resolution == 7
y.i &= 0xFFFFE000;
#elif attr_resolution == 8
y.i &= 0xFFFFF000;
#elif attr_resolution == 3
y.i &= 0xFFFE0000;
#else
y.i &= 0xFFFF0000;
#endif
outlet_out=arm::float_to_q(y.f, 27);
*/

Privacy

© 2024 Zrna Research