clkOUT

main midi clock module with song position and several extra boolean triggers to communicate with other axoloti's. Comes with it's own receive module for proper functioning of the midi messages! (clkIN module) reset/random/triggers are send as a single combined midiCC value whenever any one of them go high (each input being one bit) to reduce message count if several get updated at the same time. NOTE! No "off" message will be send as the receiver does this automatically, again, to save message count.
Author: Remco van der Most
License: BSD
Github: sss/midi/clkOUT.axo

Inlets

int32.positive position

bool32.risingfalling start

bool32.risingfalling stop

bool32.risingfalling continue

bool32.risingfalling clock

bool32.risingfalling reset

bool32.risingfalling random

bool32.risingfalling trg1

bool32.risingfalling trg2

bool32.risingfalling trg3

Outlets

int32 position

bool32 active

bool32 clock

bool32 reset

bool32 random

Attributes

spinner CH

spinner CC

combo device

Declaration
int pos, trg, act, ACT, stop, rnd, rst;
Control Rate
int AS = inlet_start || inlet_continue;
if (AS && !act) {
  act = 1;
  ACT = 1;
  if (inlet_start) {
    MidiSend1((midi_device_t)attr_device, MIDI_START);
  } else {
    MidiSend1((midi_device_t)attr_device, MIDI_CONTINUE);
  }
  MidiSend3((midi_device_t)attr_device, MIDI_SONG_POSITION,
            inlet_position & 127, inlet_position >> 7);
  pos = inlet_position;
} else if (!AS) {
  act = 0;
}

if (inlet_stop && !stop) {
  stop = 1;
  ACT = 0;
  MidiSend1((midi_device_t)attr_device, MIDI_STOP);
} else if (!inlet_stop) {
  stop = 0;
}

outlet_active = ACT;
outlet_clock = 0;
if (ACT) {
  if (!(inlet_position == pos)) {
    MidiSend3((midi_device_t)attr_device, MIDI_SONG_POSITION,
              inlet_position & 127, inlet_position >> 7);
  }

  if (inlet_clock && !trg) {
    trg = 1;
    MidiSend1((midi_device_t)attr_device, MIDI_TIMING_CLOCK);
    outlet_clock = 1;
  } else if (!inlet_clock) {
    trg = 0;
  }
}

outlet_reset = 0;
outlet_random = 0;
int RST = inlet_reset + (inlet_random << 1) + (inlet_trg1 << 2) +
          (inlet_trg2 << 3) + (inlet_trg3 << 4);
if ((RST > 0) && !rst) {
  rst = 1;
  if (inlet_reset) {
    outlet_reset = 1;
  }
  if (inlet_random) {
    outlet_random = 1;
  }
  MidiSend3((midi_device_t)attr_device, MIDI_CONTROL_CHANGE + (attr_CH - 1),
            attr_CC, __USAT(RST, 7));
} else if ((RST < 1) && rst) {
  rst = 0;
}

pos = inlet_position;

Privacy

© 2024 Zrna Research