break data into bytes and bits in max?

prismspecs's icon

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.

Miguel's icon

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

prismspecs's icon

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?

Miguel's icon

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

Floating Point's icon
Max Patch
Copy patch and select New From Clipboard in Max.

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

Jonathan Green's icon

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

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