break data into bytes and bits in max?

Jun 20, 2013 at 3:45pm

break data into bytes and bits in max?

Hey all,

I’ve seen the atoi object, but I’m curious if there is an ascii->bytes or something along those lines in MAX.

#253485
Jun 20, 2013 at 5:26pm

Difficult to say without more details on what you are trying to accomplish.

But if you have formatted the data as bytes from wherever you are sending the data from then max will receive it in that format.

For example, the SARCduino firmware ( http://www.musicsensorsemotion.com/2010/03/08/sarcduino/ ) sends all data as bytes which are then parsed in Max.

All digital ports are read and their state is sent to max as 2 bytes (representing states for 12 inputs) which are then parsed in Max.

Analog inputs are also sent as 2 bytes (per input) and the values parsed in Max to get the corresponding 0-1023 values.

hope this helps

– Miguel

#253499
Jun 20, 2013 at 6:18pm

Very helpful, thank you! I would like to read a binary file, like a movie, and send it out as bytes. So read in a large file, and a byte at a time break it down and have 8 message boxes, each with a 1 or 0. This would happen once per second, let’s say. Very impractical, I know. Thoughts?

#253509
Jun 20, 2013 at 6:50pm

Haven’t done it myself but it sounds like you should have a look at the [filein] object.

Just tried it with a video file and seems to work although values are not 1 or 0. I’m sure if you try it out and ask in the forum for the specific object you might get better feedback from the community.

Hope it all works well.

– Miguel

#253511
Jun 20, 2013 at 7:31pm

this is one way you can convert decimal ints into binary bits

<code>

– Pasted Max Patch, click to expand. –

</code>

#253512
Jun 21, 2013 at 5:05am

This is how I isolate bits within a byte, similar to Floating Point’s method.

– Pasted Max Patch, click to expand. –
#253535

You must be logged in to reply to this topic.