zoomknob

bipolar constant value dial with zoom function 0=no zoom 1= 2^8 zoom 2= 2^16 zoom don't forget to zoom out before ending patch or you'll loose your value!
Author: Remco van der Most
License: BSD
Github: sss/ctrl/zoomknob.axo

Inlets

int32 zoom

Outlets

frac32.bipolar output

Parameters

frac32.s.map value

int32.hradio zoom

Declaration
int32_t value;
int32_t mem1;
int32_t mem2;
int ttrig;
int strig;
int reset;
Init
strig = 1;
reset = 1;
Control Rate
// when either parameter or inlet zoom is 2, sets "zoom" to 2
int32_t zoom = (inlet_zoom) + (param_zoom);

// when zoom goes 2 while it was off at the former sample, puts parameter value
// into memory1 and resets parameter to zero
if ((zoom > 0) && (!(ttrig))) {
  ttrig = 1;
  mem1 = param_value;
  PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_value], 0,
                     0xFFFD);
}
// when zoom goes "not 2" while it was on at the former sample, sums the two
// memories and resets the parameter to the sum
if ((!(zoom > 0)) && (!(strig))) {
  strig = 1;
  PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_value],
                     mem1 + mem2, 0xFFFD);
}
// when zoom is not 2, puts parameter into "value" (also includes updated offset
// when going out of zoom)
if (!(zoom > 0)) {
  ttrig = 0;
  value = param_value;
}
// when zoom is 1 or 2, scales down parameter, puts it in memory2 and sums it
// with memory1 into "value"

if (zoom == 1) {
  strig = 0;
  mem2 = param_value >> 8;
  value = mem1 + mem2;
}

if (zoom == 2) {
  strig = 0;
  mem2 = param_value >> 16;
  value = mem1 + mem2;
}

// puts "value" into outlet
outlet_out = value;

Privacy

© 2024 Zrna Research