main
Adam Adhiyatma 2017-01-03 18:17:41 -05:00
parent 5cfb1f44dc
commit d3ba6264c2
3 changed files with 25 additions and 1 deletions

BIN
.README.md.swp 100644

Binary file not shown.

23
README.md 100644
View File

@ -0,0 +1,23 @@
SLIPDECODER // madam data
This is a class that connects to a serial port and interprets OSC or other messages over the serial connection. Messages must be encoded using SLIP encoding (there are libraries for Arduino, etc). It allows for multiple control sources to be read over a serial bus - for instance, multiple knobs connected to an Arduino board.
The SLIPDecoder object takes 3 arguments = a port or address, baudrate and the number of inputs to be read.
SLIPDecoder.actions is an array of functions that receive the corresponding input as an argument and are evaluated every time a new value is read. The size of the array is set by the numAddresses argument when creating a new SLIPDecoder.
note: currently, only sequentially-numbered addresses ("/0", "/1", "/2") will work; it should be simple to modify the classfile to accept different addresses.
Configuring your arduino or other microcontroller:
I have included a sample file that should work on an Arduino Uno. I have also confirmed that it works on an Adafruit Metro Mini 328. I am using the following libraries: OSCBoards.h OSCBundle.h OSCData.h OSCMessage.h OSCTiming.h SLIPEncodedSerial.h SLIPEncodedUSBSerial.h
I'm pretty sure not all those are necessary, but I only have so much time and this was hacked together in a hurry.
Currently does not support OSC bundles (each control source must send a separate OSC message)
Example code:
//args = [port or path, baudrate, number of addresses/knobs/whatever]
k = SLIPDecoder.new("/dev/your_USB_device", 9600, 3);
k.start;
k.actions[0] = {|input| input.postln;};
k.actions[1] = {|input| input.postln;}; //define functions to do something with the incoming data.

View File

@ -11,7 +11,7 @@ SLIPDecoder {
rate = b;
numAddresses = c;
port = SerialPort(deviceName, rate);
actions = {}!numAddresses; //second byte in the data array is its address if it's properly configured in OSC. This value is used to select between a number of actions which can be externally set. Each action is a function that takes the message contents as an argument. see 'decode' below.
actions = {}!numAddresses; //second byte in the data array is its address if it's properly configured in OSC. THIS MIGHT BE DIFFERENT FOR DIFFERENT VERSIONS OF THE OSC PROTOCOL. This value is used to select between a number of actions which can be externally set. Each action is a function that takes the message contents as an argument. see 'decode' below.
decode = {|data| //function for decoding the properly-SLIP-decoded message.
var temp = 0!15, address, output;
//data[1].asAscii.postln;
@ -32,6 +32,7 @@ SLIPDecoder {
// esc = 8r333 (2r11011011 or 0xdb or 219)
// esc_end = 8r334 (2r011011100 or 0xdc or 220)
// esc_esc = 8r335 (2r011011101 or 0xdd or 221)
// original code by Martin Marier & Fredrik Olofsson
var buffer, serialByte;
var maxPacketSize = 64; // 16 is enouch for 8 10 bit values.