midichordIN

Receives 3 notes (triad) with pitchbend offset. To be used with the pythagorean tonnetz sequencer and "midichordOUT" modules. This way the frequencies being generated by the tonnetz sequencer can also be send to external boards. This module outputs note-values instead of the frequency input values of the "midichordOUT" module.
Author: Remco van der Most
License: BSD
Github: sss/midi/midichordIN.axo

Inlets

None

Outlets

frac32 n1

frac32 n2

frac32 n3

Parameters

bool32.tgl singleOctave

Attributes

spinner ccl

spinner channel

Declaration
int32_t note[3];
int32_t bend[3];
int cnt;
int32_t bendl;
bool ntrig;
bool singleOct;
Init
cnt = 2;
bendl = 0;
for (int i = 0; i < 3; i++) {
  note[i] = 0;
  bend[i] = 0;
}
Control Rate
outlet_n1 = note[0] + (bend[0] >> 7);
outlet_n2 = note[1] + (bend[1] >> 7);
outlet_n3 = note[2] + (bend[2] >> 7);
singleOct = param_singleOctave;
Midi Handler
if ((status == MIDI_NOTE_ON + attr_channel - 1) && data2) {
  cnt += 1;
  cnt = cnt > 2 ? 0 : cnt;

  note[cnt] = data1 - 64;
  if (singleOct > 0) {
    note[cnt] = note[cnt] - note[cnt] / 12 * 12 + (note[cnt] < 0 ? 12 : 0);
  }
  note[cnt] = note[cnt] << 21;
}

if (status == MIDI_PITCH_BEND + attr_channel - 1) {
  bend[cnt] = (((int)((data2 << 7) + data1) - 0x2000) << 14) + bendl;
  ntrig = 0;
} else if ((status == attr_channel - 1 + MIDI_CONTROL_CHANGE) &&
           (data1 == attr_ccl)) {
  bendl = data2 << 7;
}

Privacy

© 2024 Zrna Research