## How do i get binary gates from a signal?

Aug 25, 2011 at 2:55pm

# How do i get binary gates from a signal?

and vice versa?

My google sense tells me this will be impossible to find. Search terms: max msp, dac, adc, raw bits, signal etc. Hard. Thus my question:

Is there an external to convert a signal into the bits it’s made of? A virtual “digital adc”, if you will, with one inlet and 24 outlets. Or preferably a selectable amount of outlets to avoid terrible patchcord messes. And of course an inverted version, a “digital dac”.

Any ideas? I’d love patching one up, I just have no idea about how dacs or adcs work…

#58621
Aug 25, 2011 at 5:06pm

you should be able to do that with the MSP bitwise operators, no?

#210742
Aug 29, 2011 at 2:32pm

Not that I know of. They do bitwise stuff that is cool but I want to manipulate the individual bits as 0-1 signals.

Anyone?

#210743
Aug 31, 2011 at 10:59am

Roman is right, the bitwise operators are designed to do exactly that.

#210744
Sep 1, 2011 at 8:00pm

Sorry, I didn’t have Max available when I first replied. I’m assuming you want to deal with integer values in your signal? If so, here’s how to handle an 8-bit number…

– Pasted Max Patch, click to expand. –
#210745
Sep 4, 2011 at 8:13pm

Ah. Very grateful. I guess reversing it should be just as easy? No time to try now. I’ll probably figure it out. Thanks!

#210746
Sep 5, 2011 at 8:46am

You’re welcome :)

Although it is do-able, I think reversing this process will throw up a number of ugly problems unless you know exactly what you’re doing. The above technique relies on [bitand~]‘s ability to convert a floating-point number into an integer internally.

The binary representation of an integer is very different to that of a float. See W!k!p3d!a for more details.

You’d probably be better off just using the 8 exponent bits (and forgoing the costly “convert to integer representation” process that I had [bitand~] performing earlier). If you’re struggling with the concept, I’ll knock up a patch when I next have Max handy.

If you manually pack bits into a floating point number, it’s possible to create some unusual ‘numbers’ (NaN, -infinity, +infinity). Max/MSP objects don’t play nicely with such values.

#210747
Sep 5, 2011 at 8:49am

I’m curious… What are you using this for?

I do a lot of signal-rate stuff that uses a fair bit of logic, but I’ve never had the need to do what you’re attempting. Either there’s an easier way to do what you want, or you’re doing something seriously tech and exciting!!!

#210748
Sep 15, 2011 at 2:08pm

…Ok, i have no idea how to convert the bits into “analog” again. My bad.

Basically i just want to do crazy stuff with them. Not tech so much as stupid I guess. Things like:
Take, say 12 bits and do CA style rule manipulations,
delay individual bits by different amount of samples per bit,
do bit0 XOR bit1 OR bit2 AND bit3 XOR bit4,
invert them randomly,
invert them based on logic,
shift right or left based on total number of 1s,
interleave/shuffle bits from two sounds
delay them for a set amount of samples based on CA rules…

I don’t know. I hope that when i get them all out things should start falling into place.

If it’s easier to do this some other way I’d of course do it that way but I have no idea what that would be.

Nan, inf and -inf should be ok with a bitshift~, no? Most things will probably sound crap-ish but that’s kind of the point.

So if you’d like to throw together a patch I’d be very grateful. If I get something cool out of it I could always post it here.

#210749
Sep 15, 2011 at 3:40pm

OK, I had a quick look and it’s not totally straightforward. Let me puzzle something out and I’ll get back to you – maybe not straight away.

Independent per-bit delay sounds intriguing…

I suspect all this twiddling will probably result in very same-y crust, but who knows? Time to play…

#210750
Sep 15, 2011 at 3:42pm

But back to your main problem, recombining…

It ought to be a case of simply [bitor~]ing all the signals back together. You’ll need a whole bunch of [bitor~]s though.

#210751
Sep 15, 2011 at 3:51pm

Yes, most modes will probably sound same-same. But you never know. The delay part is most intriguing, yes!

Anything like this? I’m just guessing basically.

– Pasted Max Patch, click to expand. –
#210752
Sep 15, 2011 at 5:28pm

Oh, and bitwise surround panning! Four sources, four speakers, and all the bits swapped around consecutively. Could be fun.

#210753
Sep 15, 2011 at 7:27pm

it will probably sound like crap, but you can always tell the audience: “but it is bitwise
surround panning! dont you understand the concept!?!”

maybe it is almost as cool as the converting the ASCII of the american constitution
into audio and then pan it hard to the right.

#210754
Sep 16, 2011 at 12:22am

Exactly!!

#210755
Oct 16, 2011 at 12:05am

Any progress? I haven’t thought much about it, got no idea how to do it.

(I have bought a G2 engine though, so I can do some stuff in 8 bits there as soon as it gets here.)

Btw actually I think the bitwise surround stuff could be nice with simple sounds for drony stuff! Maybe just not drumkits and choir music.

#210756
Nov 27, 2012 at 8:24pm

any news ? I’m interesting too. :-)

#210757

You must be logged in to reply to this topic.