DMX High Byte/Low Byte coding

piwolf's icon

Any links or info on how to split a data stream value out as two seperate High Byte and Low Byte channels on DMX? Tilt Pan value application with a range of 65535 which I am assuming is the bit depth of the two interleaved 255 values that dmx runs on.
Using Enttec products. I have all the regular DMX packing well in hand, just dont understand how to order the data from a single value to a split set of values of lower depth.

maxmspjit's icon

On 07-08-26, at 1315, piwolf wrote:
>
> Any links or info on how to split a data stream value out as two
> seperate High Byte and Low Byte channels on DMX? Tilt Pan value
> application with a range of 65535 which I am assuming is the bit
> depth of the two interleaved 255 values that dmx runs on.
> Using Enttec products. I have all the regular DMX packing well in
> hand, just dont understand how to order the data from a single
> value to a split set of values of lower depth.
>
Not sure if I understand you correctly, but I assume you're using two
channels to send an unsigned short?

unsigned short pan = whatever;
char channel1 = (pan & 0xff00) >> 8;
char channel2 = (pan & 0xff);

r.

piwolf's icon

Yes I am sending to two channels each with a range or 0-255. There combination of values creates a range of 65535. The code excerpt you posted is intended for me to implement where? This is something I want to be constantly streaming update data to.
Are 0xff00 and 0xff the hex locations for most and least significant byte? I know char is a data type/object but give me the quick rundown on what type "unsigned short" is?

Thanks a ton!

brandon

maxmspjit's icon

On 07-08-26, at 1353, piwolf wrote:
>
> Yes I am sending to two channels each with a range or 0-255. There
> combination of values creates a range of 65535. The code excerpt
> you posted is intended for me to implement where? This is
> something I want to be constantly streaming update data to.
>
I don't know what your DMX object looks like, so I have a hard time
advising here. If you want me to take a look at it you can send it to
me off-list. The DMX object I have accepts a number of channels at a
time as a list. I would probably implement the code I pasted upstream
to my DMX object, since it's specific to one fixture, not the DMX
object itself. Consider the [expr] object.

> Are 0xff00 and 0xff the hex locations for most and least
> significant byte? I know char is a data type/object but give me
> the quick rundown on what type "unsigned short" is?
>
0xff00 and 0xff are bit masks. I recommend reading up on bit
operations, both masking and shifting.

I also recommend reading up on data types. An unsigned short in most
languages is an unsigned 16 bit value, giving a maximum of 65535. A
char is typically 1/2 a short, or 8 bits.

r.

piwolf's icon

Thanks man. Great help.

B

piwolf's icon

So I understand the masking; and the variable types; and mostly the expression object but I am curious if I need to write an external or not. I take in the OSC float value from the lemur; then multiply it to get it into the range for the unsigned short, but Im not declaring an unsigned short, just an int in the range of one; then I tried to use the expression object to perform a masking function but the output I am getting is well beyond the range of an 8 bit value. I can see the problem from the math that I am sending in a higher bit depth variable even though I am in the value range I need to be. Is there a way to implement the masking without writing it in Visual Studio as an external? The only variable types I am familiar with declaring inside of max are the obvious, int,float,and symbol. What would be the cleanest and process friendly way of performing the split? Am I missing an obvious way with the max scripting to declare the bit depth of variables or should I do it in my external compiler? Thanks again!!

b

maxmspjit's icon

On 07-09-01, at 1912, piwolf wrote:
>
> So I understand the masking; and the variable types; and mostly the
> expression object but I am curious if I need to write an external
> or not.
>
Who knows- we can't read your mind. My guess is that if you can't
already figure out what to do at this point, then writing an external
won't help you.

This is what I gather is your question:

You have a lemur which is giving you a float value with some range
(input), and you want to convert it to an unsigned short to send over
DMX (output). This really means you need a high and low byte to send
over two DMX channels.

So just put the math I replied with previously into an expr and you
are good to go, no? If not, can you please restate your question in
such a way that we don't need to assume we know what you are doing.

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

Joe Bell's icon

thanks for posting up that demo patch, massively helpful for me.