Converting long lists of ints to ASCII, for UDP packets
What's the easiest way to convert a list (longer than 256, probably a maximum of about 1600) of ints (0-255) to ASCII? Essentially itoa but with more elements. I've tried in java but I'm missing the right actual function, and don't know if javascript can do the "casting" that's needed. Or a third-party external that does this solidly? or a clever workaround using coll?
Am sending LED data from Max wirelessly via UDP packets. They are :: RGB formatted into DMX, up to 512 channels, so maximum for a standard DMX usage = 1536, + one index byte at front. The setup could use many more channels as well, but this is within DMX specifications, and it's plenty for our purposes here.
The hardware only wants data formatted as ASCII, ints won't do it. Essentially, it would be great if the udp.send had a flag: default as-is, or switch on "convert incoming int packet list to ASCII", able to handle lists as long as udp.send can manage. Or, of course, a conversion beforehand.
This is a continued post from about a month ago, where my brother and I were getting an LED installation ready for a wedding. (Thanks to volker and Scott F. for their help during this!) Now there's no real rush, but this hurdle would save having to make multiple control boards. One of his boards can handle the full # of DMX channels (a lot more, actually, as it's a SecureDigital video / DMX / whatever playback device as well) so we want to use just one if possible. All it needs is that big ASCII list in.
Any help around this probably-quite-simple problem would be fantastic, it's getting in the way of the fun stuff ... thanks !
--CJ
On 13 Mar 2008, at 02:32, Seejay James wrote:
> What's the easiest way to convert a list (longer than 256, probably
> a maximum of about 1600) of ints (0-255) to ASCII?
A couple of questions:
(i) given that Max, or parts of Max, don't like long lists, how do
your lists of integers actually arrive or get generated? (Sequentially
with a count or an end-marker?)
(ii) ASCII is 0..127, so you're presumably making assumptions about
the device's character coding for 128...255 - what do you mean by
ASCII containing these values?
Nick Rothwell - nick@cassiel.com - www.cassiel.com
--- open-source goodies for MaxMSP: Python, Groovy, Nixie Tubes,
--- rotatable text bricks, databases: all at www.loadbang.net
Tried some more experimentation. Here's an example patch with comments to show what I'm trying to do. I guess I meant iso-8859, not ASCII, as the hardware responds to a full byte's worth of values. The patch allows you to see the full range of characters (with a number of non-printable etc. ones).
I get the lists through a jit.bfg, some other jit.effects, then a spill into separate R G B multisliders, then an interleave. The last list is a large multislider, so the user can manually set any specific channel, or run pattrs etc., if they want to(like when the generators are shut off). The interleaving of lists larger than 256 is straightforward via javascript, but only if they are still ints.
Hopefully this makes sense? Achhh ! !
--CJ
----------------------------------------------