To get bits, use the standard bitwise operators, just like C or many
other languages. Pd has the whole suite: & | >> <<
To get the value of a bit, AND it by that bit's value, i.e. the 4th
bit would be [& 16]
.hc
On Jun 16, 2006, at 2:00 PM, Dan Overholt wrote:
Hi All,
I've put up an example of using the Bluetooth CUI with PD here: http://www.create.ucsb.edu/~dano/CUI/CUIBTPDtest.pd
The only question is how to get at the individual bits within the
last 2 received bytes to decode the digital inputs from the CUI. In Max/MSP, there is an 3rd party external called [bit] that does this... any suggestions?All the best, -Dan
-- Dan Overholt -- http://www.create.ucsb.edu/~dano Center for Research in Electronic Art Technology, UCSB
On Fri, 16 Jun 2006, Alexandre Quessy wrote:
Hello Pure Data friends,
We are currently trying to make the Bluetooth CUI work with PD.
The Bluetooth Create Usb Interface is the wireless version of the USB CUI, a 13 analog/10 bits and 12 digital I/O interface for sensors.
The BTCUI is perfect for embbeded applications like dance, performance, music etc. It's one of the cheapest and smallest
wireless interface on the market, and it is Open Hardware !The USB CUI works all right with PD, with HID tools. We use the [hid] external from PD-Extended 0.39.RC4 (on Mac).
Unfortunately, we didn't succeeded to make the BluetoothCUI working with PD. We have tried [comport] and [hid]. The BTCUI works perfectly on Max/MSP (demo version), as announced by Dan Overholt, its creator. His patch is downloadable at http://www.create.ucsb.edu/~dano/CUI/BlueCUItestRev2.zip and uses the [serial] object of Max/MSP.
The protocol of the CUI is probably similar to the one used by joysticks and such. It consists in a serie of integers with delimiters, the several remaining integers beings the values that the device sends to the computer. See the attached PD patches. Below are out two PD patches. The first one uses [hid] and works with the USB CUI, but not over BlueTooth. (Apple does serial port emulation) The second uses [comport] and almost work. The CUI LED lights up, so it means that it is sending data, but most often, dumping the data from [comport]'s outlet give us nothing.
Would you have any idea of what is missing to imitate, and make even better than the [serial] Max/MSP object ? Otherwise, would it be
easier on Linux ?JN and
Man has survived hitherto because he was too ignorant to know how to
realize his wishes. Now that he can realize them, he must either
change them, or perish. -William Carlos Williams
On Fri, 16 Jun 2006, Hans-Christoph Steiner wrote:
To get bits, use the standard bitwise operators, just like C or many other languages. Pd has the whole suite: & | >> <<
Anyone outside of pd would agree that the whole suite includes ^
However pd doesn't have a [^], though [expr $f1^$f2] is a nice substitute, if one's project is GPL-compatible.
_ _ __ ___ _____ ________ _____________ _____________________ ... | Mathieu Bouchard - tél:+1.514.383.3801 - http://artengine.ca/matju | Freelance Digital Arts Engineer, Montréal QC Canada
On Fri, Jun 16, 2006 at 06:09:08PM -0400, Mathieu Bouchard wrote:
On Fri, 16 Jun 2006, Hans-Christoph Steiner wrote:
To get bits, use the standard bitwise operators, just like C or many other languages. Pd has the whole suite: & | >> <<
Anyone outside of pd would agree that the whole suite includes ^
However pd doesn't have a [^], though [expr $f1^$f2] is a nice substitute, if one's project is GPL-compatible.
Pd implementation of XOR attached. Why doesn't Pd include a bitwise NOT operator? Or did I miss something?
Best,
Chris.
chris@mccormick.cx http://mccormick.cx
On Mon, 19 Jun 2006, Chris McCormick wrote:
Pd implementation of XOR attached. Why doesn't Pd include a bitwise NOT operator? Or did I miss something?
It doesn't because it's not specified nor clear nor obvious which format of integers we want to use with it.
Pd uses the float32 number type, in which the largest embeddable int type would be int25, but it can also make sense to think of it as int24 (because 24 is multiple of 8) or as uint24.
Another issue is the interpretation of the sign bit. With floats, flipping the sign bit just negates the number, but with ints, it's normally assumed that flipping it will shift the number by 1<<N... e.g. for N=8, the char type of C has weights:
-256 64 32 16 8 4 2 1
compared to unsigned char that has 128 instead of -256, and compared to float, in which the bits don't just add up like that, they behave like [...] 128 64 32 16 8 4 2 1 for sign 0, and -128 -64 -32 -16 -8 -4 -2 -1 for sign 1.
_ _ __ ___ _____ ________ _____________ _____________________ ... | Mathieu Bouchard - tél:+1.514.383.3801 - http://artengine.ca/matju | Freelance Digital Arts Engineer, Montréal QC Canada