Automating coll to arrange incoming pitches in pitch order

Amit Fernandes's icon

Hello MaxMSPeople,

I'm working on an Up Down arpeggiator using borax, a few instances of coll and a palindrome counter. Essentially the first Coll collects all current pitch and velocities. A separate coll collects the pitches in the order it receives the notes.

I can't figure out how to have the second coll automatically order the pitches from lowest to highest as new notes are played. Playing ascending notes works fine but any subsequent notes breaks the Up-Down pattern. I've been studying the zl family but haven't had an epiphany yet.

Any direction would be much appreciated.

Thanks!

Max Patch
Copy patch and select New From Clipboard in Max.

slo ~|•'s icon

Amit, a "sort -1" message to the coll will sort the data according to the first element, in ascending order. Check out the second tab of the coll help file.

Amit Fernandes's icon

Thanks for the response SLO, the issue with using sort-1 for this arp is that borax auto assigns 'Voice Allocation Numbers' linearly. So playing chords in order from lowest to highest pitch works fine, but then playing notes in any order doesn't work because sort-1 will sort in order of the notes played not the pitch.

This is why I pack the pitch number as the first element in coll. I can then use sort-1 and use the inc/dec messages but for some reason it gets wonky. See the patch below. Am I missing something obvious here? Counter works perfectly and Coll is sorting by pitch correctly but i'm still getting odd patterns instead of the notes ramping up then down in pitch.

Max Patch
Copy patch and select New From Clipboard in Max.

slo ~|•'s icon

If I use your first patch above and use "sort-1, renumber" on the coll PitchOrder the counter then plays the notes entered ascending and descending.

Max Patch
Copy patch and select New From Clipboard in Max.

Amit Fernandes's icon

Try this with the same patch. Play three notes, say C E G, everything fine. Now while their ascending and descending go ahead and play a lower note, say B and/or A.

I really appreciate your eyes and brain on this. I feel like its some small oversight or I have to go about this a completely different way entirely.

slo ~|•'s icon

Well, if I add more notes, then I have to sort and renumber again, but otherwise works as expected.

Amit Fernandes's icon

It's a performance patch for live use so its not quite there for what i'll be using it for. I'll keep plugging away at it. Thanks so much for your help SLO. I'll post if I come up with a solution.

Roman Thilenius's icon

i would do it live, thresh -> zl sort -> and not inside the coll.

Amit Fernandes's icon

Thanks for the direction Roman! Your direction led me to a zlsort -> iter solution. It all happens in real time and outside of coll like you suggested.

There are still a few details to iron in the arp patch. I'm now trying this solution to feed cycle to try to avoid using coll altogether.

Max Patch
Copy patch and select New From Clipboard in Max.