Access to MSB/LSB
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
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
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
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:
--
Stefan Tiedje------------x-------
--_____-----------|--------------
--(_|_ ----|-----|-----()-------
-- _|_)----|-----()--------------
----------()--------www.ccmix.com
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:
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
shame on me.
obviously i shouldn't underestimate any obj.
thanks, jasch.
jl
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:
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
Apologies: I meant to type *Stefan*.
jl