Iterating over list and combining them, not matching up.

Wim Van den Borre's icon

iteration.maxpat
Max Patch

Hey,

I'm scratching my head on this one, i'm iterating over a string to split first the string into two parts and then splitting the other part into dec and hex values to be send out to midi cc eventually. Everything works fine except for when i want to construct the message at the end. Somehow the elements don't line up anymore. In this case for example element 4 should be 0 but the output is one. When i print them seperatly the order seems to be fine but not when combining, what am I missing here?

Kr,

Wim

community links  links's icon

I'm iterating over a string to split it into two parts first, and then I'm splitting the second half into dec and hex values to be sent out to midi cc at some point. Except for when I want to build the message in the end, everything is ok. All the pieces have changed in some way. In this instance, element 4 for instance, should be 0 but the output is 1. The order appears to be correct when I print them separately, but not when I combine them.

Jean-Francois Charles's icon

@WIM: Max objects output from right to left outlets. Check your [zl slice 1]: the output from the right outlet will go first, triggering an output for [combine] before the data comes out from the left outlet of [zl slice].

Jean-Francois Charles's icon

Or maybe I misunderstand what you want. It would be easier if you included in your patch the example of what you would like to output vs what you get. Also, don't hesitate to select your Max code, do Edit->Copy Compressed, then paste in your post, it's faster for users who might help you.

Wim Van den Borre's icon

Hey thank you for replying! I know the left inlet puts the message out directly so what i want to achieve is create some kind of buffer ('ive tried all sorts of delays but to no avail) so that the messages are send out clean. So: 10 20 30 40 51 61 71 81 91 A1 B0 C1 D0 E1 F0 this should give me: 01101, 01102, 01103, 01104, 11105 ... until 011015 but as messages are fired too soon i get a non coherent output. This is the whole patch for the incoming message. Maybe their are other ways to iterate over this list and split them?

Jean-Francois Charles's icon

Try this. Note how I'm using [int] and [t b i] to fix the order.

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

Wim Van den Borre's icon

Wow it works!!! Tx!! What does the tbi trigger mean exactly?

Jean-Francois Charles's icon

[t] is one of the most important objects in Max. Outputs stuff from right to left.
[t b i] outputs first the integer to the right outlet, then a bang to the left.
Note in the example how it works with [int]: first, I store the int by feeding it in the right inlet. Then, when things are ready, I bang the left inlet of int to output it.
Add some [print objects] to check how that works.
Also make sure you study Max Basic Tutorial 5.

Wim Van den Borre's icon

Ok got it, thank you so much!! Will study more on the subject!

Wim Van den Borre's icon

Ok ran into a very interesting problem here. The input text is coming from the clipnames in Ableton. So i read the clipnames with these values and then i send them to my digitakt (sampler). Now I've added program change to the code. Now the problem is, when the program change is send out, the digitakt changes the pattern after for example one bar. So with this code in place the other parameters on the right of the slice mute or unmute channel 1 to 16 first and the the program change kicks in after which is off course not wat I want :) Any idea on how to delay the mutes also for one bar coming from the ableton clock?

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

I found this patch to start something on the downbeat but connecting them all is a little over my head :) It would be perfect to send the mutes on the next downbeat as in this example (I'm receiving them from plugsync)

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