cc_thin_var

Variable rate MIDI CC data output.
Author: Are Leistad
License: BSD
Github: drj/midi/cc_thin_var.axo

Inlets

frac32.positive value

Outlets

None

Parameters

int32 Maximum rate in CCs per second

Attributes

combo txdevice

spinner txchannel

spinner cc

Declaration
int32_t timer;
int32_t period;
int32_t last_param_maxrate;
int32_t last_inlet_v;
Init
timer = 0;
period = 3000;
last_param_maxrate = 1;
last_inlet_v = 0;
Control Rate
if (timer > period && (inlet_v & 0xFFF00000) != last_inlet_v) {
  if (param_maxrate != last_param_maxrate) {
    period = 3000 / param_maxrate;
    last_param_maxrate = param_maxrate;
  }

  MidiSend3((midi_device_t)attr_txdevice,
            MIDI_CONTROL_CHANGE + (attr_txchannel - 1), attr_cc,
            __USAT(inlet_v >> 20, 7));
  last_inlet_v = inlet_v & 0xFFF00000;
  timer = 0;
}

timer++;

Privacy

© 2024 Zrna Research