CCzoom

Receives Midi Continuous Controller messages Has a CC-entry for setting a "zoom" function. This bitshifts the incoming midiCC and only updates the part of the internal value that fits the zoom-bit-depth. This allows for a "universal zoom setting", so every parameter can be controlled up to the tiniest precision.
Author: Remco van der Most
License: BSD
Github: sss/midi/CCzoom.axo

Inlets

None

Outlets

frac32.positive midi CC 0-63.5

bool32.pulse trigger output

Attributes

spinner cc

spinner default

spinner zoomcc

Declaration
int32_t ccv;
int32_t ntrig;
int zoom;
int32_t vi27 = (1 << 27) - 1;
Init
ccv = attr_default << 20;
zoom = 0;
Control Rate
outlet_midiCC = ccv;
outlet_trig = ntrig;
ntrig = 0;
Midi Handler
if ((status == attr_midichannel + MIDI_CONTROL_CHANGE) && (data1 == attr_cc)) {
  int32_t tmp1 = ((ccv << zoom + 8) & vi27) >> zoom + 8;
  int32_t tmp2 = (ccv >> 27 - zoom) << 27 - zoom;
  ccv = tmp1 + (data2 << 20 - zoom) + tmp2;
  ntrig = 1;
}
if ((status == attr_midichannel + MIDI_CONTROL_CHANGE) &&
    (data1 == attr_zoomcc)) {
  zoom = data2 >> 3;
  ntrig = 1;
}

Privacy

© 2024 Zrna Research