leadTuner

Module to produce chord-progressions along side of the bass and melody. Bass and melody have their own inputs to select the arpeggio-note. Uses only notes for the selected chord and raises an octave when the arpeggio goes above 3, 7, 11 etc. Octaves are wrapped by the ArpMax and BassMax parameters. -key sets the key of the scale (major/minor scale) -when minor-input goes high, scale turns into minor -select sets the root note (selected from scaled notes) from where the chord is build up -chordOct offsets the chord in octaves -chordmode selects between 20 different chords, which are different combinations of the 7 available notes in the scale. -inverse is a bit-wise control of octave-offsets for the 4 notes of the chord, offsetting different combinations up to several octaves. Max is 511 different inverse operations
Author: Remco van der Most
License: BSD
Github: sss/harmony/leadTuner.axo

Inlets

int32 select

int32 key

int32 chordOct

int32 chordmode

int32 inverse

int32 bass

int32 arp

bool32 minor

Outlets

int32 chord1

int32 chord2

int32 chord3

int32 chord4

int32 bass

int32 arp

Parameters

int32 chordOct

int32 stepchord

int32 chordmode

int32 stepmode

int32 bassOct

int32 BassMax

int32 arpOct

int32 ArpMax

frac32.u.map inverse

bool32.tgl sel

Declaration
int note[14] = {0, 2, 4, 5, 7, 9, 11, 0, 2, 3, 5, 7, 8, 10};
int i;
int nt[8];
int32_t select[4];
int offset[60] = {2, 4, 6, 2, 4, 5, 1, 3, 6, 2, 3, 6, 2, 3, 5, 3, 4, 6, 1, 3,
                  5, 1, 4, 6, 1, 3, 4, 1, 4, 5, 1, 2, 5, 1, 2, 4, 1, 5, 6, 2,
                  5, 6, 2, 3, 4, 1, 2, 3, 3, 4, 5, 3, 5, 6, 4, 5, 6, 1, 2, 6};
Control Rate
int chordmode = (param_chordmode + inlet_chordmode) * param_stepmode;
chordmode = chordmode - (chordmode / 20) * 20;

select[0] = (inlet_select * param_stepchord + (inlet_select >> 2));
select[1] = (inlet_select * param_stepchord + (inlet_select >> 2)) +
            offset[chordmode * 3];
select[2] = (inlet_select * param_stepchord + (inlet_select >> 2)) +
            offset[chordmode * 3 + 1];
select[3] = (inlet_select * param_stepchord + (inlet_select >> 2)) +
            offset[chordmode * 3 + 2];

for (i = 0; i < 4; i++) {
  select[i] = select[i] - (select[i] / 7) * 7;
  nt[i] = note[select[i] + inlet_minor * 7] - inlet_minor * 3;
}

int32_t inverse = (inlet_inverse + (param_inverse >> 19));

nt[0] = nt[0] + (inverse & 1 ? 12 : 0);
nt[1] = nt[1] + (inverse & 3 ? 12 : 0);
nt[2] = nt[2] + (inverse & 7 ? 12 : 0);
nt[3] = nt[3] + (inverse & 15 ? 12 : 0);
nt[0] = nt[0] + (inverse & 31 ? +24 : 0);
nt[1] = nt[1] + (inverse & 63 ? +24 : 0);
nt[2] = nt[2] + (inverse & 127 ? +24 : 0);
nt[3] = nt[3] + (inverse & 255 ? +24 : 0);

int key = inlet_key * 7 - (inlet_key * 7 / 12) * 12;
key = key > 0 ? key : key + 12;

int ns = nt[0];
ns = ns - (ns / 12) * 12;
ns = ns > 0 ? ns : ns + 12;

int arp = inlet_arp + select[0];
arp = arp > 0 ? arp : -arp;
int arpOct = arp / 7;
arp = arp - arpOct * 7;
arpOct = arpOct - (arpOct / param_ArpMax) * param_ArpMax;

int bass = inlet_bass / 12;
bass = bass - (bass / param_BassMax) * param_BassMax;
bass = bass > 0 ? bass : bass + param_BassMax;
bass += param_bassOct;

int chordoctave = (inlet_chordOct + param_chordOct) * 12 + key;
outlet_chord1 = nt[0] + chordoctave;
outlet_chord2 = nt[1] + chordoctave;
outlet_chord3 = nt[2] + chordoctave;
outlet_chord4 = nt[3] + chordoctave;
int br = nt[(inlet_bass + select[0]) & 3] -
         (nt[(inlet_bass + select[0]) & 3] / 12) * 12;

br = br > 0 ? br : br + 12;
outlet_bass = br + key + bass * 12;
if (param_sel) {
  outlet_arp = note[arp + inlet_minor * 7] + (arpOct + param_arpOct) * 12 +
               key - inlet_minor * 3;
} else {
  int nr = nt[arp & 3] - (nt[arp & 3] / 12) * 12;
  nr = nr > 0 ? nr : nr + 12;
  outlet_arp = nr + (arpOct + param_arpOct) * 12 + key;
}

Privacy

© 2024 Zrna Research