evaluating equation using bitwise operators at sample rate?

redhexagonal's icon

I'd like to evaluate c-like bytebeat equations. They use bitwise operators.
for example t<<(t>>8&(t/(t>>10&t)))
where t increments by 1 at sample rate.

I can use expr to evaluate a buffer~ by substituting $i1 for t and using poke~, but I'd like to be able to change the equation dynamically by typing it in or choosing one from a menu, and I'd like to add other parameters to the equation (like X,Y-input) so I can change the output of the equation in real time

I thought I could use gen~ but it looks like it can't process bitwise operators. Is there any way in Max to evaluate an equation with bitwise operators at sample rate? Or to dynamically change that equation?

kLSDiz's icon

Definitely doable, lots of fun! It's not exactly like coding in C, but result is interesting. In Max there are a few bitsomething~ objects. [bitshift~] doesn't have signal input for shift amount so I had to substitute it with some basic math.

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

redhexagonal's icon

Hah that's great, good work. it sounds even better with DC removed. The problem , though is that for every equation i would have to build a new patch. I was hoping I could assign equations dynamically somehow, sort of live coding with text. I sort of managed it with some scripting to create expr objects that can fill a buffer, but I'd really like to have a signal rate evaluation....surely gen~ should do this! Apparently pd can do signal rate bitwise stuff with [expr~] but not Max?