Forums > MaxMSP

Access to MSB/LSB


jml
April 15, 2007 | 7:35 pm

Hi List,

Unfortunately or fortunately, I’ve never needed to delve into the world of sysex via significant and insignificant bits and I’ve got a project I’m working on where I’ll need to know this well.
I know that there have been multiple postings over the years regarding this (many of which I’ve read), but I can’t find exactly what I’m looking for.

I understand converting hex to ints, but I’ve not needed to split a number up into it’s MSB/LSB before.
I know that one way to do this is to use the [< <],[>>] shifters, but TBH, I’m not sure *why*.
I also understand what a nybble is, but am confused about how to format one from a number in Max (not JS, Java, or C).

For example, jasch’s [nn2bits] spells it out and makes it quite clear. But even with that, I am confused as to whether or not the order is maintained, and how to find out what order a given MIDI device accepts.

If anyone could help me understand the following, I would greatly appreciate it:
1. What max’s prefered order as to the direction of the bitstream.
2. How to break up numbers
3. How (or whether you need to for transmitting/receiving MIDI sysex) to reconstruct them
4. What order they get passed around in
5. A general methodology for working with bits in max
6. Where a good reference for this stuff would be found online

* Maybe I need to be using C?

jl



jml
April 15, 2007 | 8:05 pm

Sorry, to clarify:

1. What Max’s preferred order is as to the direction of the bit stream.
2. How to break up numbers
3. How (or whether you need to for transmitting/receiving MIDI SysEx) to reconstruct them
4. A general methodology for working with bits in Max
5. Where a good reference for this stuff would be found online

Thanks,
jl


April 15, 2007 | 9:25 pm



jml
April 15, 2007 | 11:46 pm

The tutorial on Max & Sysex is particularly useful,
thanks Jose.

I suppose I’m still looking for a way to do this without Elsea’s externs, but for the moment they do the trick (I knew about Lsx, but not of the variations on how to use it w/ the rest of his objs).

Does anyone have any other insights as to how to do what P. Elsea’s externs are doing in Max aside from writing a custom extern?

I’ll also look into doing it with JS/C…
I just wanted to know if plain-vanilla Max was capable, and how this sort of thing would work with sxformat, for example.

Thanks,
jl


April 16, 2007 | 9:08 am

jLubow schrieb:
> If anyone could help me understand the following, I would greatly appreciate it:
> 1. What max’s prefered order as to the direction of the bitstream.
> 2. How to break up numbers
> 3. How (or whether you need to for transmitting/receiving MIDI sysex) to reconstruct them
> 4. What order they get passed around in
> 5. A general methodology for working with bits in max
> 6. Where a good reference for this stuff would be found online
>
> * Maybe I need to be using C?

> I just wanted to know if plain-vanilla Max was capable, and how this
> sort of thing would work with sxformat, for example.

Plain vanilla Max is fine for it, I would do it that anyway…

The main idea behind it is: breaking a number into MSB/LSB in terms of
Midi: use of the modulo [% 128] and division [/ 128] operators -
in terms of nibbles: [% 16] and [/ 16]
And for retrieving out of MSB/LSB you need to multiply the MSB with the
result of the division and add it to the result of the modulo operation…

You can exchange the division and multiplication with shift operators,
as you divide or multiply by a power of two…

this might explain it better:

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P comment 303 90 29 196617 LSB;
#P comment 262 90 29 196617 MSB;
#P comment 154 90 29 196617 LSB;
#P number 258 237 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 258 213 48 196617 +;
#P number 258 191 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 220 191 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 112 236 41 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 112 212 48 196617 +;
#P number 112 190 41 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 74 190 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 258 165 35 196617 < < 4;
#P newex 220 165 35 196617 * 16;
#P newex 112 165 35 196617 < < 7;
#P newex 74 165 35 196617 * 128;
#P number 296 138 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 258 138 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 220 138 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 258 110 35 196617 >> 4;
#P newex 220 110 35 196617 / 16;
#P newex 296 110 35 196617 % 16;
#P number 220 61 71 9 0 255 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 150 138 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 112 138 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 74 138 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 112 110 35 196617 >> 7;
#P newex 74 110 35 196617 / 128;
#P newex 150 110 39 196617 % 128;
#P number 74 62 71 9 0 16383 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P comment 113 90 29 196617 MSB;
#P connect 1 0 3 0;
#P fasten 1 0 4 0 79 106 117 106;
#P fasten 1 0 2 0 79 106 155 106;
#P connect 8 0 10 0;
#P fasten 8 0 11 0 225 106 263 106;
#P fasten 8 0 9 0 225 106 301 106;
#P connect 13 0 18 0;
#P connect 18 0 24 0;
#P connect 12 0 17 0;
#P connect 17 0 23 0;
#P connect 14 0 25 1;
#P connect 24 0 25 0;
#P connect 25 0 26 0;
#P connect 21 0 22 0;
#P connect 7 0 21 1;
#P connect 20 0 21 0;
#P connect 5 0 15 0;
#P connect 15 0 19 0;
#P connect 6 0 16 0;
#P connect 16 0 20 0;
#P connect 11 0 13 0;
#P connect 4 0 6 0;
#P connect 9 0 14 0;
#P connect 10 0 12 0;
#P connect 2 0 7 0;
#P connect 3 0 5 0;
#P window clipboard copycount 30;


Stefan Tiedje————x——-
–_____———–|————–
–(_|_ —-|—–|—–()——-
– _|_)—-|—–()————–
———-()——–www.ccmix.com



jml
April 16, 2007 | 3:47 pm

Hi Stefan,

Thanks so much.
That’s just the type of schematic I was hoping for.

Always a pleasure,
jl

p.s. There’s one thing in the logical operators’ helpfile that’s been nagging me; I’ve put in into a patch, and I’m wondering if someone could shed some light on it:

#P hidden button 95 123 15 0;
#P hidden button 51 99 15 0;
#P window setfont Geneva 9.;
#P window linecount 1;
#P comment 106 131 83 13172745 via toggle?;
#P comment 106 112 167 13172745 turning into this number…;
#P toggle 29 92 15 0;
#P window setfont "Sans Serif" 9.;
#P number 29 112 76 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 29 68 27 9109513 | 30;
#B color 5;
#P number 29 47 35 9 0 60 3 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont Geneva 9.;
#P comment 72 47 120 13172745 how is this range…;
#P comment 47 91 14 13172745 < ;
#P connect 5 0 4 0;
#P connect 9 0 8 0;
#P connect 2 0 3 0;
#P connect 3 0 5 0;
#P window clipboard copycount 10;


April 16, 2007 | 4:03 pm

from the toggle helpfile:

"Toggle has one inlet which accepts int or bang and outputs an int. A
bang toggles between 0 and 1. A non-zero int is sent through to the
output while setting the toggle on, and 0 outputs a 0 and sets the
toggle off."

hth

/*j



jml
April 16, 2007 | 4:19 pm

shame on me.
obviously i shouldn’t underestimate any obj.
thanks, jasch.

jl


April 17, 2007 | 9:45 pm

It may be overkill, but I’m surprised nobody suggested doing actual
bitwise operations in this case. The whole thing can be done using the
shift-right (>>) and bitmasking (&) operators (which are a little
cheaper, fwiw).

A pretty good tutorial on bitwise operations can be found on the Arduino
website:

http://www.arduino.cc/playground/Code/BitMath

AB

here is an example:

#P window setfont "Sans Serif" 9.;
#P window linecount 2;
#P comment 236 58 100 196617 splitting an 8-bit number;
#P window linecount 1;
#P comment 342 113 27 196617 lsb;
#P comment 204 115 27 196617 msb;
#P number 236 194 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 236 166 78 196617 +;
#P newex 236 141 29 196617 < < 8;
#P number 304 113 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 236 112 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 273 30 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 304 90 33 196617 & 15;
#P newex 236 91 29 196617 >> 4;
#P comment 148 112 27 196617 lsb;
#P comment 10 113 27 196617 msb;
#P number 42 193 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 42 165 78 196617 +;
#P newex 42 140 29 196617 < < 8;
#P number 110 112 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 42 111 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 79 29 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 110 89 39 196617 & 255;
#P newex 42 90 32 196617 >> 8;
#P window linecount 2;
#P comment 8 53 100 196617 splitting a 16-bit number;
#P connect 13 0 11 0;
#P connect 13 0 12 0;
#P connect 12 0 15 0;
#P connect 11 0 14 0;
#P connect 14 0 16 0;
#P connect 16 0 17 0;
#P connect 15 0 17 1;
#P connect 17 0 18 0;
#P connect 7 0 8 0;
#P connect 5 0 7 1;
#P connect 6 0 7 0;
#P connect 4 0 6 0;
#P connect 2 0 5 0;
#P connect 1 0 4 0;
#P connect 3 0 1 0;
#P connect 3 0 2 0;
#P window clipboard copycount 22;



jml
April 22, 2007 | 4:58 am

Thanks Andrew,

Actually, that’s what Stephan suggested…
And yes, it’s exactly what I was looking for; Thank you.

Many thanks for the link.

jl



jml
April 22, 2007 | 5:01 am

Apologies: I meant to type *Stefan*.

jl


Viewing 11 posts - 1 through 11 (of 11 total)