int32.positive step select
int32.positive length of the pattern
bool32 default value to chain objects
frac32.positive percent of active notes
int32.positive chain output
bool32 bool out
bool sequence[128];
int notes = ___SMMUL(inlet_length << 5, __USAT(inlet_notes, 27));
int rests = inlet_length - notes;
int length = __USAT(inlet_length, 7);
outlet_chain = inlet_in - length;
if (rests) {
if (notes < rests) {
int mul = rests / notes;
int rem = rests - (mul * notes);
int ii = 0;
int temp;
for (int i = 0; i < notes; i += 1) {
if (i < rem) {
temp = ii;
sequence[ii] = 1;
for (ii = temp + 1; ii < temp + mul + 2; ii += 1)
sequence[ii] = 0;
} else {
temp = ii;
sequence[ii] = 1;
for (ii = temp + 1; ii < temp + mul + 1; ii += 1)
sequence[ii] = 0;
}
}
} else if (notes > rests) {
int mul = notes / rests;
int rem = notes - (mul * rests);
int ii = 0;
int temp;
for (int i = 0; i < rests; i += 1) {
if (i < rem) {
sequence[ii] = 1;
ii += 1;
sequence[ii] = 0;
temp = ii;
for (ii = temp + 1; ii < temp + mul + 1; ii += 1)
sequence[ii] = 1;
} else {
sequence[ii] = 1;
ii += 1;
sequence[ii] = 0;
temp = ii;
for (ii = temp + 1; ii < temp + mul; ii += 1)
sequence[ii] = 1;
}
}
} else {
sequence[0] = 1;
for (int i = 1; i < length; i += 1)
sequence[i] = !sequence[i - 1];
}
} else {
for (int ii = 0; ii < length; ii += 1)
sequence[ii] = 1;
}
if (inlet_in >= 0 && inlet_in < length)
outlet_out = sequence[inlet_in];
else
outlet_out = inlet_default;