8xSortMidiNotes

8x Midi-note sorting: The value of the note-inputs are cross-compared and determine how the notes are sorted out. The destination determined by the note-inputs are also used to determine the outputs of the gate and velocity values (or any other signal for that matter, what counts is that the N01->N08 inputs determine sorting process!) When a gate input is low, a high value is added to the respective unused note-pitch, to send it to one of the bottom outputs of the list (depending on how many gates are off). The maxNotes output is the sum of all gates. To be used with a counter and multiplexer to set the max range for arpeggiators for example.
Author: Remco van der Most
License: BSD
Github: sss/math/8xSortMidiNotes.axo

Inlets

bool32 G01

bool32 G02

bool32 G03

bool32 G04

bool32 G05

bool32 G06

bool32 G07

bool32 G08

frac32 N01

frac32 N02

frac32 N03

frac32 N04

frac32 N05

frac32 N06

frac32 N07

frac32 N08

frac32 V01

frac32 V02

frac32 V03

frac32 V04

frac32 V05

frac32 V06

frac32 V07

frac32 V08

Outlets

bool32 Go01

bool32 Go02

bool32 Go03

bool32 Go04

bool32 Go05

bool32 Go06

bool32 Go07

bool32 Go08

frac32 No01

frac32 No02

frac32 No03

frac32 No04

frac32 No05

frac32 No06

frac32 No07

frac32 No08

frac32 Vo01

frac32 Vo02

frac32 Vo03

frac32 Vo04

frac32 Vo05

frac32 Vo06

frac32 Vo07

frac32 Vo08

int32 maxNotes

Declaration
int32_t a1;
int32_t b1;
int32_t c1;
int32_t d1;
int32_t e1;
int32_t f1;
int32_t g1;
int32_t h1;

uint8_t a2;
uint8_t b2;
uint8_t c2;
uint8_t d2;
uint8_t e2;
uint8_t f2;
uint8_t g2;
uint8_t h2;
int i;
uint32_t _position[8];
int _gate[8];
uint32_t _velocity[8];
Control Rate
a1 = inlet_N01 + (1 << 27) + (inlet_G01 < 1 ? (1 << 27) : 0);
b1 = inlet_N02 + (1 << 27) + (inlet_G02 < 1 ? (1 << 27) : 0);
c1 = inlet_N03 + (1 << 27) + (inlet_G03 < 1 ? (1 << 27) : 0);
d1 = inlet_N04 + (1 << 27) + (inlet_G04 < 1 ? (1 << 27) : 0);
e1 = inlet_N05 + (1 << 27) + (inlet_G05 < 1 ? (1 << 27) : 0);
f1 = inlet_N06 + (1 << 27) + (inlet_G06 < 1 ? (1 << 27) : 0);
g1 = inlet_N07 + (1 << 27) + (inlet_G07 < 1 ? (1 << 27) : 0);
h1 = inlet_N08 + (1 << 27) + (inlet_G08 < 1 ? (1 << 27) : 0);

a2 = (a1 > b1 ? 1 : 0) + (a1 > c1 ? 1 : 0) + (a1 > d1 ? 1 : 0) +
     (a1 > e1 ? 1 : 0) + (a1 > f1 ? 1 : 0) + (a1 > g1 ? 1 : 0) +
     (a1 > h1 ? 1 : 0);
b2 = (b1 > a1 ? 1 : 0) + (b1 > c1 ? 1 : 0) + (b1 > d1 ? 1 : 0) +
     (b1 > e1 ? 1 : 0) + (b1 > f1 ? 1 : 0) + (b1 > g1 ? 1 : 0) +
     (b1 > h1 ? 1 : 0);
c2 = (c1 > a1 ? 1 : 0) + (c1 > b1 ? 1 : 0) + (c1 > d1 ? 1 : 0) +
     (c1 > e1 ? 1 : 0) + (c1 > f1 ? 1 : 0) + (c1 > g1 ? 1 : 0) +
     (c1 > h1 ? 1 : 0);
d2 = (d1 > a1 ? 1 : 0) + (d1 > b1 ? 1 : 0) + (d1 > c1 ? 1 : 0) +
     (d1 > e1 ? 1 : 0) + (d1 > f1 ? 1 : 0) + (d1 > g1 ? 1 : 0) +
     (d1 > h1 ? 1 : 0);
e2 = (e1 > a1 ? 1 : 0) + (e1 > b1 ? 1 : 0) + (e1 > c1 ? 1 : 0) +
     (e1 > d1 ? 1 : 0) + (e1 > f1 ? 1 : 0) + (e1 > g1 ? 1 : 0) +
     (e1 > h1 ? 1 : 0);
f2 = (f1 > a1 ? 1 : 0) + (f1 > b1 ? 1 : 0) + (f1 > c1 ? 1 : 0) +
     (f1 > d1 ? 1 : 0) + (f1 > e1 ? 1 : 0) + (f1 > g1 ? 1 : 0) +
     (f1 > h1 ? 1 : 0);
g2 = (g1 > a1 ? 1 : 0) + (g1 > b1 ? 1 : 0) + (g1 > c1 ? 1 : 0) +
     (g1 > d1 ? 1 : 0) + (g1 > e1 ? 1 : 0) + (g1 > f1 ? 1 : 0) +
     (g1 > h1 ? 1 : 0);
h2 = (h1 > a1 ? 1 : 0) + (h1 > b1 ? 1 : 0) + (h1 > c1 ? 1 : 0) +
     (h1 > d1 ? 1 : 0) + (h1 > e1 ? 1 : 0) + (h1 > f1 ? 1 : 0) +
     (h1 > g1 ? 1 : 0);

outlet_maxNotes = inlet_G01 + inlet_G02 + inlet_G03 + inlet_G04 + inlet_G05 +
                  inlet_G06 + inlet_G07 + inlet_G08;

_gate[a2] = inlet_G01;
_gate[b2] = inlet_G02;
_gate[c2] = inlet_G03;
_gate[d2] = inlet_G04;
_gate[e2] = inlet_G05;
_gate[f2] = inlet_G06;
_gate[g2] = inlet_G07;
_gate[h2] = inlet_G08;

_position[a2] = inlet_N01;
_position[b2] = inlet_N02;
_position[c2] = inlet_N03;
_position[d2] = inlet_N04;
_position[e2] = inlet_N05;
_position[f2] = inlet_N06;
_position[g2] = inlet_N07;
_position[h2] = inlet_N08;

_velocity[a2] = inlet_V01;
_velocity[b2] = inlet_V02;
_velocity[c2] = inlet_V03;
_velocity[d2] = inlet_V04;
_velocity[e2] = inlet_V05;
_velocity[f2] = inlet_V06;
_velocity[g2] = inlet_V07;
_velocity[h2] = inlet_V08;

outlet_Go01 = _gate[0];
outlet_Go02 = _gate[1];
outlet_Go03 = _gate[2];
outlet_Go04 = _gate[3];
outlet_Go05 = _gate[4];
outlet_Go06 = _gate[5];
outlet_Go07 = _gate[6];
outlet_Go08 = _gate[7];

outlet_No01 = _position[0];
outlet_No02 = _position[1];
outlet_No03 = _position[2];
outlet_No04 = _position[3];
outlet_No05 = _position[4];
outlet_No06 = _position[5];
outlet_No07 = _position[6];
outlet_No08 = _position[7];

outlet_Vo01 = _velocity[0];
outlet_Vo02 = _velocity[1];
outlet_Vo03 = _velocity[2];
outlet_Vo04 = _velocity[3];
outlet_Vo05 = _velocity[4];
outlet_Vo06 = _velocity[5];
outlet_Vo07 = _velocity[6];
outlet_Vo08 = _velocity[7];

Privacy

© 2024 Zrna Research