Bit Manipulation - for FAQ and Cool Idea Threads

makerprofaze

2013-01-25 10:31:35

Pattern Scene Matrix Variables

I just found this thread in which metastatik divulges how to make variables hold more than one value (!!!)

It's late and I won't try it until tomorrow, but this seems useful - especially for the few of us who have nearly used up all the globals.


[Delete me]

metastatik

2013-01-26 17:57:07

FWIW, I just posted a practical example of using this here.

psamek

2013-03-27 03:31:07

:D

Bit manipulation is the bomb! I mean Bome. I was inspired to dive in and try BMT by these posts on bit manipulation, which is incredibly powerful. At first I couldn't understand why translators don't just automatically extract the channel number from the status byte because it is a very useful parameter. Thinking about it -- and the fact that the good Herr Bome has given us bit operators -- I propose the following "sandbox" example which rechannelizes any 2- or 3-byte message from any channel to a desired new channel:

Code: Select all

\\ translator 0 - set desired channel using an arbitrary sysx command
Trigger: F0 01 02 03 g0 F7
Outgoing: None

\\ translator 1 - rechannel incoming 3-byte messages to channel g0
Trigger: pp qq rr
Rules:
     pp=pp&240 \\ use binary 11110000 to mask out the four least significant bits
     pp=pp+g0 \\ add back the desired channel
Outgoing: pp qq rr \\ and that's all there is to it!

\\ translator 2 - same again for 2-byte messages
Trigger: pp qq
Rules:
     pp=pp&240 \\ use binary 11110000 to mask out the four least significant bits
     pp=pp+g0 \\ add back the desired channel
Outgoing: pp qq

The alternative would have been a lot of if statements or a lot of translators.
I can hardly wait for release 2.0! And I apologize to the group if, noob that I am, I seem to be discovering the obvious. But it seems cool to me.

florian

2013-05-25 16:00:56

Hi psalmek,

no, this is great information for many people!

Thanks,
Florian