Split and spell words

    May 19 2010 | 5:35 am
    Warning, I suck at Max, but I am trying.
    I have a device that accepts 3 characters using sysex for a LED display.
    The message looks like "sxformat 240 66 64 110 8 34 4 0 / is $i1 / / is $i2 / / is $i3 / 247"
    where the inputs are ascii values.
    I want to send a message, convert the first three characters into ascii values and then input them into the sxformat and send the message off. I'm having a hard time figuring out how to split the string, convert the letters, and then collect them before sending off the message as three inputs at the same time. I'm sure this is easy for the Max regulars out there. It should handle strings of 0, 1, 2 or 3 characters correctly as well. 0x29 is a blank.
    The ultimate would be if the string is over length of 3 is rotates the letters on a timer, but I can do this in a JS part of the patch pretty simply so just the above would suffice.
    I'm going to keep diving into the various Max objects but any guidance in the mean time would be greatly appreciated.

    • May 19 2010 | 6:04 am
      Converting to ascii using the atoi object produces a list of which the first three can be sliced using [zl slice 3]. In case the string is shorter then 3 values, if you prepend (using [prepend]) three times the value for a blank and slice off the last three values with [zl ecils 3] you have a list where blanks are correctly represented. The vexpr object allows to map the atoi output to the correct range.
    • May 19 2010 | 6:31 am
      Thanks for the quick reply jvkr. It worked perfectly.
      If anyone can figure out the case for "hello" to scroll that would be super awesome :)
      Here's the patch so far.
    • May 19 2010 | 11:07 am
      Like this?
    • May 19 2010 | 6:04 pm
      Wow, you just blew my mind jvkr. Wish this forum had rep points.
      It's super close to what I was thinking. I'll try to explain it case by case and see if you or anyone else is up to the challenge. I'm gonna give it a shot too to try to learn but I doubt I'll get it.
      Input: (where '_' is a space)
      "Hi" -> Just displays "_Hi"
      "Hey" -> Displays "Hey"
      "Hello" -> Displays "Hel" -> "ell" -> "llo" -> "lo_" -> "o_H" -> "_He" -> "Hel" then a pause and repeat.
      If the screen length is a variable maybe this could be used by anyone looking to make a scrolling display?
    • May 20 2010 | 12:17 am
      You might try [zl rot] on your overall list of ASCII values, then send/display only the first three of the list. Change the value to [zl rot] using whatever timer/counter/incdec method you want. You can go negative to read backwards :)
      The length of the list [zl len] could be used to determine when to pause your display (when the list has cycled all the way through). So this would be the same as the value to [zl rot] at the point of restarting.