chorder

Stores 8 chords in memory. Maximum chord size: 8 notes (lower notes have higher priority). Inlets: pitch -> the base pitch on which the selected chord is constructed sel -> chord selector (input must go from 0 to 7, otherwise nothing will be outputted. enable -> acts like a master note on. If not enabled all output triggers are set to 0. If enabled, the triggers corresponding to active notes will output 1. Outlets: p1, p2, .. p8 -> output the pitch cv for the corresponding note. Only active notes will be changed, the others will remain to the previous state. t1, t2, .. t8 -> output the trigger value for the corresponding note. If the note is active output=1, if inactive output=0 Parameters: chord1, chord2, .... chord8 -> allow to edit individual notes per chord and chord parameters: [1][2][3][4][5][6][7][8][9][10][11][12] correspond to semitones. If, for example you want to build a major chord on the root note, you'll have to check 1,4 and 7. If you want to build a sus2 chord 1,3 and 7. You can figure out the rest. [13] shifts active odd outlets (1, 3, 5, 7) up by one octave [14] shifts active even outlets (1, 3, 5, 7) up by one octave [15] shifts odd notes (1, 3, 5, 7, 9, 11) up by one octave [16] shifts even notes (2, 4, 6, 8, 10, 12) up by one octave
Author: Sputnki
License: BSD
Github: sptnk/sequencer/chorder.axo

Inlets

frac32.bipolar pitch input

int32 sel

bool32 enable

Outlets

frac32 p1

frac32 p2

frac32 p3

frac32 p4

frac32 p5

frac32 p6

frac32 p7

frac32 p8

bool32 t1

bool32 t2

bool32 t3

bool32 t4

bool32 t5

bool32 t6

bool32 t7

bool32 t8

Parameters

bin16 chord1

bin16 chord2

bin16 chord3

bin16 chord4

bin16 chord5

bin16 chord6

bin16 chord7

bin16 chord8

Declaration
int32_t PARAMETER;

int32_t pitch_out[8];
bool trig_out[8];

int shift_even;
int shift_odd;

int shift_even2;
int shift_odd2;
Init
for (int ii = 0; ii < 8; ii += 1) {
  pitch_out[ii] = 0;
  trig_out[ii] = 0;
}
Control Rate
switch (inlet_sel) {

case 0:
  PARAMETER = param_chord1;
  break;
case 1:
  PARAMETER = param_chord2;
  break;
case 2:
  PARAMETER = param_chord3;
  break;
case 3:
  PARAMETER = param_chord4;
  break;
case 4:
  PARAMETER = param_chord5;
  break;
case 5:
  PARAMETER = param_chord6;
  break;
case 6:
  PARAMETER = param_chord7;
  break;
case 7:
  PARAMETER = param_chord8;
  break;
default:
  PARAMETER = 0;
}

if (PARAMETER &
    (1 << 14)) // shift all odd pitches (I, III, V, VII, IX) by 12 semitones
  shift_odd = 12;
else
  shift_odd = 0;

if (PARAMETER &
    (1 << 15)) // shift all even pitches (II, IV, VI, VIII, X) by 12 semitones
  shift_even = 12;
else
  shift_even = 0;

if (PARAMETER &
    (1 << 12)) // shift all odd pitches (I, III, V, VII, IX) by 12 semitones
  shift_odd2 = 12 << 21;
else
  shift_odd2 = 0;

if (PARAMETER &
    (1 << 13)) // shift all even pitches (II, IV, VI, VIII, X) by 12 semitones
  shift_even2 = 12 << 21;
else
  shift_even2 = 0;

int outc = 0;
bool outb = 1; // start from odd

for (int ii = 0; ii < 6; ii += 1) {
  if (PARAMETER & (1 << (2 * ii)) && outc < 8) {
    pitch_out[outc] = inlet_pitch + ((2 * ii + shift_odd) << 21);
    trig_out[outc] = 1;

    if (outb)
      pitch_out[outc] += shift_odd2;
    else
      pitch_out[outc] += shift_even2;

    outc += 1;
    outb = !outb;
  }

  if (PARAMETER & (1 << (2 * ii + 1)) && outc < 8) {
    pitch_out[outc] = inlet_pitch + ((2 * ii + 1 + shift_even) << 21);
    trig_out[outc] = 1;

    if (outb)
      pitch_out[outc] += shift_odd2;
    else
      pitch_out[outc] += shift_even2;

    outc += 1;
    outb = !outb;
  }
}

while (outc < 8) {
  trig_out[outc] = 0;
  outc += 1;
}

outlet_p1 = pitch_out[0];
outlet_p2 = pitch_out[1];
outlet_p3 = pitch_out[2];
outlet_p4 = pitch_out[3];
outlet_p5 = pitch_out[4];
outlet_p6 = pitch_out[5];
outlet_p7 = pitch_out[6];
outlet_p8 = pitch_out[7];

if (inlet_enable) {

  outlet_t1 = trig_out[0];
  outlet_t2 = trig_out[1];
  outlet_t3 = trig_out[2];
  outlet_t4 = trig_out[3];
  outlet_t5 = trig_out[4];
  outlet_t6 = trig_out[5];
  outlet_t7 = trig_out[6];
  outlet_t8 = trig_out[7];
} else {

  outlet_t1 = 0;
  outlet_t2 = 0;
  outlet_t3 = 0;
  outlet_t4 = 0;
  outlet_t5 = 0;
  outlet_t6 = 0;
  outlet_t7 = 0;
  outlet_t8 = 0;
}

Privacy

© 2024 Zrna Research