bendCCtouch

object that records pitch bend, after touch and midi CCs. for use with the midi looper objects. could be used standalone, inlet stepunQCC expects a clock running at 96ppq
Author: Mattilyn Mattroe
License: if you use the object to play a wedding in september you have to come round and fix the dodgy extractor fan in my bathroom. otherwise, do as you will
Github: matroe/midi looper/bendCCtouch.axo

Inlets

int32 stepunQCC

bool32 rec

bool32 play

bool32 reset

bool32 overdub

Outlets

None

Attributes

combo input

combo output

spinner channel

spinner bar

objref table

Declaration
int cc;
int ccv;
int bendA;
int bendB;
int touch;
int prevcc;
int prevccv;
int prevbendA;
int prevbendB;
int prevtouch;
int prevOcc;
int prevOccv;
int prevObendA;
int prevObendB;
int prevOtouch;
int Occ;
int Occv;
int ObendA;
int ObendB;
int Otouch;
int prevstep;
int voice;
int bendvoice;
int play;
int rec;

int resetrig;
Init
voice = ((attr_bar << 9) - ((attr_bar << 9) >> 2));
bendvoice = (voice * 5);
Control Rate
Occ = attr_table.array[inlet_stepunQCC];
Occv = attr_table.array[inlet_stepunQCC + voice];
ObendA = attr_table.array[inlet_stepunQCC + voice + voice];
ObendB = attr_table.array[inlet_stepunQCC + voice + voice + voice];
Otouch = attr_table.array[inlet_stepunQCC + voice + voice + voice + voice];

if (inlet_stepunQCC != prevstep) {
  // play
  if (inlet_play) {
    if (Occv > 0) {
      MidiSend3((midi_device_t)attr_output,
                MIDI_CONTROL_CHANGE + (attr_channel - 1), (Occ - 1),
                (Occv - 1));
    }
    if ((ObendA > 0) || (ObendB > 0)) {
      MidiSend3((midi_device_t)attr_output,
                MIDI_PITCH_BEND + (attr_channel - 1), (ObendA - 1),
                (ObendB - 1));
    }
    if (Otouch > 0) {
      MidiSend2((midi_device_t)attr_output,
                MIDI_CHANNEL_PRESSURE + (attr_channel - 1), (Otouch - 1));
    }
  }

  // record
  if (inlet_rec) {
    attr_table.array[inlet_stepunQCC] = 0;
    attr_table.array[inlet_stepunQCC + voice] = 0;
    attr_table.array[inlet_stepunQCC + voice + voice] = 0;
    attr_table.array[inlet_stepunQCC + voice + voice + voice] = 0;
    attr_table.array[inlet_stepunQCC + voice + voice + voice + voice] = 0;
  }
  // overdub
  if (inlet_rec || inlet_overdub) {

    if (ccv > 0) {
      attr_table.array[inlet_stepunQCC] = cc;
      attr_table.array[inlet_stepunQCC + voice] = ccv;
    }
    if ((bendA > 0) || (bendB > 0)) {
      attr_table.array[inlet_stepunQCC + voice + voice] = bendA;
      attr_table.array[inlet_stepunQCC + voice + voice + voice] = bendB;
    }

    if (touch > 0) {
      attr_table.array[inlet_stepunQCC + voice + voice + voice + voice] = touch;
    }
  }

  cc = 0;
  ccv = 0;
  bendA = 0;
  bendB = 0;
  touch = 0;
  prevstep = inlet_stepunQCC;
}

// reset bend & touch
if (inlet_reset && !resetrig) {
  MidiSend3((midi_device_t)attr_output, MIDI_PITCH_BEND + (attr_channel - 1), 0,
            64);
  MidiSend2((midi_device_t)attr_output,
            MIDI_CHANNEL_PRESSURE + (attr_channel - 1), 0);
  resetrig = 1;
}

if (!inlet_reset) {
  resetrig = 0;
}
Midi Handler
if (attr_input) {

  if (status == MIDI_CONTROL_CHANGE + (attr_channel - 1)) {
    cc = data1 + 1;
    ccv = data2 + 1;
  }

  if (status == MIDI_PITCH_BEND + (attr_channel - 1)) {
    bendA = data1 + 1;
    bendB = data2 + 1;
  }
  if (status == MIDI_CHANNEL_PRESSURE + (attr_channel - 1)) {
    touch = data1 + 1;
  }
}

Privacy

© 2024 Zrna Research