├── Arduino-Code ├── OSC library - Backup │ └── OSCuino │ │ ├── API.md │ │ ├── Applications │ │ ├── MaxMSP │ │ │ └── examples │ │ │ │ ├── OSCEsplora.maxpat │ │ │ │ ├── SerialCallResponse.maxpat │ │ │ │ ├── SerialEcho.maxpat │ │ │ │ ├── SerialOscuino.maxpat │ │ │ │ ├── SerialReceive.maxpat │ │ │ │ ├── SerialReceivewithServo.maxpat │ │ │ │ ├── SerialSend.maxpat │ │ │ │ ├── UDPCallResponse.maxpat │ │ │ │ ├── UDPEcho.maxpat │ │ │ │ ├── UDPOscuino.maxpat │ │ │ │ ├── UDPReceive.maxpat │ │ │ │ └── UDPSend.maxpat │ │ ├── PD │ │ │ ├── SerialOscuino.pd │ │ │ └── o.io.slipserial.pd │ │ └── Processing │ │ │ ├── SLIPSerialToUDP │ │ │ └── SLIPSerialToUDP.pde │ │ │ ├── UDPReceiveBundle │ │ │ └── UDPReceiveBundle.pde │ │ │ ├── UDPReceiveMessage │ │ │ └── UDPReceiveMessage.pde │ │ │ └── serialSend │ │ │ ├── code │ │ │ └── javaosc.jar │ │ │ ├── serialSend.pde │ │ │ └── sketch.properties │ │ ├── LICENSE │ │ ├── OSCBoards copy.h │ │ ├── OSCBoards.h │ │ ├── OSCBundle.cpp │ │ ├── OSCBundle.h │ │ ├── OSCData.cpp │ │ ├── OSCData.h │ │ ├── OSCMatch.c │ │ ├── OSCMatch.h │ │ ├── OSCMessage.cpp │ │ ├── OSCMessage.h │ │ ├── OSCTiming.cpp │ │ ├── OSCTiming.h │ │ ├── README.md │ │ ├── SLIPEncodedSerial.cpp │ │ ├── SLIPEncodedSerial.h │ │ ├── SLIPEncodedUSBSerial.cpp │ │ ├── SLIPEncodedUSBSerial.h │ │ ├── examples │ │ ├── ESP8266ReceiveBundle │ │ │ └── ESP8266ReceiveBundle.ino │ │ ├── ESP8266sendMessage │ │ │ └── ESP8266sendMessage.ino │ │ ├── OSCEsplora │ │ │ └── OSCEsplora.ino │ │ ├── PatternMatching │ │ │ └── PatternMatching.ino │ │ ├── SerialCallResponse │ │ │ └── SerialCallResponse.ino │ │ ├── SerialEcho │ │ │ └── SerialEcho.ino │ │ ├── SerialFubarino │ │ │ └── SerialFubarino.pde │ │ ├── SerialOscuinowithBundles │ │ │ └── SerialOscuinowithBundles.ino │ │ ├── SerialOscuinowithMessages │ │ │ └── SerialOscuinowithMessages.ino │ │ ├── SerialReceive │ │ │ └── SerialReceive.ino │ │ ├── SerialReceivewithServo │ │ │ └── SerialReceivewithServo.ino │ │ ├── SerialSendBundle │ │ │ └── SerialSendBundle.ino │ │ ├── SerialSendBundleWithTimeTag │ │ │ └── SerialSendBundleWithTimeTag.ino │ │ ├── SerialSendMessage │ │ │ └── SerialSendMessage.ino │ │ ├── UDPCallResponse │ │ │ └── UDPCallResponse.ino │ │ ├── UDPEcho │ │ │ └── UDPEcho.ino │ │ ├── UDPOscuino │ │ │ └── UDPOscuino.ino │ │ ├── UDPReceive │ │ │ └── UDPReceive.ino │ │ ├── UDPSendBundle │ │ │ └── UDPSendBundle.ino │ │ ├── UDPSendBundlewithTimeTag │ │ │ └── UDPSendBundlewithTimeTag.ino │ │ └── UDPSendMessage │ │ │ └── UDPSendMessage.ino │ │ ├── keywords.txt │ │ ├── library.json │ │ ├── library.properties │ │ └── test │ │ ├── OSCBundle_test │ │ ├── OSCBundle_test.ino │ │ └── TestPrint.h │ │ ├── OSCData_test │ │ └── OSCData_test.ino │ │ ├── OSCMessage_encode_decode_test │ │ ├── OSCMessage_encode_decode_test.ino │ │ └── TestPrint.h │ │ ├── OSCMessage_match_test │ │ └── OSCMessage_match_test.ino │ │ └── OSCMessage_test │ │ └── OSCMessage_test.ino ├── ReceiveOSC │ └── ReceiveOSC.ino ├── SendOSC │ └── SendOSC.ino └── SendReceiveOSC │ └── SendReceiveOSC.ino ├── Hookup ├── Arduino_PinMapping.jpg ├── Demo.jpg ├── LayoutPart_NodeMCUV1.0.fzpz ├── SendReceive.fzz └── SendReceive.jpg ├── README.md └── TouchOSC └── Arduino+OSC.touchosc /Arduino-Code/OSC library - Backup/OSCuino/API.md: -------------------------------------------------------------------------------- 1 | # OSCMessage 2 | 3 | An OSCMessage is an address followed by any number of data. Messages can have mixed data types like an integer followed by a string followed by a float, etc. 4 | 5 | ## Constructor 6 | 7 | OSCMessages can be constructed with or without an address. 8 | 9 | ### `OSCMessage(const char *)` 10 | 11 | Set the address of the message in the constructor 12 | 13 | ```C++ 14 | OSCMessage msg("/address"); 15 | ``` 16 | 17 | ### `OSCMessage()` 18 | 19 | An OSCMessage constructed without an address is not valid until it is given an address. 20 | 21 | ## Add/Set Data 22 | 23 | 24 | ### `OSCMessage& add(int i)` 25 | 26 | Append an integer to the OSCMessage. 27 | 28 | ```C++ 29 | msg.add(1); 30 | ``` 31 | 32 | 33 | ### `OSCMessage& add(float f)` 34 | 35 | Append a float to the OSCMessage. 36 | 37 | 38 | 39 | ### `OSCMessage& add(bool b)` 40 | 41 | Append a boolean to the OSCMessage. 42 | 43 | 44 | 45 | ### `OSCMessage& add(const char * str)` 46 | 47 | Append a string to the OSCMessage. 48 | 49 | ```C++ 50 | msg.add("hello"); 51 | ``` 52 | 53 | 54 | ### `OSCMessage& add(uint8_t * blob, int length)` 55 | 56 | Append a [blob](https://en.wikipedia.org/wiki/Binary_large_object) to the OSCMessage. Pass in the length of the blob as the second argument. 57 | 58 | 59 | 60 | ### `OSCMessage& set(int position, Type data)` 61 | 62 | Replace the data at the given position with the data. `Type` can be any of the supported data types. 63 | 64 | ```C++ 65 | //replace the data at the 0th position with a string 66 | msg.set(0, "string"); 67 | ``` 68 | 69 | 70 | ### `OSCMessage& set(int position, uint8_t * data, int length)` 71 | 72 | Set the data at the given position to be a blob of the given length. 73 | 74 | 75 | ### `OSCMessage& add(double d)` 76 | 77 | Append a double precision floating point value to the OSCMessage. NOTE: double is not supported on most Arduino platforms. It will fall back to float, when double is not supported. 78 | 79 | ## Get Data 80 | 81 | 82 | ### `int getInt(int position)` 83 | 84 | Returns the integer at the given position 85 | 86 | ```C++ 87 | //returns the integer at the third position 88 | msg.getInt(2); 89 | ``` 90 | 91 | ### `float getFloat(int position)` 92 | 93 | Returns the float at the given position 94 | 95 | 96 | 97 | ### `bool getBoolean(int position)` 98 | 99 | Returns the boolean at the given position 100 | 101 | 102 | 103 | ### `double getDouble(int position)` 104 | 105 | Returns the double at the given position. NOTE: double is not supported by most Arduino platforms. This will fail silently if double is not supported. 106 | 107 | 108 | ### `int getString(int position, char * str, int length)` 109 | 110 | Copy `length` number of characters from the given position into the `str` buffer. Returns the number of copied characters. 111 | 112 | ```C++ 113 | char str[8]; 114 | //fill str with 8 characters from the 0th datum 115 | msg.getString(0, str, 8); 116 | ``` 117 | 118 | 119 | ### `int getBlob(int position, uint8_t * blob, int length)` 120 | 121 | Copy `length` number of bytes from the given position into the `blob` buffer. Returns the number of copied bytes. 122 | 123 | 124 | 125 | ### `char getType(int position)` 126 | 127 | Returns the type of the data at the given position. 128 | 129 | ```C++ 130 | OSCMessage msg("/address"); 131 | msg.add(1); 132 | msg.getType(0); //-> returns 'i' 133 | ``` 134 | 135 | 136 | ## Query Data 137 | 138 | ### `bool isInt(int position)` 139 | 140 | Returns `true` when the data at the given position is an integer. 141 | 142 | ### `bool isFloat(int position)` 143 | 144 | Returns `true` when the data at the given position is a float. 145 | 146 | ### `bool isBoolean(int position)` 147 | 148 | Returns `true` when the data at the given position is a boolean. 149 | 150 | ### `bool isString(int position)` 151 | 152 | Returns `true` when the data at the given position is a string. 153 | 154 | ### `bool isBlob(int position)` 155 | 156 | Returns `true` when the data at the given position is a blob. 157 | 158 | ### `bool isDouble(int position)` 159 | 160 | Returns `true` when the data at the given position is a double. 161 | 162 | ### `int size()` 163 | 164 | Returns the number of data the OSCMessage has. 165 | 166 | ### `int bytes()` 167 | 168 | Returns the size of the OSCMessage in bytes (if everything is 32-bit aligned). 169 | 170 | 171 | 172 | ## Address 173 | 174 | ### `OSCMessage& setAddress(const char * address)` 175 | 176 | Set the address of the OSCMessage. 177 | 178 | ### `OSCMessage& getAddress(char * str, int offset=0)` 179 | 180 | Copy the address of the OSCMessage into the `str` buffer. Copy after the given address offset (defaults to 0). 181 | 182 | 183 | ## Send Receive 184 | 185 | ### `OSCMessage& send(Print &p)` 186 | 187 | Output the message to the given transport layer which extends Arduino's [Print class](http://playground.arduino.cc/Code/Printclass) like the `Serial` out. 188 | 189 | ```C++ 190 | msg.send(SLIPSerial); 191 | ``` 192 | 193 | ### `OSCMessage& fill(uint8_t incomingByte)` 194 | 195 | Add the incoming byte to the OSCMessage where it will be decoded. 196 | 197 | ### `OSCMessage& fill(uint8_t * bytes, int length)` 198 | 199 | Add and decode the array of bytes as an OSCMessage. 200 | 201 | 202 | 203 | ## Matching / Routing 204 | 205 | ### `bool fullMatch( const char * pattern, int offset = 0)` 206 | 207 | Returns true if the message's address is a full match to the given pattern after the offset. 208 | 209 | ```C++ 210 | OSCMessage msg("/a/0"); 211 | msg.fullMatch("/0", 2); // ->returns true 212 | ``` 213 | 214 | ### `int match( const char * pattern, int offset = 0)` 215 | 216 | Returns the number of matched characters of the message's address against the given pattern (optionally with an offset). Unlike `fullMatch`, `match` allows for partial matches 217 | 218 | ```C++ 219 | OSCMessage msg("/a/0"); 220 | msg.match("/a"); // ->returns 2 221 | ``` 222 | 223 | ### `bool dispatch(const char * pattern, void (*callback)(OSCMessage &), int offset = 0)` 224 | 225 | Invoke the given callback if the address if a full match with the pattern (after the offset). The message is passed into the callback function. Returns true if the pattern was a match and the callback function was invoked. 226 | 227 | ### `bool route(const char * pattern, void (*callback)(OSCMessage &, int), int offset = 0)` 228 | 229 | Invoke the given callback if the address if a match with the pattern (after the offset). The OSCMessage and the address offset is passed into the callback function. Returns true if the pattern was a match and the callback function was invoked. 230 | 231 | ```C++ 232 | //define a callback function for matching messages 233 | void routeCallback(OSCMessage & message, int addressOffset){ 234 | //do something with the message... 235 | 236 | //with the message below, the addressOffset will equal 2. 237 | } 238 | 239 | OSCMessage msg("/a/0"); 240 | msg.route("/a", routeCallback); 241 | ``` 242 | 243 | 244 | ## Address Patterns 245 | 246 | OSCMessages can be constructed with patterns and later routed or dispatched against addresses. 247 | 248 | ```C++ 249 | OSCMessage msg("/{a,b}/[0-9]"); 250 | msg.route("/a/0", a0_callback); //matches the address 251 | msg.route("/b/2", b2_callback); //matches the address 252 | msg.route("/c/11", c11_callback); //not invoked 253 | ``` 254 | 255 | # OSCBundle 256 | 257 | A bundle is a group of OSCMessages with a timetag. 258 | 259 | 260 | ## Constructor 261 | 262 | ### `OSCBundle()` 263 | 264 | Construct an empty OSCBundle. 265 | 266 | ### `OSCBundle(osctime_t = zerotime)` 267 | 268 | Construct the bundle with a timetag. timetag defaults to 0 (immediate). 269 | 270 | 271 | 272 | ## Add OSCMessage 273 | 274 | ### `OSCMessage & add(char * address)` 275 | 276 | Create a new message with the given address in the bundle. Returns the newly created OSCMessage. 277 | 278 | ```C++ 279 | //create a new OSCMessage and add some data to it 280 | bundle.add("/message").add("data"); 281 | ``` 282 | 283 | 284 | ## Get OSCMessage 285 | 286 | ### `OSCMessage * getOSCMessage(int position)` 287 | 288 | Return the OSCMessage in the bundle at the given position. 289 | 290 | ```C++ 291 | OSCBundle bundle 292 | bundle.add("/a"); 293 | bundle.add("/b"); 294 | bundle.getOSCMessage(0);//returns the OSCMessage with the address "/a". 295 | ``` 296 | 297 | ### `OSCMessage * getOSCMessage(char * address)` 298 | 299 | Return the OSCMessage in the bundle which matches the given address. 300 | 301 | ```C++ 302 | OSCBundle bundle 303 | bundle.add("/a"); 304 | bundle.add("/b"); 305 | bundle.getOSCMessage("/b");//returns the second OSCMessage in the bundle 306 | ``` 307 | 308 | 309 | ## Routing 310 | 311 | ### `bool dispatch(const char * pattern, void (*callback)(OSCMessage&), int offset = 0)` 312 | 313 | Invoke the callback function with all messages in the bundle which match the given pattern after the offset. 314 | 315 | ```C++ 316 | bundle.add("/a/0"); 317 | bundle.add("/b/0"); 318 | bundle.dispatch("/0", dispatchZero, 2); 319 | ``` 320 | 321 | ### `bool route(const char * pattern, void (*callback)(OSCMessage &, int), int offset = 0)` 322 | 323 | Invoke the callback with all the OSCMessages in the bundle which match the given pattern. `route` allows for partial matches. 324 | 325 | 326 | 327 | ## Send/Receive 328 | 329 | ### `OSCBundle& send(Print &p)` 330 | 331 | Output the bundle to the given transport layer which extends Arduino's [Print class](http://playground.arduino.cc/Code/Printclass) (such as `SLIPSerial` out). 332 | 333 | ```C++ 334 | bundle.send(SLIPSerial); 335 | ``` 336 | 337 | ### `OSCBundle& fill(uint8_t incomingByte)` 338 | 339 | Add the incoming byte to the OSCBundle where it will be decoded. 340 | 341 | ### `OSCBundle& fill(uint8_t * bytes, int length)` 342 | 343 | Add and decode the array of bytes as an OSCBundle. 344 | 345 | 346 | 347 | # Chaining 348 | 349 | Many methods return `this` which enables you to string together multiple commands. 350 | 351 | This technique allows multiple lines to be condensed into one: 352 | 353 | ```C++ 354 | bundle.add("/address").add("data").add(0).send(SLIPSerial).empty(); 355 | ``` 356 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/Applications/MaxMSP/examples/OSCEsplora.maxpat: -------------------------------------------------------------------------------- 1 | { 2 | "patcher" : { 3 | "fileversion" : 1, 4 | "appversion" : { 5 | "major" : 7, 6 | "minor" : 0, 7 | "revision" : 4, 8 | "architecture" : "x86", 9 | "modernui" : 1 10 | } 11 | , 12 | "rect" : [ 130.0, 174.0, 983.0, 623.0 ], 13 | "bglocked" : 0, 14 | "openinpresentation" : 0, 15 | "default_fontsize" : 12.0, 16 | "default_fontface" : 0, 17 | "default_fontname" : "Arial", 18 | "gridonopen" : 1, 19 | "gridsize" : [ 15.0, 15.0 ], 20 | "gridsnaponopen" : 1, 21 | "objectsnaponopen" : 1, 22 | "statusbarvisible" : 2, 23 | "toolbarvisible" : 1, 24 | "lefttoolbarpinned" : 0, 25 | "toptoolbarpinned" : 0, 26 | "righttoolbarpinned" : 0, 27 | "bottomtoolbarpinned" : 0, 28 | "toolbars_unpinned_last_save" : 0, 29 | "tallnewobj" : 0, 30 | "boxanimatetime" : 200, 31 | "enablehscroll" : 1, 32 | "enablevscroll" : 1, 33 | "devicewidth" : 0.0, 34 | "description" : "", 35 | "digest" : "", 36 | "tags" : "", 37 | "style" : "", 38 | "subpatcher_template" : "", 39 | "boxes" : [ { 40 | "box" : { 41 | "fontface" : 0, 42 | "fontsize" : 12.0, 43 | "id" : "obj-5", 44 | "maxclass" : "o.display", 45 | "numinlets" : 1, 46 | "numoutlets" : 1, 47 | "outlettype" : [ "" ], 48 | "patching_rect" : [ 141.0, 266.0, 150.0, 34.0 ], 49 | "textcolor" : [ 1.0, 1.0, 1.0, 1.0 ] 50 | } 51 | 52 | } 53 | , { 54 | "box" : { 55 | "fontface" : 0, 56 | "fontname" : "Arial", 57 | "fontsize" : 12.0, 58 | "id" : "obj-3", 59 | "linecount" : 6, 60 | "maxclass" : "o.display", 61 | "numinlets" : 1, 62 | "numoutlets" : 1, 63 | "outlettype" : [ "" ], 64 | "patching_rect" : [ 422.5, 125.0, 158.0, 101.0 ], 65 | "text" : "/port : \"usbmodemOSCes41\",\n/rate/output : 0,\n/rate/input : 0,\n/mediansize/received : -1,\n/baud", 66 | "textcolor" : [ 1.0, 1.0, 1.0, 1.0 ] 67 | } 68 | 69 | } 70 | , { 71 | "box" : { 72 | "fontname" : "Arial", 73 | "fontsize" : 12.0, 74 | "id" : "obj-2", 75 | "linecount" : 2, 76 | "maxclass" : "comment", 77 | "numinlets" : 1, 78 | "numoutlets" : 0, 79 | "patching_rect" : [ 389.5, -32.5, 170.0, 33.0 ], 80 | "style" : "", 81 | "text" : "Look for your device in the menu list of serial USB" 82 | } 83 | 84 | } 85 | , { 86 | "box" : { 87 | "bgmode" : 0, 88 | "border" : 0, 89 | "clickthrough" : 0, 90 | "enablehscroll" : 0, 91 | "enablevscroll" : 0, 92 | "id" : "obj-7", 93 | "lockeddragscroll" : 0, 94 | "maxclass" : "bpatcher", 95 | "name" : "o.io.serial.display.maxpat", 96 | "numinlets" : 1, 97 | "numoutlets" : 1, 98 | "offset" : [ 3.0, 0.0 ], 99 | "outlettype" : [ "FullPacket" ], 100 | "patching_rect" : [ 81.5, 29.0, 340.5, 25.0 ], 101 | "viewvisibility" : 1 102 | } 103 | 104 | } 105 | , { 106 | "box" : { 107 | "fontname" : "Arial", 108 | "fontsize" : 12.0, 109 | "id" : "obj-23", 110 | "maxclass" : "newobj", 111 | "numinlets" : 2, 112 | "numoutlets" : 2, 113 | "outlettype" : [ "FullPacket", "FullPacket" ], 114 | "patching_rect" : [ 20.5, 68.0, 80.0, 22.0 ], 115 | "style" : "", 116 | "text" : "o.io.slipserial" 117 | } 118 | 119 | } 120 | , { 121 | "box" : { 122 | "fontname" : "Andale Mono", 123 | "fontsize" : 14.0, 124 | "id" : "obj-11", 125 | "linecount" : 3, 126 | "maxclass" : "comment", 127 | "numinlets" : 1, 128 | "numoutlets" : 0, 129 | "patching_rect" : [ 471.0, 29.0, 150.0, 54.0 ], 130 | "style" : "", 131 | "text" : "stats on serial OSC communications" 132 | } 133 | 134 | } 135 | , { 136 | "box" : { 137 | "fontface" : 0, 138 | "fontsize" : 12.0, 139 | "id" : "obj-6", 140 | "maxclass" : "o.display", 141 | "numinlets" : 1, 142 | "numoutlets" : 1, 143 | "outlettype" : [ "" ], 144 | "patching_rect" : [ 214.0, 285.0, 150.0, 34.0 ], 145 | "textcolor" : [ 1.0, 1.0, 1.0, 1.0 ] 146 | } 147 | 148 | } 149 | , { 150 | "box" : { 151 | "fontface" : 0, 152 | "fontsize" : 12.0, 153 | "id" : "obj-4", 154 | "maxclass" : "o.display", 155 | "numinlets" : 1, 156 | "numoutlets" : 1, 157 | "outlettype" : [ "" ], 158 | "patching_rect" : [ 23.0, 285.0, 150.0, 34.0 ], 159 | "textcolor" : [ 1.0, 1.0, 1.0, 1.0 ] 160 | } 161 | 162 | } 163 | , { 164 | "box" : { 165 | "fontname" : "Arial", 166 | "fontsize" : 12.0, 167 | "id" : "obj-1", 168 | "maxclass" : "newobj", 169 | "numinlets" : 1, 170 | "numoutlets" : 3, 171 | "outlettype" : [ "", "", "FullPacket" ], 172 | "patching_rect" : [ 23.0, 176.0, 119.0, 22.0 ], 173 | "style" : "", 174 | "text" : "o.route /raw /cooked" 175 | } 176 | 177 | } 178 | ], 179 | "lines" : [ { 180 | "patchline" : { 181 | "destination" : [ "obj-4", 0 ], 182 | "disabled" : 0, 183 | "hidden" : 0, 184 | "source" : [ "obj-1", 0 ] 185 | } 186 | 187 | } 188 | , { 189 | "patchline" : { 190 | "destination" : [ "obj-6", 0 ], 191 | "disabled" : 0, 192 | "hidden" : 0, 193 | "source" : [ "obj-1", 1 ] 194 | } 195 | 196 | } 197 | , { 198 | "patchline" : { 199 | "destination" : [ "obj-1", 0 ], 200 | "disabled" : 0, 201 | "hidden" : 0, 202 | "source" : [ "obj-23", 0 ] 203 | } 204 | 205 | } 206 | , { 207 | "patchline" : { 208 | "color" : [ 1.0, 0.8, 0.4, 1.0 ], 209 | "destination" : [ "obj-3", 0 ], 210 | "disabled" : 0, 211 | "hidden" : 0, 212 | "midpoints" : [ 91.0, 109.0, 432.0, 109.0 ], 213 | "source" : [ "obj-23", 1 ] 214 | } 215 | 216 | } 217 | , { 218 | "patchline" : { 219 | "destination" : [ "obj-5", 0 ], 220 | "disabled" : 0, 221 | "hidden" : 0, 222 | "source" : [ "obj-23", 0 ] 223 | } 224 | 225 | } 226 | , { 227 | "patchline" : { 228 | "color" : [ 1.0, 0.8, 0.4, 1.0 ], 229 | "destination" : [ "obj-7", 0 ], 230 | "disabled" : 0, 231 | "hidden" : 0, 232 | "midpoints" : [ 91.0, 95.0, 433.0, 95.0, 433.0, 5.0, 91.0, 5.0 ], 233 | "source" : [ "obj-23", 1 ] 234 | } 235 | 236 | } 237 | , { 238 | "patchline" : { 239 | "color" : [ 1.0, 0.8, 0.4, 1.0 ], 240 | "destination" : [ "obj-23", 1 ], 241 | "disabled" : 0, 242 | "hidden" : 0, 243 | "source" : [ "obj-7", 0 ] 244 | } 245 | 246 | } 247 | ], 248 | "dependency_cache" : [ { 249 | "name" : "o.io.slipserial.maxpat", 250 | "bootpath" : "~/Documents/Max/Packages/o.io/experimental/Protocols/serial", 251 | "type" : "JSON", 252 | "implicit" : 1 253 | } 254 | , { 255 | "name" : "o.righttoleft.maxpat", 256 | "bootpath" : "~/Documents/Max/Packages/odot/patchers/ordering", 257 | "type" : "JSON", 258 | "implicit" : 1 259 | } 260 | , { 261 | "name" : "o.io.serial.display.maxpat", 262 | "bootpath" : "~/Documents/Max/Packages/o.io/experimental/Protocols/serial", 263 | "type" : "JSON", 264 | "implicit" : 1 265 | } 266 | , { 267 | "name" : "o.route.mxo", 268 | "type" : "iLaX" 269 | } 270 | , { 271 | "name" : "o.display.mxo", 272 | "type" : "iLaX" 273 | } 274 | , { 275 | "name" : "o.pack.mxo", 276 | "type" : "iLaX" 277 | } 278 | , { 279 | "name" : "o.union.mxo", 280 | "type" : "iLaX" 281 | } 282 | , { 283 | "name" : "o.validate.mxo", 284 | "type" : "iLaX" 285 | } 286 | , { 287 | "name" : "o.print.mxo", 288 | "type" : "iLaX" 289 | } 290 | , { 291 | "name" : "o.slip.encode.mxo", 292 | "type" : "iLaX" 293 | } 294 | , { 295 | "name" : "o.slip.decode.mxo", 296 | "type" : "iLaX" 297 | } 298 | , { 299 | "name" : "o.if.mxo", 300 | "type" : "iLaX" 301 | } 302 | ], 303 | "embedsnapshot" : 0 304 | } 305 | 306 | } 307 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/Applications/MaxMSP/examples/SerialEcho.maxpat: -------------------------------------------------------------------------------- 1 | { 2 | "patcher" : { 3 | "fileversion" : 1, 4 | "appversion" : { 5 | "major" : 6, 6 | "minor" : 1, 7 | "revision" : 6, 8 | "architecture" : "x86" 9 | } 10 | , 11 | "rect" : [ 608.0, 81.0, 1202.0, 749.0 ], 12 | "bglocked" : 0, 13 | "openinpresentation" : 0, 14 | "default_fontsize" : 14.0, 15 | "default_fontface" : 0, 16 | "default_fontname" : "Andale Mono", 17 | "gridonopen" : 0, 18 | "gridsize" : [ 5.0, 5.0 ], 19 | "gridsnaponopen" : 0, 20 | "statusbarvisible" : 2, 21 | "toolbarvisible" : 1, 22 | "boxanimatetime" : 200, 23 | "imprint" : 0, 24 | "enablehscroll" : 1, 25 | "enablevscroll" : 1, 26 | "devicewidth" : 0.0, 27 | "description" : "", 28 | "digest" : "", 29 | "tags" : "", 30 | "boxes" : [ { 31 | "box" : { 32 | "fontname" : "Andale Mono", 33 | "fontsize" : 14.0, 34 | "id" : "obj-1", 35 | "maxclass" : "newobj", 36 | "numinlets" : 1, 37 | "numoutlets" : 1, 38 | "outlettype" : [ "FullPacket" ], 39 | "patching_rect" : [ 218.0, 295.0, 95.0, 22.0 ], 40 | "text" : "o.downcast" 41 | } 42 | 43 | } 44 | , { 45 | "box" : { 46 | "fontname" : "Arial", 47 | "fontsize" : 12.0, 48 | "id" : "obj-18", 49 | "linecount" : 10, 50 | "maxclass" : "o.display", 51 | "numinlets" : 1, 52 | "numoutlets" : 1, 53 | "outlettype" : [ "" ], 54 | "patching_rect" : [ 28.5, 425.0, 267.0, 155.0 ], 55 | "text" : "/ping : 100,\n/thing : [2., 3.04, 1242., 23., \"thing\"],\n/stuff : [1, 2, 3, 4, 5],\n/fsakjfskfsdkasfk : [234, 242, 234, 234, 4],\n/decision : 1,\n/notdecision : 0,\n/micros : 616229100,\n/sequencenumber : 20557,\n/digital/5 : false,\n/lsb : false", 56 | "textcolor" : [ 0.0, 0.0, 0.0, 1.0 ] 57 | } 58 | 59 | } 60 | , { 61 | "box" : { 62 | "fontname" : "Arial", 63 | "fontsize" : 12.0, 64 | "id" : "obj-3", 65 | "linecount" : 5, 66 | "maxclass" : "o.display", 67 | "numinlets" : 1, 68 | "numoutlets" : 1, 69 | "outlettype" : [ "" ], 70 | "patching_rect" : [ 404.5, 425.0, 158.0, 88.0 ], 71 | "text" : "/port : \"usbmodem12341\",\n/rate/output : 32,\n/rate/input : 39,\n/mediansize/received : -1,\n/baud", 72 | "textcolor" : [ 0.0, 0.0, 0.0, 1.0 ] 73 | } 74 | 75 | } 76 | , { 77 | "box" : { 78 | "fontname" : "Arial", 79 | "fontsize" : 12.0, 80 | "frgb" : 0.0, 81 | "id" : "obj-19", 82 | "linecount" : 2, 83 | "maxclass" : "comment", 84 | "numinlets" : 1, 85 | "numoutlets" : 0, 86 | "patching_rect" : [ 424.5, 269.5, 170.0, 33.0 ], 87 | "text" : "Look for your device in the menu list of serial USB" 88 | } 89 | 90 | } 91 | , { 92 | "box" : { 93 | "id" : "obj-20", 94 | "maxclass" : "bpatcher", 95 | "name" : "o.io.serial.display.maxpat", 96 | "numinlets" : 1, 97 | "numoutlets" : 1, 98 | "offset" : [ 3.0, 0.0 ], 99 | "outlettype" : [ "FullPacket" ], 100 | "patching_rect" : [ 404.5, 340.0, 164.0, 24.0 ] 101 | } 102 | 103 | } 104 | , { 105 | "box" : { 106 | "fontname" : "Arial", 107 | "fontsize" : 12.0, 108 | "id" : "obj-23", 109 | "maxclass" : "newobj", 110 | "numinlets" : 2, 111 | "numoutlets" : 2, 112 | "outlettype" : [ "FullPacket", "FullPacket" ], 113 | "patching_rect" : [ 343.5, 379.0, 80.0, 20.0 ], 114 | "text" : "o.io.slipserial" 115 | } 116 | 117 | } 118 | , { 119 | "box" : { 120 | "fontname" : "Andale Mono", 121 | "fontsize" : 14.0, 122 | "id" : "obj-2", 123 | "linecount" : 6, 124 | "maxclass" : "o.compose", 125 | "numinlets" : 2, 126 | "numoutlets" : 1, 127 | "outlettype" : [ "" ], 128 | "patching_rect" : [ 45.0, 90.166656, 964.0, 105.0 ], 129 | "text" : "/ping : 100,\n/thing : [2., 3.04, 1242., 23., \"thing\"],\n/stuff : [1, 2, 3, 4, 5],\n/fsakjfskfsdkasfk : [234, 242, 234, 234, 4],\n/decision : true,\n/notdecision : false", 130 | "textcolor" : [ 0.0, 0.0, 0.0, 1.0 ] 131 | } 132 | 133 | } 134 | , { 135 | "box" : { 136 | "fontname" : "Andale Mono", 137 | "fontsize" : 14.0, 138 | "frgb" : 0.0, 139 | "id" : "obj-4", 140 | "linecount" : 3, 141 | "maxclass" : "comment", 142 | "numinlets" : 1, 143 | "numoutlets" : 0, 144 | "patching_rect" : [ 595.0, 415.0, 150.0, 54.0 ], 145 | "text" : "stats on serial OSC communications" 146 | } 147 | 148 | } 149 | , { 150 | "box" : { 151 | "fontname" : "Andale Mono", 152 | "fontsize" : 14.0, 153 | "id" : "obj-61", 154 | "maxclass" : "newobj", 155 | "numinlets" : 2, 156 | "numoutlets" : 1, 157 | "outlettype" : [ "bang" ], 158 | "patching_rect" : [ 45.0, 38.166656, 162.0, 22.0 ], 159 | "text" : "metro 22 @active 1" 160 | } 161 | 162 | } 163 | ], 164 | "lines" : [ { 165 | "patchline" : { 166 | "color" : [ 1.0, 0.8, 0.4, 1.0 ], 167 | "destination" : [ "obj-23", 0 ], 168 | "disabled" : 0, 169 | "hidden" : 0, 170 | "source" : [ "obj-1", 0 ] 171 | } 172 | 173 | } 174 | , { 175 | "patchline" : { 176 | "color" : [ 1.0, 0.8, 0.4, 1.0 ], 177 | "destination" : [ "obj-1", 0 ], 178 | "disabled" : 0, 179 | "hidden" : 0, 180 | "source" : [ "obj-2", 0 ] 181 | } 182 | 183 | } 184 | , { 185 | "patchline" : { 186 | "color" : [ 1.0, 0.8, 0.4, 1.0 ], 187 | "destination" : [ "obj-23", 1 ], 188 | "disabled" : 0, 189 | "hidden" : 0, 190 | "source" : [ "obj-20", 0 ] 191 | } 192 | 193 | } 194 | , { 195 | "patchline" : { 196 | "color" : [ 1.0, 0.8, 0.4, 1.0 ], 197 | "destination" : [ "obj-18", 0 ], 198 | "disabled" : 0, 199 | "hidden" : 0, 200 | "source" : [ "obj-23", 0 ] 201 | } 202 | 203 | } 204 | , { 205 | "patchline" : { 206 | "color" : [ 1.0, 0.8, 0.4, 1.0 ], 207 | "destination" : [ "obj-20", 0 ], 208 | "disabled" : 0, 209 | "hidden" : 0, 210 | "midpoints" : [ 414.0, 406.0, 583.0, 406.0, 583.0, 316.0, 414.0, 316.0 ], 211 | "source" : [ "obj-23", 1 ] 212 | } 213 | 214 | } 215 | , { 216 | "patchline" : { 217 | "color" : [ 1.0, 0.8, 0.4, 1.0 ], 218 | "destination" : [ "obj-3", 0 ], 219 | "disabled" : 0, 220 | "hidden" : 0, 221 | "midpoints" : [ 414.0, 420.0, 414.0, 420.0 ], 222 | "source" : [ "obj-23", 1 ] 223 | } 224 | 225 | } 226 | , { 227 | "patchline" : { 228 | "destination" : [ "obj-2", 0 ], 229 | "disabled" : 0, 230 | "hidden" : 0, 231 | "source" : [ "obj-61", 0 ] 232 | } 233 | 234 | } 235 | ], 236 | "dependency_cache" : [ { 237 | "name" : "o.io.slipserial.maxpat", 238 | "bootpath" : "/Users/adrian2013/Documents/Max/Packages/CNMAT-MMJSS/patchers/esplora", 239 | "patcherrelativepath" : "../../../../../Documents/Max/Packages/CNMAT-MMJSS/patchers/esplora", 240 | "type" : "JSON", 241 | "implicit" : 1 242 | } 243 | , { 244 | "name" : "o.righttoleft.maxpat", 245 | "bootpath" : "/Users/adrian2013/Documents/Max/Packages/CNMAT-odot/patchers/ordering", 246 | "patcherrelativepath" : "../../../../../Documents/Max/Packages/CNMAT-odot/patchers/ordering", 247 | "type" : "JSON", 248 | "implicit" : 1 249 | } 250 | , { 251 | "name" : "o.io.serial.display.maxpat", 252 | "bootpath" : "/Users/adrian2013/Documents/Max/Packages/CNMAT-MMJSS/patchers/esplora", 253 | "patcherrelativepath" : "../../../../../Documents/Max/Packages/CNMAT-MMJSS/patchers/esplora", 254 | "type" : "JSON", 255 | "implicit" : 1 256 | } 257 | , { 258 | "name" : "o.compose.mxo", 259 | "type" : "iLaX" 260 | } 261 | , { 262 | "name" : "o.pack.mxo", 263 | "type" : "iLaX" 264 | } 265 | , { 266 | "name" : "o.route.mxo", 267 | "type" : "iLaX" 268 | } 269 | , { 270 | "name" : "o.union.mxo", 271 | "type" : "iLaX" 272 | } 273 | , { 274 | "name" : "o.validate.mxo", 275 | "type" : "iLaX" 276 | } 277 | , { 278 | "name" : "o.print.mxo", 279 | "type" : "iLaX" 280 | } 281 | , { 282 | "name" : "o.slip.encode.mxo", 283 | "type" : "iLaX" 284 | } 285 | , { 286 | "name" : "o.slip.decode.mxo", 287 | "type" : "iLaX" 288 | } 289 | , { 290 | "name" : "o.if.mxo", 291 | "type" : "iLaX" 292 | } 293 | , { 294 | "name" : "o.display.mxo", 295 | "type" : "iLaX" 296 | } 297 | , { 298 | "name" : "o.downcast.mxo", 299 | "type" : "iLaX" 300 | } 301 | ] 302 | } 303 | 304 | } 305 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/Applications/MaxMSP/examples/SerialReceivewithServo.maxpat: -------------------------------------------------------------------------------- 1 | { 2 | "patcher" : { 3 | "fileversion" : 1, 4 | "appversion" : { 5 | "major" : 7, 6 | "minor" : 0, 7 | "revision" : 4, 8 | "architecture" : "x86", 9 | "modernui" : 1 10 | } 11 | , 12 | "rect" : [ 125.0, 78.0, 1072.0, 480.0 ], 13 | "bglocked" : 0, 14 | "openinpresentation" : 0, 15 | "default_fontsize" : 12.0, 16 | "default_fontface" : 0, 17 | "default_fontname" : "Arial", 18 | "gridonopen" : 1, 19 | "gridsize" : [ 15.0, 15.0 ], 20 | "gridsnaponopen" : 1, 21 | "objectsnaponopen" : 1, 22 | "statusbarvisible" : 2, 23 | "toolbarvisible" : 1, 24 | "lefttoolbarpinned" : 0, 25 | "toptoolbarpinned" : 0, 26 | "righttoolbarpinned" : 0, 27 | "bottomtoolbarpinned" : 0, 28 | "toolbars_unpinned_last_save" : 0, 29 | "tallnewobj" : 0, 30 | "boxanimatetime" : 200, 31 | "enablehscroll" : 1, 32 | "enablevscroll" : 1, 33 | "devicewidth" : 0.0, 34 | "description" : "", 35 | "digest" : "", 36 | "tags" : "", 37 | "style" : "", 38 | "subpatcher_template" : "", 39 | "boxes" : [ { 40 | "box" : { 41 | "fontface" : 0, 42 | "fontname" : "Arial", 43 | "fontsize" : 12.0, 44 | "id" : "obj-12", 45 | "maxclass" : "o.display", 46 | "numinlets" : 1, 47 | "numoutlets" : 1, 48 | "outlettype" : [ "" ], 49 | "patching_rect" : [ 27.5, 386.0, 158.0, 34.0 ], 50 | "presentation_rect" : [ 534.5, 418.0, 0.0, 0.0 ], 51 | "textcolor" : [ 1.0, 1.0, 1.0, 1.0 ] 52 | } 53 | 54 | } 55 | , { 56 | "box" : { 57 | "id" : "obj-6", 58 | "maxclass" : "newobj", 59 | "numinlets" : 1, 60 | "numoutlets" : 1, 61 | "outlettype" : [ "FullPacket" ], 62 | "patching_rect" : [ 137.5, 194.0, 82.0, 22.0 ], 63 | "style" : "", 64 | "text" : "o.pack /servo" 65 | } 66 | 67 | } 68 | , { 69 | "box" : { 70 | "contdata" : 1, 71 | "id" : "obj-11", 72 | "maxclass" : "multislider", 73 | "numinlets" : 1, 74 | "numoutlets" : 2, 75 | "outlettype" : [ "", "" ], 76 | "parameter_enable" : 0, 77 | "patching_rect" : [ 139.0, 27.0, 20.0, 140.0 ], 78 | "setminmax" : [ 0.0, 180.0 ], 79 | "settype" : 0, 80 | "style" : "" 81 | } 82 | 83 | } 84 | , { 85 | "box" : { 86 | "fontface" : 0, 87 | "fontname" : "Arial", 88 | "fontsize" : 12.0, 89 | "id" : "obj-3", 90 | "maxclass" : "o.display", 91 | "numinlets" : 1, 92 | "numoutlets" : 1, 93 | "outlettype" : [ "" ], 94 | "patching_rect" : [ 198.5, 386.0, 158.0, 34.0 ], 95 | "textcolor" : [ 1.0, 1.0, 1.0, 1.0 ] 96 | } 97 | 98 | } 99 | , { 100 | "box" : { 101 | "fontname" : "Arial", 102 | "fontsize" : 12.0, 103 | "id" : "obj-1", 104 | "linecount" : 2, 105 | "maxclass" : "comment", 106 | "numinlets" : 1, 107 | "numoutlets" : 0, 108 | "patching_rect" : [ 218.5, 230.5, 170.0, 33.0 ], 109 | "style" : "", 110 | "text" : "Look for your device in the menu list of serial USB" 111 | } 112 | 113 | } 114 | , { 115 | "box" : { 116 | "bgmode" : 0, 117 | "border" : 0, 118 | "clickthrough" : 0, 119 | "enablehscroll" : 0, 120 | "enablevscroll" : 0, 121 | "id" : "obj-20", 122 | "lockeddragscroll" : 0, 123 | "maxclass" : "bpatcher", 124 | "name" : "o.io.serial.display.maxpat", 125 | "numinlets" : 1, 126 | "numoutlets" : 1, 127 | "offset" : [ 3.0, 0.0 ], 128 | "outlettype" : [ "FullPacket" ], 129 | "patching_rect" : [ 198.5, 301.0, 164.0, 24.0 ], 130 | "viewvisibility" : 1 131 | } 132 | 133 | } 134 | , { 135 | "box" : { 136 | "fontname" : "Arial", 137 | "fontsize" : 12.0, 138 | "id" : "obj-23", 139 | "maxclass" : "newobj", 140 | "numinlets" : 2, 141 | "numoutlets" : 2, 142 | "outlettype" : [ "FullPacket", "FullPacket" ], 143 | "patching_rect" : [ 137.5, 337.0, 80.0, 22.0 ], 144 | "style" : "", 145 | "text" : "o.io.slipserial" 146 | } 147 | 148 | } 149 | , { 150 | "box" : { 151 | "fontname" : "Andale Mono", 152 | "fontsize" : 14.0, 153 | "id" : "obj-5", 154 | "linecount" : 3, 155 | "maxclass" : "comment", 156 | "numinlets" : 1, 157 | "numoutlets" : 0, 158 | "patching_rect" : [ 389.0, 376.0, 150.0, 54.0 ], 159 | "style" : "", 160 | "text" : "stats on serial OSC communications" 161 | } 162 | 163 | } 164 | , { 165 | "box" : { 166 | "fontname" : "Arial", 167 | "fontsize" : 12.0, 168 | "id" : "obj-19", 169 | "maxclass" : "comment", 170 | "numinlets" : 1, 171 | "numoutlets" : 0, 172 | "patching_rect" : [ 335.0, 151.0, 156.0, 20.0 ], 173 | "style" : "", 174 | "text" : "Servo control (from 0-180)" 175 | } 176 | 177 | } 178 | ], 179 | "lines" : [ { 180 | "patchline" : { 181 | "destination" : [ "obj-6", 0 ], 182 | "disabled" : 0, 183 | "hidden" : 0, 184 | "source" : [ "obj-11", 0 ] 185 | } 186 | 187 | } 188 | , { 189 | "patchline" : { 190 | "color" : [ 1.0, 0.8, 0.4, 1.0 ], 191 | "destination" : [ "obj-23", 1 ], 192 | "disabled" : 0, 193 | "hidden" : 0, 194 | "source" : [ "obj-20", 0 ] 195 | } 196 | 197 | } 198 | , { 199 | "patchline" : { 200 | "destination" : [ "obj-12", 0 ], 201 | "disabled" : 0, 202 | "hidden" : 0, 203 | "source" : [ "obj-23", 0 ] 204 | } 205 | 206 | } 207 | , { 208 | "patchline" : { 209 | "color" : [ 1.0, 0.8, 0.4, 1.0 ], 210 | "destination" : [ "obj-20", 0 ], 211 | "disabled" : 0, 212 | "hidden" : 0, 213 | "midpoints" : [ 208.0, 367.0, 377.0, 367.0, 377.0, 277.0, 208.0, 277.0 ], 214 | "source" : [ "obj-23", 1 ] 215 | } 216 | 217 | } 218 | , { 219 | "patchline" : { 220 | "color" : [ 1.0, 0.8, 0.4, 1.0 ], 221 | "destination" : [ "obj-3", 0 ], 222 | "disabled" : 0, 223 | "hidden" : 0, 224 | "midpoints" : [ 208.0, 381.0, 208.0, 381.0 ], 225 | "source" : [ "obj-23", 1 ] 226 | } 227 | 228 | } 229 | , { 230 | "patchline" : { 231 | "destination" : [ "obj-23", 0 ], 232 | "disabled" : 0, 233 | "hidden" : 0, 234 | "source" : [ "obj-6", 0 ] 235 | } 236 | 237 | } 238 | ], 239 | "dependency_cache" : [ { 240 | "name" : "o.io.slipserial.maxpat", 241 | "bootpath" : "~/Documents/Max/Packages/o.io/experimental/Protocols/serial", 242 | "type" : "JSON", 243 | "implicit" : 1 244 | } 245 | , { 246 | "name" : "o.righttoleft.maxpat", 247 | "bootpath" : "~/Documents/Max/Packages/odot/patchers/ordering", 248 | "type" : "JSON", 249 | "implicit" : 1 250 | } 251 | , { 252 | "name" : "o.io.serial.display.maxpat", 253 | "bootpath" : "~/Documents/Max/Packages/o.io/experimental/Protocols/serial", 254 | "type" : "JSON", 255 | "implicit" : 1 256 | } 257 | , { 258 | "name" : "o.pack.mxo", 259 | "type" : "iLaX" 260 | } 261 | , { 262 | "name" : "o.route.mxo", 263 | "type" : "iLaX" 264 | } 265 | , { 266 | "name" : "o.union.mxo", 267 | "type" : "iLaX" 268 | } 269 | , { 270 | "name" : "o.validate.mxo", 271 | "type" : "iLaX" 272 | } 273 | , { 274 | "name" : "o.print.mxo", 275 | "type" : "iLaX" 276 | } 277 | , { 278 | "name" : "o.slip.encode.mxo", 279 | "type" : "iLaX" 280 | } 281 | , { 282 | "name" : "o.slip.decode.mxo", 283 | "type" : "iLaX" 284 | } 285 | , { 286 | "name" : "o.if.mxo", 287 | "type" : "iLaX" 288 | } 289 | , { 290 | "name" : "o.display.mxo", 291 | "type" : "iLaX" 292 | } 293 | ], 294 | "embedsnapshot" : 0 295 | } 296 | 297 | } 298 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/Applications/MaxMSP/examples/SerialSend.maxpat: -------------------------------------------------------------------------------- 1 | { 2 | "patcher" : { 3 | "fileversion" : 1, 4 | "appversion" : { 5 | "major" : 6, 6 | "minor" : 1, 7 | "revision" : 9, 8 | "architecture" : "x86" 9 | } 10 | , 11 | "rect" : [ 196.0, 152.0, 1072.0, 480.0 ], 12 | "bglocked" : 0, 13 | "openinpresentation" : 0, 14 | "default_fontsize" : 12.0, 15 | "default_fontface" : 0, 16 | "default_fontname" : "Arial", 17 | "gridonopen" : 0, 18 | "gridsize" : [ 15.0, 15.0 ], 19 | "gridsnaponopen" : 0, 20 | "statusbarvisible" : 2, 21 | "toolbarvisible" : 1, 22 | "boxanimatetime" : 200, 23 | "imprint" : 0, 24 | "enablehscroll" : 1, 25 | "enablevscroll" : 1, 26 | "devicewidth" : 0.0, 27 | "description" : "", 28 | "digest" : "", 29 | "tags" : "", 30 | "boxes" : [ { 31 | "box" : { 32 | "fontsize" : 12.0, 33 | "id" : "obj-8", 34 | "maxclass" : "o.display", 35 | "numinlets" : 1, 36 | "numoutlets" : 1, 37 | "outlettype" : [ "" ], 38 | "patching_rect" : [ 572.0, 228.0, 207.0, 34.0 ], 39 | "textcolor" : [ 0.0, 0.0, 0.0, 1.0 ] 40 | } 41 | 42 | } 43 | , { 44 | "box" : { 45 | "fontsize" : 12.0, 46 | "id" : "obj-6", 47 | "maxclass" : "o.display", 48 | "numinlets" : 1, 49 | "numoutlets" : 1, 50 | "outlettype" : [ "" ], 51 | "patching_rect" : [ 95.0, 228.0, 394.0, 34.0 ], 52 | "textcolor" : [ 0.0, 0.0, 0.0, 1.0 ] 53 | } 54 | 55 | } 56 | , { 57 | "box" : { 58 | "fontsize" : 12.0, 59 | "id" : "obj-9", 60 | "maxclass" : "o.expr.codebox", 61 | "numinlets" : 1, 62 | "numoutlets" : 2, 63 | "outlettype" : [ "FullPacket", "FullPacket" ], 64 | "patching_rect" : [ 95.0, 172.0, 251.0, 37.0 ], 65 | "text" : " /bundle/time = gettimetag()", 66 | "textcolor" : [ 0.0, 0.0, 0.0, 1.0 ] 67 | } 68 | 69 | } 70 | , { 71 | "box" : { 72 | "id" : "obj-7", 73 | "maxclass" : "bpatcher", 74 | "name" : "o.io.serial.display.maxpat", 75 | "numinlets" : 1, 76 | "numoutlets" : 1, 77 | "outlettype" : [ "FullPacket" ], 78 | "patching_rect" : [ 271.0, 58.0, 331.0, 28.0 ] 79 | } 80 | 81 | } 82 | , { 83 | "box" : { 84 | "fontname" : "Andale Mono", 85 | "fontsize" : 14.0, 86 | "frgb" : 0.0, 87 | "id" : "obj-4", 88 | "linecount" : 3, 89 | "maxclass" : "comment", 90 | "numinlets" : 1, 91 | "numoutlets" : 0, 92 | "patching_rect" : [ 592.0, 119.0, 150.0, 54.0 ], 93 | "text" : "stats on serial OSC communications" 94 | } 95 | 96 | } 97 | , { 98 | "box" : { 99 | "fontname" : "Andale Mono", 100 | "fontsize" : 14.0, 101 | "id" : "obj-26", 102 | "maxclass" : "newobj", 103 | "numinlets" : 2, 104 | "numoutlets" : 2, 105 | "outlettype" : [ "FullPacket", "FullPacket" ], 106 | "patching_rect" : [ 95.0, 119.0, 195.0, 22.0 ], 107 | "text" : "o.io.slipserial f 9600" 108 | } 109 | 110 | } 111 | ], 112 | "lines" : [ { 113 | "patchline" : { 114 | "color" : [ 1.0, 0.8, 0.4, 1.0 ], 115 | "destination" : [ "obj-7", 0 ], 116 | "disabled" : 0, 117 | "hidden" : 0, 118 | "midpoints" : [ 280.5, 141.0, 300.0, 141.0, 300.0, 96.0, 258.0, 96.0, 258.0, 54.0, 280.5, 54.0 ], 119 | "source" : [ "obj-26", 1 ] 120 | } 121 | 122 | } 123 | , { 124 | "patchline" : { 125 | "color" : [ 1.0, 0.8, 0.4, 1.0 ], 126 | "destination" : [ "obj-8", 0 ], 127 | "disabled" : 0, 128 | "hidden" : 0, 129 | "source" : [ "obj-26", 1 ] 130 | } 131 | 132 | } 133 | , { 134 | "patchline" : { 135 | "color" : [ 1.0, 0.8, 0.4, 1.0 ], 136 | "destination" : [ "obj-9", 0 ], 137 | "disabled" : 0, 138 | "hidden" : 0, 139 | "source" : [ "obj-26", 0 ] 140 | } 141 | 142 | } 143 | , { 144 | "patchline" : { 145 | "color" : [ 1.0, 0.8, 0.4, 1.0 ], 146 | "destination" : [ "obj-26", 1 ], 147 | "disabled" : 0, 148 | "hidden" : 0, 149 | "source" : [ "obj-7", 0 ] 150 | } 151 | 152 | } 153 | , { 154 | "patchline" : { 155 | "destination" : [ "obj-6", 0 ], 156 | "disabled" : 0, 157 | "hidden" : 0, 158 | "source" : [ "obj-9", 0 ] 159 | } 160 | 161 | } 162 | ], 163 | "dependency_cache" : [ { 164 | "name" : "o.io.slipserial.maxpat", 165 | "bootpath" : "/Users/adrian2013/Documents/Max/Packages/o.io/experimental/Protocols/serial", 166 | "patcherrelativepath" : "../../../../../../Documents/Max/Packages/o.io/experimental/Protocols/serial", 167 | "type" : "JSON", 168 | "implicit" : 1 169 | } 170 | , { 171 | "name" : "o.righttoleft.maxpat", 172 | "bootpath" : "/Users/adrian2013/Documents/Max/Packages/CNMAT-odot/patchers/ordering", 173 | "patcherrelativepath" : "../../../../../../Documents/Max/Packages/CNMAT-odot/patchers/ordering", 174 | "type" : "JSON", 175 | "implicit" : 1 176 | } 177 | , { 178 | "name" : "o.io.serial.display.maxpat", 179 | "bootpath" : "/Users/adrian2013/Documents/Max/Packages/o.io/experimental/Protocols/serial", 180 | "patcherrelativepath" : "../../../../../../Documents/Max/Packages/o.io/experimental/Protocols/serial", 181 | "type" : "JSON", 182 | "implicit" : 1 183 | } 184 | , { 185 | "name" : "o.pack.mxo", 186 | "type" : "iLaX" 187 | } 188 | , { 189 | "name" : "o.route.mxo", 190 | "type" : "iLaX" 191 | } 192 | , { 193 | "name" : "o.union.mxo", 194 | "type" : "iLaX" 195 | } 196 | , { 197 | "name" : "o.validate.mxo", 198 | "type" : "iLaX" 199 | } 200 | , { 201 | "name" : "o.print.mxo", 202 | "type" : "iLaX" 203 | } 204 | , { 205 | "name" : "o.slip.encode.mxo", 206 | "type" : "iLaX" 207 | } 208 | , { 209 | "name" : "o.slip.decode.mxo", 210 | "type" : "iLaX" 211 | } 212 | , { 213 | "name" : "o.if.mxo", 214 | "type" : "iLaX" 215 | } 216 | , { 217 | "name" : "o.expr.codebox.mxo", 218 | "type" : "iLaX" 219 | } 220 | , { 221 | "name" : "o.display.mxo", 222 | "type" : "iLaX" 223 | } 224 | ] 225 | } 226 | 227 | } 228 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/Applications/MaxMSP/examples/UDPEcho.maxpat: -------------------------------------------------------------------------------- 1 | { 2 | "patcher" : { 3 | "fileversion" : 1, 4 | "appversion" : { 5 | "major" : 6, 6 | "minor" : 1, 7 | "revision" : 9, 8 | "architecture" : "x86" 9 | } 10 | , 11 | "rect" : [ 153.0, 100.0, 758.0, 531.0 ], 12 | "bglocked" : 0, 13 | "openinpresentation" : 0, 14 | "default_fontsize" : 14.0, 15 | "default_fontface" : 0, 16 | "default_fontname" : "Andale Mono", 17 | "gridonopen" : 0, 18 | "gridsize" : [ 5.0, 5.0 ], 19 | "gridsnaponopen" : 0, 20 | "statusbarvisible" : 2, 21 | "toolbarvisible" : 1, 22 | "boxanimatetime" : 200, 23 | "imprint" : 0, 24 | "enablehscroll" : 1, 25 | "enablevscroll" : 1, 26 | "devicewidth" : 0.0, 27 | "description" : "", 28 | "digest" : "", 29 | "tags" : "", 30 | "boxes" : [ { 31 | "box" : { 32 | "fontname" : "Andale Mono", 33 | "fontsize" : 14.0, 34 | "id" : "obj-8", 35 | "maxclass" : "newobj", 36 | "numinlets" : 1, 37 | "numoutlets" : 1, 38 | "outlettype" : [ "FullPacket" ], 39 | "patching_rect" : [ 20.5, 240.0, 128.0, 22.0 ], 40 | "text" : "o.betweentimes" 41 | } 42 | 43 | } 44 | , { 45 | "box" : { 46 | "fontsize" : 14.0, 47 | "id" : "obj-7", 48 | "linecount" : 2, 49 | "maxclass" : "o.compose", 50 | "numinlets" : 2, 51 | "numoutlets" : 1, 52 | "outlettype" : [ "" ], 53 | "patching_rect" : [ 20.5, 112.0, 510.0, 42.0 ], 54 | "saved_bundle_data" : [ 35, 98, 117, 110, 100, 108, 101, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 47, 112, 105, 110, 103, 0, 0, 0, 44, 105, 0, 0, 0, 0, 0, 100, 0, 0, 0, 76, 47, 116, 104, 105, 110, 103, 0, 0, 44, 100, 105, 105, 105, 105, 105, 105, 105, 105, 115, 0, 64, 89, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 4, 98, 105, 103, 103, 101, 114, 32, 112, 97, 99, 107, 101, 116, 0, 0, 0 ], 55 | "saved_bundle_length" : 116, 56 | "text" : "/ping : 100,\n/thing : [100., 100, 1, 2, 3, 4, 4, 4, 4, \"bigger packet\"]", 57 | "textcolor" : [ 0.0, 0.0, 0.0, 1.0 ] 58 | } 59 | 60 | } 61 | , { 62 | "box" : { 63 | "fontsize" : 14.0, 64 | "id" : "obj-5", 65 | "maxclass" : "o.display", 66 | "numinlets" : 1, 67 | "numoutlets" : 1, 68 | "outlettype" : [ "" ], 69 | "patching_rect" : [ 20.5, 296.0, 517.0, 36.0 ], 70 | "textcolor" : [ 0.0, 0.0, 0.0, 1.0 ] 71 | } 72 | 73 | } 74 | , { 75 | "box" : { 76 | "fontname" : "Andale Mono", 77 | "fontsize" : 14.0, 78 | "id" : "obj-61", 79 | "maxclass" : "newobj", 80 | "numinlets" : 2, 81 | "numoutlets" : 1, 82 | "outlettype" : [ "bang" ], 83 | "patching_rect" : [ 20.5, 22.0, 153.0, 22.0 ], 84 | "text" : "metro 2 @active 1" 85 | } 86 | 87 | } 88 | , { 89 | "box" : { 90 | "fontname" : "Andale Mono", 91 | "fontsize" : 14.0, 92 | "id" : "obj-26", 93 | "maxclass" : "newobj", 94 | "numinlets" : 1, 95 | "numoutlets" : 1, 96 | "outlettype" : [ "" ], 97 | "patching_rect" : [ 20.5, 191.0, 288.0, 22.0 ], 98 | "text" : "o.io.udp 128.32.122.252 8888 9999" 99 | } 100 | 101 | } 102 | ], 103 | "lines" : [ { 104 | "patchline" : { 105 | "color" : [ 1.0, 0.8, 0.4, 1.0 ], 106 | "destination" : [ "obj-8", 0 ], 107 | "disabled" : 0, 108 | "hidden" : 0, 109 | "source" : [ "obj-26", 0 ] 110 | } 111 | 112 | } 113 | , { 114 | "patchline" : { 115 | "color" : [ 1.0, 0.8, 0.4, 1.0 ], 116 | "destination" : [ "obj-7", 0 ], 117 | "disabled" : 0, 118 | "hidden" : 0, 119 | "source" : [ "obj-61", 0 ] 120 | } 121 | 122 | } 123 | , { 124 | "patchline" : { 125 | "color" : [ 1.0, 0.8, 0.4, 1.0 ], 126 | "destination" : [ "obj-26", 0 ], 127 | "disabled" : 0, 128 | "hidden" : 0, 129 | "source" : [ "obj-7", 0 ] 130 | } 131 | 132 | } 133 | , { 134 | "patchline" : { 135 | "color" : [ 1.0, 0.8, 0.4, 1.0 ], 136 | "destination" : [ "obj-5", 0 ], 137 | "disabled" : 0, 138 | "hidden" : 0, 139 | "source" : [ "obj-8", 0 ] 140 | } 141 | 142 | } 143 | ], 144 | "dependency_cache" : [ { 145 | "name" : "o.io.udp.maxpat", 146 | "bootpath" : "/Users/adrian2013/Documents/Max/Packages/o.io/experimental/Protocols/udp", 147 | "patcherrelativepath" : "../../../../../../Documents/Max/Packages/o.io/experimental/Protocols/udp", 148 | "type" : "JSON", 149 | "implicit" : 1 150 | } 151 | , { 152 | "name" : "o.betweentimes.maxpat", 153 | "bootpath" : "/Users/adrian2013/Documents/Max/Packages/CNMAT-odot/patchers/time", 154 | "patcherrelativepath" : "../../../../../../Documents/Max/Packages/CNMAT-odot/patchers/time", 155 | "type" : "JSON", 156 | "implicit" : 1 157 | } 158 | , { 159 | "name" : "o.was.maxpat", 160 | "bootpath" : "/Users/adrian2013/Documents/Max/Packages/CNMAT-odot/dev", 161 | "patcherrelativepath" : "../../../../../../Documents/Max/Packages/CNMAT-odot/dev", 162 | "type" : "JSON", 163 | "implicit" : 1 164 | } 165 | , { 166 | "name" : "o.righttoleft.maxpat", 167 | "bootpath" : "/Users/adrian2013/Documents/Max/Packages/CNMAT-odot/patchers/ordering", 168 | "patcherrelativepath" : "../../../../../../Documents/Max/Packages/CNMAT-odot/patchers/ordering", 169 | "type" : "JSON", 170 | "implicit" : 1 171 | } 172 | , { 173 | "name" : "o.display.mxo", 174 | "type" : "iLaX" 175 | } 176 | , { 177 | "name" : "o.compose.mxo", 178 | "type" : "iLaX" 179 | } 180 | , { 181 | "name" : "o.timetag.mxo", 182 | "type" : "iLaX" 183 | } 184 | , { 185 | "name" : "o.prepend.mxo", 186 | "type" : "iLaX" 187 | } 188 | , { 189 | "name" : "o.intersection.mxo", 190 | "type" : "iLaX" 191 | } 192 | , { 193 | "name" : "o.union.mxo", 194 | "type" : "iLaX" 195 | } 196 | , { 197 | "name" : "o.var.mxo", 198 | "type" : "iLaX" 199 | } 200 | , { 201 | "name" : "o.collect.mxo", 202 | "type" : "iLaX" 203 | } 204 | , { 205 | "name" : "o.if.mxo", 206 | "type" : "iLaX" 207 | } 208 | , { 209 | "name" : "o.expr.codebox.mxo", 210 | "type" : "iLaX" 211 | } 212 | ] 213 | } 214 | 215 | } 216 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/Applications/MaxMSP/examples/UDPReceive.maxpat: -------------------------------------------------------------------------------- 1 | { 2 | "patcher" : { 3 | "fileversion" : 1, 4 | "appversion" : { 5 | "major" : 7, 6 | "minor" : 0, 7 | "revision" : 4, 8 | "architecture" : "x86", 9 | "modernui" : 1 10 | } 11 | , 12 | "rect" : [ 334.0, 78.0, 1072.0, 480.0 ], 13 | "bglocked" : 0, 14 | "openinpresentation" : 0, 15 | "default_fontsize" : 12.0, 16 | "default_fontface" : 0, 17 | "default_fontname" : "Arial", 18 | "gridonopen" : 1, 19 | "gridsize" : [ 15.0, 15.0 ], 20 | "gridsnaponopen" : 1, 21 | "objectsnaponopen" : 1, 22 | "statusbarvisible" : 2, 23 | "toolbarvisible" : 1, 24 | "lefttoolbarpinned" : 0, 25 | "toptoolbarpinned" : 0, 26 | "righttoolbarpinned" : 0, 27 | "bottomtoolbarpinned" : 0, 28 | "toolbars_unpinned_last_save" : 0, 29 | "tallnewobj" : 0, 30 | "boxanimatetime" : 200, 31 | "enablehscroll" : 1, 32 | "enablevscroll" : 1, 33 | "devicewidth" : 0.0, 34 | "description" : "", 35 | "digest" : "", 36 | "tags" : "", 37 | "style" : "", 38 | "subpatcher_template" : "", 39 | "boxes" : [ { 40 | "box" : { 41 | "fontface" : 0, 42 | "fontsize" : 12.0, 43 | "id" : "obj-5", 44 | "maxclass" : "o.display", 45 | "numinlets" : 1, 46 | "numoutlets" : 1, 47 | "outlettype" : [ "" ], 48 | "patching_rect" : [ 183.5, 341.0, 150.0, 34.0 ], 49 | "textcolor" : [ 1.0, 1.0, 1.0, 1.0 ] 50 | } 51 | 52 | } 53 | , { 54 | "box" : { 55 | "fontname" : "Arial", 56 | "fontsize" : 12.0, 57 | "id" : "obj-18", 58 | "linecount" : 2, 59 | "maxclass" : "comment", 60 | "numinlets" : 1, 61 | "numoutlets" : 0, 62 | "patching_rect" : [ 498.0, 91.0, 150.0, 33.0 ], 63 | "style" : "", 64 | "text" : "control Arduino square wave tone on pin 3" 65 | } 66 | 67 | } 68 | , { 69 | "box" : { 70 | "fontface" : 0, 71 | "fontname" : "Andale Mono", 72 | "fontsize" : 14.0, 73 | "id" : "obj-15", 74 | "maxclass" : "o.message", 75 | "numinlets" : 2, 76 | "numoutlets" : 1, 77 | "outlettype" : [ "" ], 78 | "patching_rect" : [ 406.0, 168.0, 150.0, 22.0 ], 79 | "text" : "/tone/3", 80 | "textcolor" : [ 0.0, 0.0, 0.0, 1.0 ] 81 | } 82 | 83 | } 84 | , { 85 | "box" : { 86 | "fontname" : "Arial", 87 | "fontsize" : 12.0, 88 | "id" : "obj-12", 89 | "maxclass" : "newobj", 90 | "numinlets" : 1, 91 | "numoutlets" : 1, 92 | "outlettype" : [ "" ], 93 | "patching_rect" : [ 134.0, 127.0, 34.0, 22.0 ], 94 | "style" : "", 95 | "text" : "mtof" 96 | } 97 | 98 | } 99 | , { 100 | "box" : { 101 | "id" : "obj-11", 102 | "maxclass" : "kslider", 103 | "numinlets" : 2, 104 | "numoutlets" : 2, 105 | "outlettype" : [ "int", "int" ], 106 | "parameter_enable" : 0, 107 | "patching_rect" : [ 132.0, 65.0, 336.0, 53.0 ], 108 | "presentation_rect" : [ 0.0, 0.0, 336.0, 53.0 ], 109 | "style" : "", 110 | "varname" : "kslider" 111 | } 112 | 113 | } 114 | , { 115 | "box" : { 116 | "fontname" : "Arial", 117 | "fontsize" : 12.0, 118 | "id" : "obj-9", 119 | "maxclass" : "message", 120 | "numinlets" : 2, 121 | "numoutlets" : 1, 122 | "outlettype" : [ "" ], 123 | "patching_rect" : [ 242.0, 140.0, 32.5, 22.0 ], 124 | "style" : "", 125 | "text" : "220" 126 | } 127 | 128 | } 129 | , { 130 | "box" : { 131 | "fontname" : "Arial", 132 | "fontsize" : 12.0, 133 | "id" : "obj-8", 134 | "maxclass" : "message", 135 | "numinlets" : 2, 136 | "numoutlets" : 1, 137 | "outlettype" : [ "" ], 138 | "patching_rect" : [ 184.0, 137.0, 34.0, 22.0 ], 139 | "style" : "", 140 | "text" : "440." 141 | } 142 | 143 | } 144 | , { 145 | "box" : { 146 | "id" : "obj-4", 147 | "maxclass" : "button", 148 | "numinlets" : 1, 149 | "numoutlets" : 1, 150 | "outlettype" : [ "bang" ], 151 | "patching_rect" : [ 402.0, 137.0, 20.0, 20.0 ], 152 | "style" : "" 153 | } 154 | 155 | } 156 | , { 157 | "box" : { 158 | "fontname" : "Arial", 159 | "fontsize" : 12.0, 160 | "id" : "obj-3", 161 | "linecount" : 3, 162 | "maxclass" : "comment", 163 | "numinlets" : 1, 164 | "numoutlets" : 0, 165 | "patching_rect" : [ 489.0, 279.0, 154.0, 47.0 ], 166 | "style" : "", 167 | "text" : "8888 is the port sent to on the Arduino node 128.32.122.252" 168 | } 169 | 170 | } 171 | , { 172 | "box" : { 173 | "fontface" : 0, 174 | "fontname" : "Andale Mono", 175 | "fontsize" : 14.0, 176 | "id" : "obj-20", 177 | "maxclass" : "o.message", 178 | "numinlets" : 2, 179 | "numoutlets" : 1, 180 | "outlettype" : [ "" ], 181 | "patching_rect" : [ 235.0, 234.0, 150.0, 22.0 ], 182 | "text" : "/tone/3 130.813 \n", 183 | "textcolor" : [ 0.0, 0.0, 0.0, 1.0 ] 184 | } 185 | 186 | } 187 | , { 188 | "box" : { 189 | "fontface" : 0, 190 | "fontname" : "Andale Mono", 191 | "fontsize" : 14.0, 192 | "id" : "obj-6", 193 | "maxclass" : "o.message", 194 | "numinlets" : 2, 195 | "numoutlets" : 1, 196 | "outlettype" : [ "" ], 197 | "patching_rect" : [ 185.0, 191.0, 150.0, 22.0 ], 198 | "text" : "/tone/3 \"$1\" ", 199 | "textcolor" : [ 0.0, 0.0, 0.0, 1.0 ] 200 | } 201 | 202 | } 203 | , { 204 | "box" : { 205 | "fontname" : "Andale Mono", 206 | "fontsize" : 14.0, 207 | "id" : "obj-26", 208 | "maxclass" : "newobj", 209 | "numinlets" : 1, 210 | "numoutlets" : 1, 211 | "outlettype" : [ "" ], 212 | "patching_rect" : [ 183.5, 290.0, 288.0, 24.0 ], 213 | "style" : "", 214 | "text" : "o.io.udp 128.32.122.252 8888 9999" 215 | } 216 | 217 | } 218 | ], 219 | "lines" : [ { 220 | "patchline" : { 221 | "destination" : [ "obj-12", 0 ], 222 | "disabled" : 0, 223 | "hidden" : 0, 224 | "source" : [ "obj-11", 0 ] 225 | } 226 | 227 | } 228 | , { 229 | "patchline" : { 230 | "destination" : [ "obj-6", 0 ], 231 | "disabled" : 0, 232 | "hidden" : 0, 233 | "source" : [ "obj-12", 0 ] 234 | } 235 | 236 | } 237 | , { 238 | "patchline" : { 239 | "destination" : [ "obj-26", 0 ], 240 | "disabled" : 0, 241 | "hidden" : 0, 242 | "source" : [ "obj-15", 0 ] 243 | } 244 | 245 | } 246 | , { 247 | "patchline" : { 248 | "destination" : [ "obj-5", 0 ], 249 | "disabled" : 0, 250 | "hidden" : 0, 251 | "source" : [ "obj-26", 0 ] 252 | } 253 | 254 | } 255 | , { 256 | "patchline" : { 257 | "destination" : [ "obj-15", 0 ], 258 | "disabled" : 0, 259 | "hidden" : 0, 260 | "source" : [ "obj-4", 0 ] 261 | } 262 | 263 | } 264 | , { 265 | "patchline" : { 266 | "destination" : [ "obj-20", 1 ], 267 | "disabled" : 0, 268 | "hidden" : 0, 269 | "source" : [ "obj-6", 0 ] 270 | } 271 | 272 | } 273 | , { 274 | "patchline" : { 275 | "destination" : [ "obj-26", 0 ], 276 | "disabled" : 0, 277 | "hidden" : 0, 278 | "source" : [ "obj-6", 0 ] 279 | } 280 | 281 | } 282 | , { 283 | "patchline" : { 284 | "destination" : [ "obj-6", 0 ], 285 | "disabled" : 0, 286 | "hidden" : 0, 287 | "source" : [ "obj-8", 0 ] 288 | } 289 | 290 | } 291 | , { 292 | "patchline" : { 293 | "destination" : [ "obj-6", 0 ], 294 | "disabled" : 0, 295 | "hidden" : 0, 296 | "source" : [ "obj-9", 0 ] 297 | } 298 | 299 | } 300 | ], 301 | "dependency_cache" : [ { 302 | "name" : "o.io.udp.maxpat", 303 | "bootpath" : "~/Documents/Max/Packages/o.io/experimental/Protocols/udp", 304 | "type" : "JSON", 305 | "implicit" : 1 306 | } 307 | , { 308 | "name" : "o.message.mxo", 309 | "type" : "iLaX" 310 | } 311 | , { 312 | "name" : "o.display.mxo", 313 | "type" : "iLaX" 314 | } 315 | ], 316 | "embedsnapshot" : 0 317 | } 318 | 319 | } 320 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/Applications/MaxMSP/examples/UDPSend.maxpat: -------------------------------------------------------------------------------- 1 | { 2 | "patcher" : { 3 | "fileversion" : 1, 4 | "appversion" : { 5 | "major" : 7, 6 | "minor" : 0, 7 | "revision" : 4, 8 | "architecture" : "x86", 9 | "modernui" : 1 10 | } 11 | , 12 | "rect" : [ 443.0, 218.0, 1072.0, 480.0 ], 13 | "bglocked" : 0, 14 | "openinpresentation" : 0, 15 | "default_fontsize" : 12.0, 16 | "default_fontface" : 0, 17 | "default_fontname" : "Arial", 18 | "gridonopen" : 1, 19 | "gridsize" : [ 15.0, 15.0 ], 20 | "gridsnaponopen" : 1, 21 | "objectsnaponopen" : 1, 22 | "statusbarvisible" : 2, 23 | "toolbarvisible" : 1, 24 | "lefttoolbarpinned" : 0, 25 | "toptoolbarpinned" : 0, 26 | "righttoolbarpinned" : 0, 27 | "bottomtoolbarpinned" : 0, 28 | "toolbars_unpinned_last_save" : 0, 29 | "tallnewobj" : 0, 30 | "boxanimatetime" : 200, 31 | "enablehscroll" : 1, 32 | "enablevscroll" : 1, 33 | "devicewidth" : 0.0, 34 | "description" : "", 35 | "digest" : "", 36 | "tags" : "", 37 | "style" : "", 38 | "subpatcher_template" : "", 39 | "boxes" : [ { 40 | "box" : { 41 | "fontface" : 0, 42 | "fontsize" : 12.0, 43 | "id" : "obj-8", 44 | "maxclass" : "o.display", 45 | "numinlets" : 1, 46 | "numoutlets" : 1, 47 | "outlettype" : [ "" ], 48 | "patching_rect" : [ 277.0, 243.0, 150.0, 34.0 ], 49 | "textcolor" : [ 1.0, 1.0, 1.0, 1.0 ] 50 | } 51 | 52 | } 53 | , { 54 | "box" : { 55 | "fontface" : 0, 56 | "fontsize" : 12.0, 57 | "id" : "obj-6", 58 | "maxclass" : "o.display", 59 | "numinlets" : 1, 60 | "numoutlets" : 1, 61 | "outlettype" : [ "" ], 62 | "patching_rect" : [ 91.0, 243.0, 150.0, 34.0 ], 63 | "textcolor" : [ 1.0, 1.0, 1.0, 1.0 ] 64 | } 65 | 66 | } 67 | , { 68 | "box" : { 69 | "fontname" : "Arial", 70 | "fontsize" : 12.0, 71 | "id" : "obj-2", 72 | "maxclass" : "newobj", 73 | "numinlets" : 1, 74 | "numoutlets" : 2, 75 | "outlettype" : [ "FullPacket", "FullPacket" ], 76 | "patching_rect" : [ 91.0, 149.0, 97.0, 22.0 ], 77 | "style" : "", 78 | "text" : "o.if exists(/units)" 79 | } 80 | 81 | } 82 | , { 83 | "box" : { 84 | "fontname" : "Arial", 85 | "fontsize" : 12.0, 86 | "id" : "obj-4", 87 | "linecount" : 2, 88 | "maxclass" : "comment", 89 | "numinlets" : 1, 90 | "numoutlets" : 0, 91 | "patching_rect" : [ 95.0, 62.0, 150.0, 33.0 ], 92 | "style" : "", 93 | "text" : "Set udp port, send and receive port respectively" 94 | } 95 | 96 | } 97 | , { 98 | "box" : { 99 | "fontname" : "Andale Mono", 100 | "fontsize" : 14.0, 101 | "id" : "obj-26", 102 | "maxclass" : "newobj", 103 | "numinlets" : 1, 104 | "numoutlets" : 1, 105 | "outlettype" : [ "" ], 106 | "patching_rect" : [ 91.0, 107.0, 288.0, 24.0 ], 107 | "style" : "", 108 | "text" : "o.io.udp 128.32.122.26 8888 9999" 109 | } 110 | 111 | } 112 | ], 113 | "lines" : [ { 114 | "patchline" : { 115 | "destination" : [ "obj-6", 0 ], 116 | "disabled" : 0, 117 | "hidden" : 0, 118 | "source" : [ "obj-2", 0 ] 119 | } 120 | 121 | } 122 | , { 123 | "patchline" : { 124 | "destination" : [ "obj-8", 0 ], 125 | "disabled" : 0, 126 | "hidden" : 0, 127 | "source" : [ "obj-2", 1 ] 128 | } 129 | 130 | } 131 | , { 132 | "patchline" : { 133 | "destination" : [ "obj-2", 0 ], 134 | "disabled" : 0, 135 | "hidden" : 0, 136 | "source" : [ "obj-26", 0 ] 137 | } 138 | 139 | } 140 | ], 141 | "dependency_cache" : [ { 142 | "name" : "o.io.udp.maxpat", 143 | "bootpath" : "~/Documents/Max/Packages/o.io/experimental/Protocols/udp", 144 | "type" : "JSON", 145 | "implicit" : 1 146 | } 147 | , { 148 | "name" : "o.if.mxo", 149 | "type" : "iLaX" 150 | } 151 | , { 152 | "name" : "o.display.mxo", 153 | "type" : "iLaX" 154 | } 155 | ], 156 | "embedsnapshot" : 0 157 | } 158 | 159 | } 160 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/Applications/PD/SerialOscuino.pd: -------------------------------------------------------------------------------- 1 | #N canvas 616 22 1168 784 10; 2 | #X declare -lib mrpeach; 3 | #X obj 310 126 unpackOSC; 4 | #X obj 133 96 packOSC; 5 | #X msg 119 62 /a/*; 6 | #X obj 547 162 prepend set; 7 | #X msg 422 47 /s/a; 8 | #X msg 370 43 /s/d; 9 | #X msg 500 53 /s/m; 10 | #X obj 491 327 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 11 | 1; 12 | #X obj 519 325 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 13 | 1; 14 | #X obj 541 327 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 15 | 1; 16 | #X obj 560 327 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 17 | 1; 18 | #X msg 274 46 /d/[1-3]; 19 | #X obj -173 275 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 20 | -1 -1 0 1; 21 | #X obj 122 7 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 1 22 | ; 23 | #X obj -93 280 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 24 | -1 -1 0 1; 25 | #X obj -152 278 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 26 | -1 -1 0 1; 27 | #X obj -112 279 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 28 | -1 -1 0 1; 29 | #X obj -132 278 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 30 | -1 -1 0 1; 31 | #X obj -66 277 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 32 | -1 -1 0 1; 33 | #X obj -39 276 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 34 | -1 -1 0 1; 35 | #X obj -10 277 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 36 | -1 -1 0 1; 37 | #X obj 18 274 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 38 | -1 -1 0 1; 39 | #X obj 116 277 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 40 | -1 -1 0 1; 41 | #X obj 39 274 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 42 | -1 -1 0 1; 43 | #X obj 87 276 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 44 | -1 -1 0 1; 45 | #X obj 63 281 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 46 | -1 -1 0 1; 47 | #X obj 187 288 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 48 | -1 -1 0 1; 49 | #X obj 164 277 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 50 | -1 -1 0 1; 51 | #X obj 139 276 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 52 | -1 -1 0 1; 53 | #X obj 75 27 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1 1 54 | ; 55 | #X msg 70 60 /s/l \$1; 56 | #X obj 577 329 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 57 | 1; 58 | #X obj 595 329 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 59 | 1; 60 | #X obj 612 326 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 61 | 1; 62 | #X obj 633 328 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 63 | 1; 64 | #X obj 654 330 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 65 | 1; 66 | #X obj 679 330 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 67 | 1; 68 | #X obj 699 330 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 69 | 1; 70 | #X obj 720 330 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 71 | 1; 72 | #X obj 741 332 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 73 | 1; 74 | #X obj 768 331 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 75 | 1; 76 | #X obj 791 328 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 77 | 1; 78 | #X obj 810 328 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 79 | 1; 80 | #X obj 124 119 o.io.slipserial; 81 | #X obj 835 328 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 82 | 1; 83 | #X obj 854 329 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 84 | 1; 85 | #X obj 877 330 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 86 | 1; 87 | #X obj 905 330 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 88 | 1; 89 | #X obj 507 218 routeOSC /1 /2 /3 /4 /5 /6 /7 /8 /9 /10 /11 /12 /13 90 | /14 /15 /16 /17 /18 /19 /20; 91 | #X obj 482 446 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 92 | -1 -1 0 1; 93 | #X obj 562 451 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 94 | -1 -1 0 1; 95 | #X obj 503 449 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 96 | -1 -1 0 1; 97 | #X obj 543 450 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 98 | -1 -1 0 1; 99 | #X obj 523 449 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 100 | -1 -1 0 1; 101 | #X obj 589 448 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 102 | -1 -1 0 1; 103 | #X obj 616 447 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 104 | -1 -1 0 1; 105 | #X obj 645 448 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 106 | -1 -1 0 1; 107 | #X obj 673 445 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 108 | -1 -1 0 1; 109 | #X obj 694 445 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 110 | -1 -1 0 1; 111 | #X obj 742 447 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 112 | -1 -1 0 1; 113 | #X obj 718 452 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 114 | -1 -1 0 1; 115 | #X obj 277 207 prepend set; 116 | #X msg 274 236 /m 1.90169e+09; 117 | #X msg 647 63 /c/*; 118 | #X obj 324 151 routeOSC /a /d /s /c; 119 | #X obj 485 397 routeOSC /0 /1 /16 /17 /18 /19 /22 /23 /25 /32 /33 /15 120 | ; 121 | #X obj 57 520 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 122 | -1 -1 0 1; 123 | #X obj 137 525 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 124 | -1 -1 0 1; 125 | #X obj 78 523 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 126 | -1 -1 0 1; 127 | #X obj 118 524 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 128 | -1 -1 0 1; 129 | #X obj 98 523 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 130 | -1 -1 0 1; 131 | #X obj 164 522 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 132 | -1 -1 0 1; 133 | #X obj 191 521 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 134 | -1 -1 0 1; 135 | #X obj 220 522 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 136 | -1 -1 0 1; 137 | #X obj 248 519 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 138 | -1 -1 0 1; 139 | #X obj 42 460 routeOSC /1 /2 /3 /4 /5 /6 /7 /8 /9 /10 /11 /12 /13 /14 140 | /15 /16; 141 | #X obj 346 522 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 142 | -1 -1 0 1; 143 | #X obj 269 519 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 144 | -1 -1 0 1; 145 | #X obj 317 521 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 146 | -1 -1 0 1; 147 | #X obj 293 526 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 148 | -1 -1 0 1; 149 | #X obj 418 521 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 150 | -1 -1 0 1; 151 | #X obj 394 522 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 152 | -1 -1 0 1; 153 | #X obj 369 521 vsl 15 128 0 1023 0 0 empty empty empty 0 -9 0 10 -262144 154 | -1 -1 0 1; 155 | #X obj -166 200 routeOSC /0/u /1/u /2/u /3/u /4/u /5/u /6/u /7/u /8/u 156 | /9/u /10/u /11/u /12/u /13/u /14/u /15/u; 157 | #X msg 193 61 /a/*/u; 158 | #X text 200 45 Pull up; 159 | #X text 258 20 Digital pins; 160 | #X text 374 21 How many pins?; 161 | #X text 498 20 How many milliseconds ?; 162 | #X text 150 13 Analog Pins; 163 | #X text 78 8 LED; 164 | #X text 623 40 Teensy 3 Touch; 165 | #X text 686 187 Digital Pin state; 166 | #X text 585 369 Touch Pins on Teensy 3; 167 | #X msg 546 190; 168 | #X text 522 137 System message responses; 169 | #X text 60 439 Analog Values; 170 | #X text -109 178 Analog Values with Pullups Enabled; 171 | #N canvas 0 22 450 278 (subpatch) 0; 172 | #X array AnalogArray 16 float 2; 173 | #X coords 0 1023 16 0 200 140 1 0 0; 174 | #X restore -158 574 graph; 175 | #X obj -119 545 send AnalogArray; 176 | #X obj -4 511 funnel 16; 177 | #X obj 122 32 metro 60; 178 | #X text -120 30 Oscuino Serial Adrian Freed 2013; 179 | #X obj 729 19 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 180 | 1; 181 | #X obj 729 44 metro 60; 182 | #X obj 131 155 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 183 | -1 -1; 184 | #X obj 214 158 print; 185 | #X obj -40 118 print; 186 | #X msg 527 91 devicename /dev/tty.usbmodem122611 \, baud 9600 \, pollintervall 187 | 4 \, verbose 1; 188 | #X connect 0 0 64 0; 189 | #X connect 1 0 43 0; 190 | #X connect 2 0 1 0; 191 | #X connect 3 0 94 0; 192 | #X connect 4 0 1 0; 193 | #X connect 5 0 1 0; 194 | #X connect 6 0 1 0; 195 | #X connect 11 0 1 0; 196 | #X connect 13 0 101 0; 197 | #X connect 29 0 30 0; 198 | #X connect 30 0 1 0; 199 | #X connect 43 0 0 0; 200 | #X connect 43 0 105 0; 201 | #X connect 43 0 106 0; 202 | #X connect 48 0 7 0; 203 | #X connect 48 1 8 0; 204 | #X connect 48 2 9 0; 205 | #X connect 48 3 10 0; 206 | #X connect 48 4 31 0; 207 | #X connect 48 5 32 0; 208 | #X connect 48 6 33 0; 209 | #X connect 48 7 34 0; 210 | #X connect 48 8 35 0; 211 | #X connect 48 9 36 0; 212 | #X connect 48 10 37 0; 213 | #X connect 48 11 38 0; 214 | #X connect 48 12 39 0; 215 | #X connect 48 13 40 0; 216 | #X connect 48 14 41 0; 217 | #X connect 48 15 42 0; 218 | #X connect 48 16 44 0; 219 | #X connect 48 17 45 0; 220 | #X connect 48 18 46 0; 221 | #X connect 48 19 47 0; 222 | #X connect 61 0 62 0; 223 | #X connect 63 0 1 0; 224 | #X connect 64 0 83 0; 225 | #X connect 64 1 48 0; 226 | #X connect 64 2 61 0; 227 | #X connect 64 3 65 0; 228 | #X connect 64 4 3 0; 229 | #X connect 65 0 49 0; 230 | #X connect 65 1 51 0; 231 | #X connect 65 2 53 0; 232 | #X connect 65 3 52 0; 233 | #X connect 65 4 50 0; 234 | #X connect 65 5 54 0; 235 | #X connect 65 6 55 0; 236 | #X connect 65 7 56 0; 237 | #X connect 65 8 57 0; 238 | #X connect 65 9 58 0; 239 | #X connect 65 10 60 0; 240 | #X connect 65 11 59 0; 241 | #X connect 75 0 66 0; 242 | #X connect 75 0 100 0; 243 | #X connect 75 1 68 0; 244 | #X connect 75 1 100 1; 245 | #X connect 75 2 70 0; 246 | #X connect 75 2 100 2; 247 | #X connect 75 3 69 0; 248 | #X connect 75 3 100 3; 249 | #X connect 75 4 67 0; 250 | #X connect 75 4 100 4; 251 | #X connect 75 5 71 0; 252 | #X connect 75 5 100 5; 253 | #X connect 75 6 72 0; 254 | #X connect 75 6 100 6; 255 | #X connect 75 7 73 0; 256 | #X connect 75 7 100 7; 257 | #X connect 75 8 74 0; 258 | #X connect 75 8 100 8; 259 | #X connect 75 9 77 0; 260 | #X connect 75 9 100 9; 261 | #X connect 75 10 79 0; 262 | #X connect 75 10 100 10; 263 | #X connect 75 11 78 0; 264 | #X connect 75 11 100 11; 265 | #X connect 75 12 76 0; 266 | #X connect 75 12 100 12; 267 | #X connect 75 13 82 0; 268 | #X connect 75 13 100 13; 269 | #X connect 75 14 81 0; 270 | #X connect 75 14 100 14; 271 | #X connect 75 15 80 0; 272 | #X connect 75 15 100 15; 273 | #X connect 83 0 12 0; 274 | #X connect 83 1 15 0; 275 | #X connect 83 2 17 0; 276 | #X connect 83 3 16 0; 277 | #X connect 83 4 14 0; 278 | #X connect 83 5 18 0; 279 | #X connect 83 6 19 0; 280 | #X connect 83 7 20 0; 281 | #X connect 83 8 21 0; 282 | #X connect 83 9 23 0; 283 | #X connect 83 10 25 0; 284 | #X connect 83 11 24 0; 285 | #X connect 83 12 22 0; 286 | #X connect 83 13 28 0; 287 | #X connect 83 14 27 0; 288 | #X connect 83 15 26 0; 289 | #X connect 83 16 75 0; 290 | #X connect 84 0 1 0; 291 | #X connect 100 0 99 0; 292 | #X connect 101 0 2 0; 293 | #X connect 103 0 104 0; 294 | #X connect 104 0 63 0; 295 | #X connect 108 0 43 1; 296 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/Applications/PD/o.io.slipserial.pd: -------------------------------------------------------------------------------- 1 | #N canvas 624 330 756 268 10; 2 | #X declare -lib mrpeach; 3 | #X obj 251 231 import mrpeach; 4 | #X obj 95 179 mrpeach/slipdec 65536; 5 | #X obj 95 47 mrpeach/slipenc 65536; 6 | #X obj 303 65 loadbang; 7 | #X obj 299 22 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 8 | -1; 9 | #X obj 76 16 inlet; 10 | #X obj 74 240 outlet; 11 | #X msg 296 142 baud 115200; 12 | #X obj 261 46 inlet; 13 | #X msg 132 95 devicename /dev/tty.usbserial-A5002rKU \, pollintervall 14 | 1; 15 | #X obj 57 157 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 16 | -1; 17 | #X obj 99 120 comport; 18 | #X obj 49 99 print; 19 | #X obj 301 199 print errors; 20 | #X msg 390 42; 21 | #X obj 226 19 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 22 | -1; 23 | #X connect 1 0 6 0; 24 | #X connect 2 0 11 0; 25 | #X connect 2 0 12 0; 26 | #X connect 3 0 9 0; 27 | #X connect 3 0 7 0; 28 | #X connect 4 0 3 0; 29 | #X connect 5 0 2 0; 30 | #X connect 7 0 11 0; 31 | #X connect 8 0 11 0; 32 | #X connect 9 0 11 0; 33 | #X connect 11 0 1 0; 34 | #X connect 11 0 10 0; 35 | #X connect 11 1 13 0; 36 | #X connect 15 0 11 0; 37 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/Applications/Processing/UDPReceiveBundle/UDPReceiveBundle.pde: -------------------------------------------------------------------------------- 1 | /* 2 | Receives and visualizes OSCBundles sent over UDP 3 | 4 | Use with /examples/UDPSendBundle 5 | 6 | or with /examples/SerialSendBundle in conjunction 7 | with /Applicaitons/Processing/SLIPSerialToUDP 8 | */ 9 | 10 | import oscP5.*; 11 | import netP5.*; 12 | 13 | OscP5 oscP5; 14 | 15 | void setup() { 16 | size(600,300); 17 | frameRate(30); 18 | //set this to the receiving port 19 | oscP5 = new OscP5(this,9001); 20 | } 21 | 22 | 23 | void draw() { 24 | background(0); 25 | //draw the analog values 26 | float analog0Height = map(analogValue0, 0, 1024, 0, 200); 27 | float analog1Height = map(analogValue1, 0, 1024, 0, 200); 28 | fill(255); 29 | rect(50, 250, 50, -analog0Height); 30 | rect(150, 250, 50, -analog1Height); 31 | //and the labels 32 | textSize(12); 33 | text("/analog/0", 50, 270); 34 | text("/analog/1", 150, 270); 35 | //and the digital pin label 36 | text("/digital/5", 250, 270); 37 | textSize(25); 38 | text(digitalValue5, 250, 250); 39 | //now do the mouse part 40 | //add the label 41 | textSize(12); 42 | text("/mouse/step", 350, 270); 43 | //make a box where it should go 44 | noFill(); 45 | stroke(255); 46 | rect(350, 50, 200, 200); 47 | //and a square where the mouse is 48 | fill(255); 49 | float mouseXPos = map(mouseStepX, 0, 1024, 350, 530); 50 | float mouseYPos = map(mouseStepY, 0, 1024, 50, 230); 51 | rect(mouseXPos, mouseYPos, 20, 20); 52 | } 53 | 54 | int analogValue0 = 50; 55 | int analogValue1 = 50; 56 | String digitalValue5 = "LOW"; 57 | 58 | int mouseStepX = 0; 59 | int mouseStepY = 0; 60 | 61 | // incoming osc message are forwarded to the oscEvent method. 62 | void oscEvent(OscMessage theOscMessage) { 63 | //println(theOscMessage.addrPattern()); 64 | if (theOscMessage.addrPattern().equals("/analog/0")){ 65 | analogValue0 = theOscMessage.get(0).intValue(); 66 | } else if(theOscMessage.addrPattern().equals("/analog/1")){ 67 | analogValue1 = theOscMessage.get(0).intValue(); 68 | } else if(theOscMessage.addrPattern().equals("/digital/5")){ 69 | digitalValue5 = theOscMessage.get(0).stringValue(); 70 | } else if(theOscMessage.addrPattern().equals("/mouse/step")){ 71 | mouseStepX = theOscMessage.get(0).intValue(); 72 | mouseStepY = theOscMessage.get(1).intValue(); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/Applications/Processing/UDPReceiveMessage/UDPReceiveMessage.pde: -------------------------------------------------------------------------------- 1 | /* 2 | Receives and visualizes OSCBundles sent over UDP 3 | 4 | Use with /examples/UDPSendMessage 5 | 6 | or with /examples/SerialSendMessage in conjunction 7 | with /Applicaitons/Processing/SLIPSerialToUDP 8 | */ 9 | 10 | import oscP5.*; 11 | import netP5.*; 12 | 13 | OscP5 oscP5; 14 | 15 | void setup() { 16 | size(150,300); 17 | frameRate(30); 18 | //set this to the receiving port 19 | oscP5 = new OscP5(this,9001); 20 | } 21 | 22 | 23 | void draw() { 24 | background(0); 25 | //draw the analog values 26 | float analog0Height = map(analogValue0, 0, 1024, 0, 200); 27 | fill(255); 28 | rect(50, 250, 50, -analog0Height); 29 | //and the labels 30 | textSize(12); 31 | text("/analog/0", 50, 270); 32 | } 33 | 34 | int analogValue0 = 50; 35 | 36 | // incoming osc message are forwarded to the oscEvent method. 37 | void oscEvent(OscMessage theOscMessage) { 38 | //println(theOscMessage.addrPattern()); 39 | if (theOscMessage.addrPattern().equals("/analog/0")){ 40 | analogValue0 = theOscMessage.get(0).intValue(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/Applications/Processing/serialSend/code/javaosc.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janfiess/NodeMCU_OSC/79ebd9a0a320323f50cafb268acb095a67160994/Arduino-Code/OSC library - Backup/OSCuino/Applications/Processing/serialSend/code/javaosc.jar -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/Applications/Processing/serialSend/serialSend.pde: -------------------------------------------------------------------------------- 1 | import oscP5.*; 2 | import netP5.*; 3 | 4 | OscP5 oscP5; 5 | NetAddress arduinoAddress; 6 | //the number of analog pins on this controller 7 | int analogPins = 16; 8 | //an array of all of the pin values 9 | int[] pinVals = new int[analogPins]; 10 | 11 | void setup() { 12 | frameRate(60); 13 | size(320, 100); 14 | background(0); 15 | //initialize the listening port 16 | oscP5 = new OscP5(this, 9999); 17 | //the outgoing communication to the arduino 18 | arduinoAddress = new NetAddress("128,32.122.252", 8888); 19 | } 20 | 21 | 22 | void draw() { 23 | //clear the previous bars 24 | fill(0); 25 | rect(0, 0, width, height); 26 | //draw each of the bars showing the pin value 27 | for (int i = 0; i < analogPins; i++) { 28 | int value = pinVals[i]; 29 | int barWidth = width/analogPins; 30 | float barHeight = (value/1024.)*height; 31 | //draws the new bar in white 32 | fill(255); 33 | rect(barWidth*i, height - barHeight, barWidth, barHeight); 34 | } 35 | } 36 | 37 | // incoming osc message are forwarded to the oscEvent method. 38 | void oscEvent(OscMessage msg) { 39 | String address = msg.addrPattern(); 40 | if (address.startsWith("/analog/")) { 41 | //then it's an analog reading 42 | //split the address 43 | String[] splitAddr = address.split("/"); 44 | //the third element should be the number 45 | int pinNum = Integer.parseInt(splitAddr[2]); 46 | int val = msg.get(0).intValue(); 47 | pinVals[pinNum] = val; 48 | } 49 | } 50 | 51 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/Applications/Processing/serialSend/sketch.properties: -------------------------------------------------------------------------------- 1 | mode=Android 2 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/LICENSE: -------------------------------------------------------------------------------- 1 | Written by Yotam Mann and Adrian Freed, The Center for New Music and Audio Technologies, 2 | University of California, Berkeley. Copyright (c) 2013, The Regents of 3 | the University of California (Regents). 4 | 5 | Permission to use, copy, modify, distribute, and distribute modified versions 6 | of this software and its documentation without fee and without a signed 7 | licensing agreement, is hereby granted, provided that the above copyright 8 | notice, this paragraph and the following two paragraphs appear in all copies, 9 | modifications, and distributions. 10 | 11 | IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, 12 | SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING 13 | OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS 14 | BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 15 | 16 | REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 17 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 | PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED 19 | HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE 20 | MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 21 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/OSCBoards copy.h: -------------------------------------------------------------------------------- 1 | // 2 | // OSCBoards.h 3 | // 4 | // 5 | // Created by AdrianFreed on 5/26/13. 6 | // 7 | // 8 | 9 | #ifndef _OSCBoards_h 10 | #define _OSCBoards_h 11 | 12 | 13 | 14 | #if defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MKL26Z64__) // Teensy 3.0 3.1 (PIC32's might have some day) 3.1LC 15 | #define BOARD_HAS_CAPACITANCE_SENSING 16 | #endif 17 | 18 | #if defined(__AVR_ATmega32U4__) || defined(__MKL26Z64__) || defined(__MK20DX128__)|| defined(__MK20DX256__) || defined(__AVR_ATmega328_) || defined(__AVR_ATmega128__) 19 | 20 | #define BOARD_HAS_DIE_TEMPERATURE_SENSOR 21 | #endif 22 | 23 | #if defined(__AVR_ATmega32U4__) || defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MKL26Z64__) || defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega328_) || defined(__AVR_ATmega128__) 24 | 25 | 26 | #define BOARD_HAS_DIE_POWER_SUPPLY_MEASUREMENT 27 | #define BOARD_HAS_ANALOG_PULLUP 28 | #endif 29 | 30 | // missing specs for PIC32 31 | 32 | #if defined(__PIC32MX__) 33 | #define NUM_ANALOG_INPUTS NUM_ANALOG_PINS 34 | #define NUM_DIGITAL_INPUTS NUM_DIGITAL_PINS 35 | #define LED_BUILTIN PIN_LED1 36 | #endif 37 | 38 | // missing specs for Arduino Due 39 | #if defined(__SAM3X8E__) 40 | 41 | #ifndef analogInputToDigitalPin 42 | #define analogInputToDigitalPin(p) ((p < 12) ? (p) + 54 : -1) 43 | #endif 44 | 45 | 46 | #endif // defined(__SAM3X8E__) 47 | 48 | // missing specs for Leonardo derived devices 49 | #if ! defined(CORE_TEENSY) && (defined(__AVR_ATmega32U4__) && (!defined(LED_BUILTIN) || !defined(analogInputToDigitalPin)) ) 50 | 51 | #if F_CPU==16000000 52 | // Leonardo and Esplora 53 | #ifndef LED_BUILTIN 54 | #define LED_BUILTIN 13 55 | #endif 56 | #ifndef analogInputToDigitalPin 57 | #define analogInputToDigitalPin(p) ((p < 12) ? (p) + 18 : -1) 58 | #endif 59 | #else // F_CPU 60 | //Lilypad USB and Flora (8Mhz) 61 | #ifndef LED_BUILTIN 62 | #define LED_BUILTIN 13 // its 7 on Flora but how do we detect this? 63 | #endif 64 | #ifndef analogInputToDigitalPin 65 | #define analogInputToDigitalPin(p) ((p < 12) ? (p) + 18 : -1) 66 | #endif 67 | #endif //F_CPU 68 | #endif 69 | 70 | #endif 71 | 72 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/OSCBoards.h: -------------------------------------------------------------------------------- 1 | // 2 | // OSCBoards.h 3 | // 4 | // 5 | // Created by AdrianFreed on 5/26/13. 6 | // 7 | // 8 | 9 | #ifndef _OSCBoards_h 10 | #define _OSCBoards_h 11 | 12 | 13 | 14 | #if defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MKL26Z64__) || defined(__MK66FX1M0__) 15 | // Teensy 3.0 3.1 (PIC32's might have some day) 3.1LC 3.2 3.5 16 | #define BOARD_HAS_CAPACITANCE_SENSING 17 | #endif 18 | 19 | #if defined(__AVR_ATmega32U4__) || defined(__MKL26Z64__) || defined(__MK20DX128__)|| defined(__MK20DX256__) || defined(__MK66FX1M0__) || defined(__AVR_ATmega328_) || defined(__AVR_ATmega128__) 20 | 21 | #define BOARD_HAS_DIE_TEMPERATURE_SENSOR 22 | #endif 23 | 24 | #if defined(__AVR_ATmega32U4__) || defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK66FX1M0__)|| defined(__MKL26Z64__) || defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega328_) || defined(__AVR_ATmega128__) 25 | 26 | 27 | #define BOARD_HAS_DIE_POWER_SUPPLY_MEASUREMENT 28 | #endif 29 | 30 | 31 | #if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega328_) || defined(__AVR_ATmega128__) 32 | 33 | 34 | #define BOARD_HAS_ANALOG_PULLUP 35 | #endif 36 | 37 | // missing specs for PIC32 38 | 39 | #if defined(__PIC32MX__) 40 | #define NUM_ANALOG_INPUTS NUM_ANALOG_PINS 41 | #define NUM_DIGITAL_INPUTS NUM_DIGITAL_PINS 42 | #define LED_BUILTIN PIN_LED1 43 | #endif 44 | 45 | // missing specs for Arduino Due 46 | #if defined(__SAM3X8E__) 47 | 48 | 49 | 50 | 51 | #endif // defined(__SAM3X8E__) 52 | 53 | // missing specs for Leonardo derived devices 54 | #if ! defined(CORE_TEENSY) && (defined(__AVR_ATmega32U4__) && (!defined(LED_BUILTIN) || !defined(analogInputToDigitalPin)) ) 55 | 56 | #if F_CPU==16000000 57 | // Leonardo and Esplora 58 | #ifndef LED_BUILTIN 59 | #define LED_BUILTIN 13 60 | #endif 61 | 62 | #else // F_CPU 63 | //Lilypad USB and Flora (8Mhz) 64 | #ifndef LED_BUILTIN 65 | #define LED_BUILTIN 13 // its 7 on Flora but how do we detect this? 66 | #endif 67 | 68 | #endif //F_CPU 69 | #endif 70 | 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/OSCBundle.h: -------------------------------------------------------------------------------- 1 | /* 2 | Written by Yotam Mann, The Center for New Music and Audio Technologies, 3 | University of California, Berkeley. Copyright (c) 2012, 2013, The Regents of 4 | the University of California (Regents). 5 | 6 | Permission to use, copy, modify, distribute, and distribute modified versions 7 | of this software and its documentation without fee and without a signed 8 | licensing agreement, is hereby granted, provided that the above copyright 9 | notice, this paragraph and the following two paragraphs appear in all copies, 10 | modifications, and distributions. 11 | 12 | IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, 13 | SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING 14 | OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS 15 | BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 16 | 17 | REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 18 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 | PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED 20 | HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE 21 | MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 22 | 23 | 24 | */ 25 | 26 | #ifndef OSCBUNDLE_h 27 | #define OSCBUNDLE_h 28 | 29 | #include "OSCMessage.h" 30 | 31 | extern osctime_t zerotime; 32 | class OSCBundle 33 | { 34 | 35 | private: 36 | 37 | /*============================================================================= 38 | PRIVATE VARIABLES 39 | =============================================================================*/ 40 | 41 | //the array of messages contained in the bundle 42 | OSCMessage ** messages; 43 | 44 | //the number of messages in the array 45 | int numMessages; 46 | 47 | osctime_t timetag; 48 | 49 | //error codes 50 | OSCErrorCode error; 51 | 52 | /*============================================================================= 53 | DECODING INCOMING BYTES 54 | =============================================================================*/ 55 | 56 | //the decoding states for incoming bytes 57 | enum DecodeState { 58 | STANDBY, 59 | HEADER, 60 | TIMETAG, 61 | MESSAGE_SIZE, 62 | MESSAGE, 63 | } decodeState; 64 | 65 | //stores incoming bytes until they can be decoded 66 | uint8_t * incomingBuffer; 67 | int incomingBufferSize; 68 | 69 | //the size of the incoming message 70 | int incomingMessageSize; 71 | 72 | //adds a byte to the buffer 73 | void addToIncomingBuffer(uint8_t); 74 | //clears the incoming buffer 75 | void clearIncomingBuffer(); 76 | 77 | //decoding functions 78 | void decode(uint8_t); 79 | void decodeTimetag(); 80 | void decodeHeader(); 81 | void decodeMessage(uint8_t); 82 | 83 | //just a placeholder while filling 84 | OSCMessage & add(); 85 | 86 | 87 | public: 88 | 89 | /*============================================================================= 90 | CONSTRUCTORS / DESTRUCTOR 91 | =============================================================================*/ 92 | 93 | //default timetag of 94 | OSCBundle(osctime_t = zerotime); 95 | 96 | //DESTRUCTOR 97 | ~OSCBundle(); 98 | 99 | //clears all of the OSCMessages inside 100 | OSCBundle& empty(); 101 | 102 | /*============================================================================= 103 | SETTERS 104 | =============================================================================*/ 105 | 106 | //start a new OSC Message in the bundle 107 | OSCMessage & add( char * address); 108 | //add with nothing in it produces an invalid osc message 109 | //copies an existing message into the bundle 110 | OSCMessage & add(OSCMessage & msg); 111 | 112 | template 113 | OSCBundle& setTimetag(T t){ 114 | timetag = (osctime_t) t; 115 | return *this; 116 | } 117 | //sets the timetag from a buffer 118 | OSCBundle& setTimetag(uint8_t * buff){ 119 | memcpy(&timetag, buff, 8); 120 | return *this; 121 | } 122 | 123 | /*============================================================================= 124 | GETTERS 125 | =============================================================================*/ 126 | 127 | //gets the message the matches the address string 128 | //will do regex matching 129 | OSCMessage * getOSCMessage(char * addr); 130 | 131 | //get message by position 132 | OSCMessage * getOSCMessage(int position); 133 | 134 | /*============================================================================= 135 | MATCHING 136 | =============================================================================*/ 137 | 138 | //if the bundle contains a message that matches the pattern, 139 | //call the function callback on that message 140 | bool dispatch(const char * pattern, void (*callback)(OSCMessage&), int = 0); 141 | 142 | //like dispatch, but allows for partial matches 143 | //the address match offset is sent as an argument to the callback 144 | bool route(const char * pattern, void (*callback)(OSCMessage&, int), int = 0); 145 | 146 | /*============================================================================= 147 | SIZE 148 | =============================================================================*/ 149 | //returns the number of messages in the bundle; 150 | int size(); 151 | 152 | /*============================================================================= 153 | ERROR 154 | =============================================================================*/ 155 | 156 | bool hasError(); 157 | 158 | OSCErrorCode getError(); 159 | 160 | /*============================================================================= 161 | SENDING 162 | =============================================================================*/ 163 | 164 | OSCBundle& send(Print &p); 165 | 166 | /*============================================================================= 167 | FILLING 168 | =============================================================================*/ 169 | 170 | OSCBundle& fill(uint8_t incomingByte); 171 | 172 | OSCBundle& fill(uint8_t * incomingBytes, int length); 173 | }; 174 | 175 | #endif 176 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/OSCData.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "OSCData.h" 3 | 4 | 5 | osctime_t zerotime = {0,0}; 6 | /*============================================================================= 7 | CONSTRUCTORS 8 | 9 | overloaded methods for each of the types which will 10 | set the type flag, the size (in bytes), and the data 11 | =============================================================================*/ 12 | 13 | 14 | OSCData::OSCData(const char * s){ 15 | error = OSC_OK; 16 | type = 's'; 17 | bytes = (strlen(s) + 1); 18 | //own the data 19 | char * mem = (char *) malloc(bytes); 20 | if (mem == NULL){ 21 | error = ALLOCFAILED; 22 | } else { 23 | strcpy(mem, s); 24 | data.s = mem; 25 | } 26 | } 27 | 28 | 29 | 30 | 31 | OSCData::OSCData(int32_t i){ 32 | error = OSC_OK; 33 | type = 'i'; 34 | bytes = 4; 35 | data.i = i; 36 | } 37 | #ifndef ESP8266 38 | OSCData::OSCData(int i){ 39 | error = OSC_OK; 40 | type = 'i'; 41 | bytes = 4; 42 | data.i = i; 43 | } 44 | #endif 45 | OSCData::OSCData(unsigned int i){ 46 | error = OSC_OK; 47 | type = 'i'; 48 | bytes = 4; 49 | data.i = i; 50 | } 51 | #if defined(__SAM3X8E__) 52 | OSCData::OSCData(int16_t i){ 53 | error = OSC_OK; 54 | type = 'i'; 55 | bytes = 4; 56 | data.i = i; 57 | } 58 | #endif 59 | 60 | OSCData::OSCData(float f){ 61 | error = OSC_OK; 62 | type = 'f'; 63 | bytes = 4; 64 | data.f = f; 65 | } 66 | 67 | OSCData::OSCData(osctime_t t){ 68 | error = OSC_OK; 69 | type = 't'; 70 | bytes = 8; 71 | data.time = t; 72 | } 73 | OSCData::OSCData(boolean b){ 74 | error = OSC_OK; 75 | type = b?'T':'F'; 76 | bytes = 0; 77 | } 78 | 79 | 80 | OSCData::OSCData(double d){ 81 | error = OSC_OK; 82 | bytes = sizeof(double); 83 | //if it's not 8 bytes it's not a true double 84 | if (bytes == 8){ 85 | type = 'd'; 86 | data.d = d; 87 | } else { 88 | type = 'f'; 89 | data.f = d; 90 | } 91 | } 92 | 93 | OSCData::OSCData(uint8_t * b, int len){ 94 | error = OSC_OK; 95 | type = 'b'; 96 | bytes = len + 4; 97 | //add the size to the front of the blob 98 | uint32_t len32 = (uint32_t) len; 99 | //make sure the length is endian-safe 100 | len32 = BigEndian(len32); 101 | uint8_t * lenPtr = (uint8_t *) (& len32); 102 | //own the data 103 | if(bytes>0) 104 | { 105 | 106 | uint8_t * mem = (uint8_t * ) malloc(bytes); 107 | if (mem == NULL){ 108 | error = ALLOCFAILED; 109 | } else { 110 | //copy over the blob length 111 | memcpy(mem, lenPtr, 4); 112 | //copy over the blob data 113 | memcpy(mem + 4, b, len); 114 | data.b = mem; 115 | } 116 | } 117 | else 118 | data.b = 0; 119 | } 120 | 121 | OSCData::OSCData (OSCData * datum){ 122 | error = OSC_OK; 123 | type = datum->type; 124 | bytes = datum->bytes; 125 | if ( (type == 'i') || (type == 'f') || (type == 'd') || (type == 't') 126 | || (type == 'h') || (type == 'c') || (type == 'r') || (type == 'm') 127 | ) 128 | { 129 | data = datum->data; 130 | } else if ((type == 's') || (type == 'b')){ 131 | //allocate a new piece of memory 132 | uint8_t * mem = (uint8_t * ) malloc(bytes); 133 | if (mem == NULL){ 134 | error = ALLOCFAILED; 135 | } else { 136 | //copy over the blob length 137 | memcpy(mem, datum->data.b, bytes); 138 | data.b = mem; 139 | } 140 | } 141 | } 142 | 143 | //DESTRUCTOR 144 | OSCData::~OSCData(){ 145 | //if there are no bytes, there is nothing to free 146 | if (bytes>0){ 147 | //if the data is of type 's' or 'b', need to free that memory 148 | if (type == 's'){ 149 | free(data.s); 150 | }else if( type == 'b'){ 151 | free(data.b); 152 | } 153 | } 154 | } 155 | 156 | //sets just the type as a message placeholder 157 | //no data 158 | OSCData::OSCData(char t){ 159 | error = INVALID_OSC; 160 | type = t; 161 | bytes = 0; 162 | } 163 | 164 | /*============================================================================= 165 | GETTERS 166 | 167 | perform a safety check to make sure the data type matches the request 168 | otherwise returns NULL 169 | =============================================================================*/ 170 | 171 | int32_t OSCData::getInt(){ 172 | if (type == 'i'){ 173 | return data.i; 174 | } else { 175 | #ifndef ESP8266 176 | return NULL; 177 | #else 178 | return -1; 179 | #endif 180 | } 181 | } 182 | osctime_t OSCData::getTime(){ 183 | if (type == 't'){ 184 | return data.time; 185 | } else { 186 | 187 | return zerotime; 188 | } 189 | } 190 | float OSCData::getFloat(){ 191 | if (type == 'f'){ 192 | return data.f; 193 | } else { 194 | #ifndef ESP8266 195 | return NULL; 196 | #else 197 | return -1; 198 | #endif 199 | } 200 | } 201 | 202 | double OSCData::getDouble(){ 203 | if (type == 'd'){ 204 | return data.d; 205 | } else { 206 | #ifndef ESP8266 207 | return NULL; 208 | #else 209 | return -1; 210 | #endif 211 | } 212 | } 213 | bool OSCData::getBoolean(){ 214 | if (type == 'T'){ 215 | return true; 216 | } else if (type=='F'){ 217 | return false; 218 | } 219 | else 220 | #ifndef ESP8266 221 | return NULL; 222 | #else 223 | return -1; 224 | #endif 225 | } 226 | 227 | int OSCData::getString(char * strBuffer, int length){ 228 | if (type == 's' && bytes >= length){ 229 | strncpy(strBuffer, data.s, length); 230 | return length; 231 | } else { 232 | #ifndef ESP8266 233 | return NULL; 234 | #else 235 | return -1; 236 | #endif 237 | } 238 | } 239 | 240 | int OSCData::getBlob(uint8_t * blobBuffer, int length){ 241 | //jump over the first 4 bytes which encode the length 242 | int blobLength = bytes - 4; 243 | if (type == 'b' && blobLength >= length){ 244 | memcpy(blobBuffer, data.b + 4, length); 245 | return length; 246 | } else { 247 | #ifndef ESP8266 248 | return NULL; 249 | #else 250 | return -1; 251 | #endif 252 | } 253 | } -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/OSCData.h: -------------------------------------------------------------------------------- 1 | /* 2 | Written by Yotam Mann, The Center for New Music and Audio Technologies, 3 | University of California, Berkeley. Copyright (c) 2013, The Regents of 4 | the University of California (Regents). 5 | 6 | Permission to use, copy, modify, distribute, and distribute modified versions 7 | of this software and its documentation without fee and without a signed 8 | licensing agreement, is hereby granted, provided that the above copyright 9 | notice, this paragraph and the following two paragraphs appear in all copies, 10 | modifications, and distributions. 11 | 12 | IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, 13 | SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING 14 | OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS 15 | BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 16 | 17 | REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 18 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 | PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED 20 | HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE 21 | MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 22 | 23 | For bug reports and feature requests please email me at yotam@cnmat.berkeley.edu 24 | */ 25 | 26 | #ifndef OSCDATA_h 27 | #define OSCDATA_h 28 | 29 | #include "Arduino.h" 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #include "OSCTiming.h" 37 | 38 | #if (defined(CORE_TEENSY) && defined(USB_SERIAL)) || (!defined(CORE_TEENSY) && defined(__AVR_ATmega32U4__)) || defined(__SAM3X8E__) || (defined(_USB) && defined(_USE_USB_FOR_SERIAL_)) || defined(BOARD_maple_mini) 39 | 40 | #define BOARD_HAS_USB_SERIAL 41 | #if defined(__SAM3X8E__) 42 | #define thisBoardsSerialUSB SerialUSB 43 | #else 44 | #define thisBoardsSerialUSB Serial 45 | #endif 46 | #endif 47 | 48 | 49 | 50 | //ERRORS///////////////////////////////////////////////// 51 | typedef enum { OSC_OK = 0, 52 | BUFFER_FULL, INVALID_OSC, ALLOCFAILED, INDEX_OUT_OF_BOUNDS 53 | } OSCErrorCode; 54 | 55 | class OSCData 56 | { 57 | 58 | private: 59 | 60 | //friends 61 | friend class OSCMessage; 62 | 63 | //should only be used while decoding 64 | //leaves an invalid OSCMessage with a type, but no data 65 | OSCData(char t); 66 | 67 | public: 68 | 69 | //an error flag 70 | OSCErrorCode error; 71 | 72 | //the size (in bytes) of the data 73 | int bytes; 74 | 75 | //the type of the data 76 | int type; 77 | 78 | //the data 79 | union { 80 | char * s; //string 81 | int32_t i; //int 82 | float f; //float 83 | double d; //double 84 | uint64_t l; //long 85 | uint8_t * b; //blob 86 | osctime_t time; 87 | } data; 88 | 89 | //overload the constructor to account for all the types and sizes 90 | OSCData(const char * s); 91 | #if defined(__SAM3X8E__) 92 | OSCData (int16_t); 93 | #endif 94 | OSCData (int32_t); 95 | #ifndef ESP8266 96 | OSCData (int); 97 | #endif 98 | OSCData (unsigned int); 99 | OSCData (float); 100 | OSCData (double); 101 | OSCData (uint8_t *, int); 102 | //accepts another OSCData objects and clones it 103 | OSCData (OSCData *); 104 | OSCData (boolean); 105 | OSCData (osctime_t); 106 | 107 | //destructor 108 | ~OSCData(); 109 | 110 | //GETTERS 111 | int32_t getInt(); 112 | float getFloat(); 113 | double getDouble(); 114 | int getString(char *, int); 115 | int getBlob(uint8_t *, int); 116 | bool getBoolean(); 117 | osctime_t getTime(); 118 | 119 | //constructor from byte array with type and length 120 | OSCData(char, uint8_t *, int); 121 | //fill the passed in buffer with the data 122 | //uint8_t * asByteArray(); 123 | 124 | }; 125 | 126 | /* 127 | based on http://stackoverflow.com/questions/809902/64-bit-ntohl-in-c 128 | 129 | if the system is little endian, it will flip the bits 130 | if the system is big endian, it'll do nothing 131 | */ 132 | template 133 | static inline T BigEndian(const T& x) 134 | { 135 | const int one = 1; 136 | const char sig = *(char*)&one; 137 | if (sig == 0) return x; // for big endian machine just return the input 138 | T ret; 139 | int size = sizeof(T); 140 | char* src = (char*)&x + sizeof(T) - 1; 141 | char* dst = (char*)&ret; 142 | while (size-- > 0){ 143 | *dst++ = *src--; 144 | } 145 | return ret; 146 | } 147 | 148 | #endif -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/OSCMatch.c: -------------------------------------------------------------------------------- 1 | #define OSC_MATCH_ENABLE_2STARS 1 2 | #define OSC_MATCH_ENABLE_NSTARS 1 3 | /* 4 | Written by John MacCallum, The Center for New Music and Audio Technologies, 5 | University of California, Berkeley. Copyright (c) 2009, The Regents of 6 | the University of California (Regents). 7 | Permission to use, copy, modify, distribute, and distribute modified versions 8 | of this software and its documentation without fee and without a signed 9 | licensing agreement, is hereby granted, provided that the above copyright 10 | notice, this paragraph and the following two paragraphs appear in all copies, 11 | modifications, and distributions. 12 | 13 | IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, 14 | SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING 15 | OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS 16 | BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 17 | 18 | REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 19 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 20 | PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED 21 | HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE 22 | MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 23 | */ 24 | #include 25 | #include "OSCMatch.h" 26 | 27 | static int osc_match_star(const char *pattern, const char *address); 28 | static int osc_match_star_r(const char *pattern, const char *address); 29 | static int osc_match_single_char(const char *pattern, const char *address); 30 | static int osc_match_bracket(const char *pattern, const char *address); 31 | static int osc_match_curly_brace(const char *pattern, const char *address); 32 | 33 | int osc_match(const char *pattern, const char *address, int *pattern_offset, int *address_offset) 34 | { 35 | if(!strcmp(pattern, address)){ 36 | *pattern_offset = strlen(pattern); 37 | *address_offset = strlen(address); 38 | return OSC_MATCH_ADDRESS_COMPLETE | OSC_MATCH_PATTERN_COMPLETE; 39 | } 40 | 41 | const char *pattern_start; 42 | const char *address_start; 43 | 44 | pattern_start = pattern; 45 | address_start = address; 46 | 47 | *pattern_offset = 0; 48 | *address_offset = 0; 49 | 50 | while(*address != '\0' && *pattern != '\0'){ 51 | if(*pattern == '*'){ 52 | if(!osc_match_star(pattern, address)){ 53 | return 0; 54 | } 55 | while(*pattern != '/' && *pattern != '\0'){ 56 | pattern++; 57 | } 58 | while(*address != '/' && *address != '\0'){ 59 | address++; 60 | } 61 | }else if(*address == '*'){ 62 | while(*pattern != '/' && *pattern != '\0'){ 63 | pattern++; 64 | } 65 | while(*address != '/' && *address != '\0'){ 66 | address++; 67 | } 68 | }else{ 69 | int n = 0; 70 | if(!(n = osc_match_single_char(pattern, address))){ 71 | return 0; 72 | } 73 | if(*pattern == '['){ 74 | while(*pattern != ']'){ 75 | pattern++; 76 | } 77 | pattern++; 78 | address++; 79 | }else if(*pattern == '{'){ 80 | while(*pattern != '}'){ 81 | pattern++; 82 | } 83 | pattern++; 84 | address += n; 85 | }else{ 86 | pattern++; 87 | address++; 88 | } 89 | } 90 | } 91 | 92 | *pattern_offset = pattern - pattern_start; 93 | *address_offset = address - address_start; 94 | 95 | int r = 0; 96 | 97 | if(*address == '\0') { 98 | r |= OSC_MATCH_ADDRESS_COMPLETE; 99 | } 100 | 101 | if(*pattern == '\0') { 102 | r |= OSC_MATCH_PATTERN_COMPLETE; 103 | } 104 | 105 | return r; 106 | } 107 | 108 | static int osc_match_star(const char *pattern, const char *address) 109 | { 110 | const char *address_start = address; 111 | const char *pattern_start = pattern; 112 | int num_stars = 0; 113 | if(*address == '\0') { return 0; } 114 | while(*address != '/' && *address != '\0'){ 115 | address++; 116 | } 117 | while(*pattern != '/' && *pattern != '\0'){ 118 | if(*pattern == '*'){ 119 | num_stars++; 120 | } 121 | pattern++; 122 | } 123 | pattern--; 124 | address--; 125 | switch(num_stars){ 126 | case 1: 127 | { 128 | const char *pp = pattern, *aa = address; 129 | while(*pp != '*'){ 130 | if(!(osc_match_single_char(pp, aa))){ 131 | return 0; 132 | } 133 | if(*pp == ']' || *pp == '}'){ 134 | while(*pp != '[' && *pp != '{'){ 135 | pp--; 136 | } 137 | } 138 | pp--; 139 | aa--; 140 | } 141 | } 142 | break; 143 | case 2: 144 | #if (OSC_MATCH_ENABLE_2STARS == 1) 145 | { 146 | const char *pp = pattern, *aa = address; 147 | while(*pp != '*'){ 148 | if(!(osc_match_single_char(pp, aa))){ 149 | return 0; 150 | } 151 | if(*pp == ']' || *pp == '}'){ 152 | while(*pp != '[' && *pp != '{'){ 153 | pp--; 154 | } 155 | } 156 | pp--; 157 | aa--; 158 | } 159 | aa++; // we want to start one character forward to allow the star to match nothing 160 | const char *star2 = pp; 161 | const char *test = aa; 162 | int i = 0; 163 | while(test > address_start){ 164 | pp = star2 - 1; 165 | aa = test - 1; 166 | i++; 167 | while(*pp != '*'){ 168 | if(!osc_match_single_char(pp, aa)){ 169 | break; 170 | } 171 | if(*pp == ']' || *pp == '}'){ 172 | while(*pp != '[' && *pp != '{'){ 173 | pp--; 174 | } 175 | } 176 | pp--; 177 | aa--; 178 | } 179 | if(pp == pattern_start){ 180 | return 1; 181 | } 182 | test--; 183 | } 184 | return 0; 185 | } 186 | break; 187 | #else 188 | return 0; 189 | #endif 190 | default: 191 | #if (OSC_MATCH_ENABLE_NSTARS == 1) 192 | return osc_match_star_r(pattern_start, address_start); 193 | break; 194 | #else 195 | return 0; 196 | #endif 197 | } 198 | return 1; 199 | } 200 | 201 | #if (OSC_MATCH_ENABLE_NSTARS == 1) 202 | static int osc_match_star_r(const char *pattern, const char *address) 203 | { 204 | if(*address == '/' || *address == '\0'){ 205 | if(*pattern == '/' || *pattern == '\0' || (*pattern == '*' && ((*(pattern + 1) == '/') || *(pattern + 1) == '\0'))){ 206 | return 1; 207 | }else{ 208 | return 0; 209 | } 210 | } 211 | if(*pattern == '*'){ 212 | if(osc_match_star_r(pattern + 1, address)){ 213 | return 1; 214 | }else{ 215 | return osc_match_star_r(pattern, address + 1); 216 | } 217 | }else{ 218 | if(!osc_match_single_char(pattern, address)){ 219 | return 0; 220 | } 221 | if(*pattern == '[' || *pattern == '{'){ 222 | while(*pattern != ']' && *pattern != '}'){ 223 | pattern++; 224 | } 225 | } 226 | return osc_match_star_r(pattern + 1, address + 1); 227 | } 228 | } 229 | #endif 230 | 231 | static int osc_match_single_char(const char *pattern, const char *address) 232 | { 233 | switch(*pattern){ 234 | case '[': 235 | return osc_match_bracket(pattern, address); 236 | case ']': 237 | while(*pattern != '['){ 238 | pattern--; 239 | } 240 | return osc_match_bracket(pattern, address); 241 | case '{': 242 | return osc_match_curly_brace(pattern, address); 243 | case '}': 244 | while(*pattern != '{'){ 245 | pattern--; 246 | } 247 | return osc_match_curly_brace(pattern, address); 248 | case '?': 249 | return 1; 250 | default: 251 | if(*pattern == *address){ 252 | return 1; 253 | }else{ 254 | return 0; 255 | } 256 | } 257 | return 0; 258 | } 259 | 260 | static int osc_match_bracket(const char *pattern, const char *address) 261 | { 262 | pattern++; 263 | int val = 1; 264 | if(*pattern == '!'){ 265 | pattern++; 266 | val = 0; 267 | } 268 | int matched = !val; 269 | while(*pattern != ']' && *pattern != '\0'){ 270 | // the character we're on now is the beginning of a range 271 | if(*(pattern + 1) == '-'){ 272 | if(*address >= *pattern && *address <= *(pattern + 2)){ 273 | matched = val; 274 | break; 275 | }else{ 276 | pattern += 3; 277 | } 278 | }else{ 279 | // just test the character 280 | if(*pattern == *address){ 281 | matched = val; 282 | break; 283 | } 284 | pattern++; 285 | } 286 | } 287 | return matched; 288 | } 289 | 290 | static int osc_match_curly_brace(const char *pattern, const char *address) 291 | { 292 | pattern++; 293 | const char *ptr = pattern; 294 | while(*ptr != '}' && *ptr != '\0' && *ptr != '/'){ 295 | while(*ptr != '}' && *ptr != '\0' && *ptr != '/' && *ptr != ','){ 296 | ptr++; 297 | } 298 | int n = ptr - pattern; 299 | if(!strncmp(pattern, address, n)){ 300 | return n; 301 | }else{ 302 | ptr++; 303 | pattern = ptr; 304 | } 305 | } 306 | return 0; 307 | } -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/OSCMatch.h: -------------------------------------------------------------------------------- 1 | /* 2 | Written by John MacCallum, The Center for New Music and Audio Technologies, 3 | University of California, Berkeley. Copyright (c) 2009, The Regents of 4 | the University of California (Regents). 5 | Permission to use, copy, modify, distribute, and distribute modified versions 6 | of this software and its documentation without fee and without a signed 7 | licensing agreement, is hereby granted, provided that the above copyright 8 | notice, this paragraph and the following two paragraphs appear in all copies, 9 | modifications, and distributions. 10 | 11 | IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, 12 | SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING 13 | OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS 14 | BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 15 | 16 | REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 17 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 | PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED 19 | HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE 20 | MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 21 | */ 22 | 23 | #ifndef __OSC_MATCH_H__ 24 | #define __OSC_MATCH_H__ 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /** 31 | * Switch this off to disable matching against a pattern with 2 stars 32 | */ 33 | //#define OSC_MATCH_ENABLE_2STARS 1 34 | /** 35 | * Switch this off to disable matching against a pattern with more than 2 stars which will 36 | * be done recursively. 37 | */ 38 | //#define OSC_MATCH_ENABLE_NSTARS 1 39 | 40 | /** 41 | * Return code for osc_match() that indicates that the entire address was successfully matched 42 | */ 43 | #define OSC_MATCH_ADDRESS_COMPLETE 1 44 | 45 | /** 46 | * Return code for osc_match() that indicates that the entire pattern was successfully matched 47 | */ 48 | #define OSC_MATCH_PATTERN_COMPLETE 2 49 | /* 50 | typedef struct _osc_callback { 51 | const char* address; // Address 52 | struct _osc_callback *child; // RAM 53 | struct _osc_callback *sibling; // RAM 54 | struct _osc_callback *parent; // RAM 55 | int callback; // ROM 56 | } osc_callback; 57 | */ 58 | 59 | /** 60 | * Match a pattern against an address. In the case of a partial match, pattern_offset 61 | * and address_offset will contain the number of bytes into their respective strings 62 | * where the match failed. 63 | * 64 | * @param pattern The pattern to match 65 | * @param address The address to match 66 | * @param pattern_offset The number of bytes into the pattern that were matched successfully 67 | * @param address_offset The number of bytes into the address that were matched successfully 68 | * @return 0 if the match failed altogether, or an or'd combination of OSC_MATCH_ADDRESS_COMPLETE and 69 | * OSC_MATCH_PATTERN_COMPLETE. 70 | */ 71 | int osc_match(const char *pattern, const char *address, int *pattern_offset, int *address_offset); 72 | 73 | #ifdef __cplusplus 74 | } 75 | #endif 76 | 77 | #endif // __OSC_MATCH_H__ 78 | 79 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/OSCTiming.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Written by Adrian Freed, The Center for New Music and Audio Technologies, 3 | University of California, Berkeley. Copyright (c) 2013, The Regents of 4 | the University of California (Regents). 5 | 6 | Permission to use, copy, modify, distribute, and distribute modified versions 7 | of this software and its documentation without fee and without a signed 8 | licensing agreement, is hereby granted, provided that the above copyright 9 | notice, this paragraph and the following two paragraphs appear in all copies, 10 | modifications, and distributions. 11 | 12 | IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, 13 | SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING 14 | OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS 15 | BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 16 | 17 | REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 18 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 | PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED 20 | HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE 21 | MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 22 | 23 | For bug reports and feature requests please email me at yotam@cnmat.berkeley.edu 24 | */ 25 | 26 | 27 | #include "OSCTiming.h" 28 | #include "OSCBoards.h" 29 | 30 | #if defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MKL26Z64__) 31 | 32 | extern volatile uint32_t systick_millis_count; 33 | static uint32_t savedcount, savedcurrent; 34 | 35 | static void latchOscTime() 36 | { 37 | 38 | uint32_t istatus; 39 | uint32_t count, current; 40 | 41 | __disable_irq(); 42 | current = SYST_CVR; 43 | count = systick_millis_count; 44 | istatus = SCB_ICSR; // bit 26 indicates if systick exception pending 45 | __enable_irq(); 46 | //systick_current = current; 47 | //systick_count = count; 48 | //systick_istatus = istatus & SCB_ICSR_PENDSTSET ? 1 : 0; 49 | if ((istatus & SCB_ICSR_PENDSTSET) && current > 50) count++; 50 | current = ((F_CPU / 1000) - 1) - current; 51 | savedcount=count; savedcurrent=current; 52 | } 53 | static osctime_t computeOscTime() 54 | { //4,294,967,296 55 | 56 | 57 | osctime_t t; 58 | 59 | 60 | t.seconds = (( uint64_t)(savedcount/1000)) ; 61 | 62 | 63 | t.fractionofseconds = ( (uint64_t)(4294967295) * ( (savedcount * 1000 + (uint64_t)savedcurrent / (F_CPU / 1000000UL)) % 1000000) ) /1000000; 64 | return t; 65 | } 66 | 67 | osctime_t oscTime() 68 | { 69 | latchOscTime(); 70 | return computeOscTime(); 71 | } 72 | 73 | #elif defined(CORE_TEENSY) 74 | extern volatile uint32_t timer0_millis_count; 75 | static uint32_t savedcount, savedmicros; 76 | 77 | static void latchOscTime() 78 | { 79 | noInterrupts(); 80 | savedcount = timer0_millis_count; 81 | savedmicros = micros(); 82 | interrupts(); 83 | } 84 | 85 | static osctime_t computeOscTime() 86 | { //4,294,967,296 87 | osctime_t t; 88 | savedmicros %= 1000000; 89 | t.fractionofseconds= (67108864ULL * savedmicros) / 15625 ; // 2^32/1000000 90 | t.seconds = savedcount/1000; 91 | return t; 92 | #ifdef ddfgsdfgsdfgsdfg 93 | return ((savedcount/1000)<<32) + ( (4294967295ULL) * ( (savedcount * 1000ULL + savedmicros) % 1000000ULL) ) /1000000ULL 94 | 95 | ; 96 | #endif 97 | 98 | 99 | } 100 | osctime_t oscTime() 101 | { 102 | latchOscTime(); 103 | return computeOscTime(); 104 | 105 | } 106 | #elif defined(AVR) || defined(__AVR_ATmega32U4__) || defined(__SAM3X8E__) 107 | static uint32_t savedcount, savedmicros; 108 | 109 | 110 | static void latchOscTime() 111 | { 112 | noInterrupts(); 113 | //cli(); 114 | savedcount = millis(); 115 | savedmicros = micros(); 116 | interrupts(); 117 | //sei(); 118 | } 119 | 120 | osctime_t computeOscTime() 121 | { //4,294,967,296 122 | osctime_t t; 123 | savedmicros %= 1000000UL; 124 | // t.fractionofseconds = (67108864ULL * (uint64_t)savedmicros) / 15625ULL ; // 2^32/1000000 125 | t.fractionofseconds= (67108864UL * savedmicros)/ 15625ULL ; // 2^32/1000000 126 | t.seconds = savedcount/1000; 127 | return t; 128 | 129 | 130 | 131 | } 132 | osctime_t oscTime() 133 | { 134 | latchOscTime(); 135 | return computeOscTime(); 136 | } 137 | 138 | #else 139 | 140 | 141 | 142 | static void latchOscTime() 143 | { 144 | } 145 | 146 | osctime_t oscTime() 147 | { 148 | osctime_t t; 149 | t.fractionofseconds = 1; 150 | return t; 151 | 152 | } 153 | #endif 154 | 155 | int adcRead(int pin, osctime_t *t) 156 | { 157 | latchOscTime(); 158 | 159 | int v =analogRead(pin); 160 | *t = oscTime(); 161 | return v; 162 | } 163 | #ifdef BOARD_HAS_CAPACITANCE_SENSING 164 | int capacitanceRead(int pin, osctime_t *t) 165 | { 166 | latchOscTime(); 167 | int v = touchRead(pin); 168 | 169 | *t = oscTime(); 170 | return v; 171 | } 172 | #endif 173 | int inputRead(int pin, osctime_t *t) 174 | { 175 | 176 | int v =digitalRead(pin); 177 | *t = oscTime(); 178 | 179 | return v; 180 | } 181 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/OSCTiming.h: -------------------------------------------------------------------------------- 1 | // 2 | // OSCTiming.h 3 | // 4 | // 5 | // Created by AdrianFreed on 11/10/13. 6 | // 7 | // 8 | 9 | #ifndef ____OSCTiming__ 10 | #define ____OSCTiming__ 11 | 12 | 13 | #include "Arduino.h" 14 | #include 15 | #include 16 | #include 17 | typedef struct 18 | { 19 | uint32_t seconds; 20 | uint32_t fractionofseconds; 21 | } osctime_t; 22 | 23 | osctime_t oscTime(); 24 | int adcRead(int pin, osctime_t *t); 25 | int capacitanceRead(int pin, osctime_t *t); 26 | 27 | int inputRead(int pin, uint64_t *t); 28 | 29 | 30 | #endif /* defined(____OSCTiming__) */ 31 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/README.md: -------------------------------------------------------------------------------- 1 | # OSC for Arduino 2 | 3 | This is an Arduino and Teensy library implementation of the [OSC](http://opensoundcontrol.org) (Open Sound Control) encoding.It was developed primarily by Yotam Mann and Adrian Freed at CNMAT where OSC was invented. It benefits from contributions from John MacCallum, Matt Wright, Jeff Lubow and Andy Schmeder and many beta testers. 4 | 5 | Features: 6 | 7 | * Supports the four basic OSC data types (32-bit integers, 32-bit floats, strings, and blobs - arbitrary length byte sequences) 8 | * Supports the optional 64-bit timetag data type and Booleans 9 | * Address pattern matching 10 | * Dynamic memory allocation 11 | * Sends and receives OSC packets over transport layers that implements the Arduino Stream Class such as Serial and Ethernet UDP 12 | 13 | # Installation 14 | 15 | We recommend Arduino 1.05 or greater and Teensyduino 1.14 or later if you use the Teensy. Download the zip from github. Unzip it and remove text after the "-" in the name (i.e. -master) because the Arduino IDE doesn't allow certain characters in library names. Move the OSC folder into your "libraries" folder in your Arduino Sketch search path. Now you will see OSC examples under the Examples menu of Arduino. 16 | 17 | Additional information about installing libraries on [Arduino's website](https://www.arduino.cc/en/Guide/Libraries). 18 | 19 | # Examples 20 | 21 | The `Applications` folder contains examples for Max/MSP and PD and Processing that work with the example sketches. This will be expanded to include other applications like TouchOSC and Processing. For the Max/MSP examples you will need to download the CNMAT max externals package that includes the "o." objects available [here](http://cnmat.berkeley.edu/downloads). 22 | 23 | # API 24 | 25 | OSC for Arduino supports creating, sending and receiving OSCMessages individually and wrapped into OSCBundles. 26 | 27 | The full API is available [here](./API.md). 28 | 29 | ### Sending Data 30 | 31 | Create a new `OSCMessage` with an address in the constructor: 32 | 33 | ```C++ 34 | OSCMessage msg("/address"); 35 | ``` 36 | 37 | add some data to it: 38 | 39 | ```C++ 40 | msg.add(1); 41 | msg.add(2.0); 42 | msg.add("three"); 43 | ``` 44 | 45 | `add` will infer the type of the data and encode it correctly. The API also supports chaining, so multiple calls to `add` can be strung together: 46 | 47 | ```C++ 48 | msg.add(1).add(2.0f).add("three"); 49 | ``` 50 | 51 | Then send it over any transport layer that extends Arduino's [Print class](http://playground.arduino.cc/Code/Printclass) like the `Serial` out. 52 | 53 | ```C++ 54 | msg.send(Serial); 55 | ``` 56 | 57 | ### Receiving Data 58 | 59 | In a typical Serial stream, there is no way to know where one message ends and another begins. That's why we recommend using `SLIPSerial` (which also comes in the OSC for Arduino Package). Read more about the lightweight [SLIP encoding](https://en.wikipedia.org/wiki/Serial_Line_Internet_Protocol). 60 | 61 | To receive an OSCMessage, wait for the end of SLIP Stream, and fill an empty OSCMessage with the available bytes: 62 | 63 | ```C++ 64 | //make an empty message to fill with the incoming data 65 | OSCMessage msg; 66 | //wait for the end of the packet to be received 67 | while(!SLIPSerial.endofPacket()){ 68 | int size = SLIPSerial.available(); 69 | if (size > 0){ 70 | //fill the msg with all of the available bytes 71 | while(size--){ 72 | msg.fill(SLIPSerial.read()); 73 | } 74 | } 75 | } 76 | ``` 77 | 78 | Now you can query and use the data you received: 79 | 80 | ```C++ 81 | //returns true if the data in the first position is an integer 82 | if (msg.isInt(0)){ 83 | //get that integer 84 | int data = msg.getInt(0); 85 | } 86 | ``` 87 | 88 | ### Routing / Dispatching 89 | 90 | OSCMessages can be routed to a specific function by matching their address exactly or with an OSC pattern. 91 | 92 | `dispatch` will do a full match on the OSCMessage's address or patterned address. 93 | 94 | ```C++ 95 | OSCMessage msg("/a/1"); 96 | msg.dispatch("/a/1", dispatchAddress); 97 | ``` 98 | 99 | And the function definition of `dispatchAddress` could be as follows: 100 | 101 | ```C++ 102 | //called whenever an OSCMessage's address matches "/a/1" 103 | void dispatchAddress(OSCMessage &msg){ 104 | //do something with the OSCMessage... 105 | if (msg.isFloat(0)){ 106 | float val = msg.getFloat(0); 107 | } 108 | } 109 | ``` 110 | 111 | `route` does the same thing as `dispatch` but allows for partial address matching as long as they are aligned to a `/` character. 112 | 113 | ```C++ 114 | OSCMessage msg("/b/2"); 115 | msg.route("/b", routeAddress); 116 | ``` 117 | 118 | ```C++ 119 | //called whenever an OSCMessage's address matches "/b" 120 | void routeAddress(OSCMessage &msg, int addressOffset){ 121 | //do something with the OSCMessage... 122 | if (msg.isBoolean(0)){ 123 | bool val = msg.getBoolean(0); 124 | } 125 | } 126 | ``` 127 | 128 | ### OSCBundles 129 | 130 | An OSCBundle is a group of OSCMessage that can be sent and received together. 131 | 132 | ```C++ 133 | OSCBundle bundle; 134 | //add a new OSCMessage to the bundle with the address "/a" 135 | OSCMessage msgA = bundle.add("/a"); 136 | //add some data to that message 137 | msgA.add("some data"); 138 | //append another OSCMessage, this time chaining 'add' calls 139 | bundle.add("/b").add("some more data").add("even more data"); 140 | ``` 141 | 142 | Now send the OSCBundle over SLIPSerial 143 | 144 | ```C++ 145 | //start a new SLIP Packet 146 | SLIPSerial.beginPacket(); 147 | //send the data 148 | bundle.send(SLIPSerial); 149 | //end the packet 150 | SLIPSerial.endPacket(); 151 | ``` 152 | 153 | ### SLIP Serial 154 | 155 | The OSC for Arduino library includes extensions of the USB serial and Hardware serial functions of the Arduino core that sends and receives data using the SLIP encoding. This makes Max/MSP and PD integration very simple using CNMAT's o.io.slipserial. The SLIPSerial library implements the same methods as the Serial object with additional `beginPacket` and `endPacket` methods to mark the boundaries of each packet in a serial stream. 156 | 157 | When sending data, begin each packet with `SLIPSerial.beginPacket()`, then write any data to the SLIPSerial and signify the end of the packet using `SLIPSerial.endPacket()`. 158 | 159 | On the receiving side, in addition to the normal `read` and `available` methods of the Serial object, SLIPSerial includes `SLIPSerial.endofPacket()` which returns true when the EOT (End Of Transmission) character is received, marking the end of the data packet. 160 | 161 | # Oscuino 162 | 163 | As well as many small examples illustrating the API, there is a larger application called "oscuino" that illustrates how to use OSC to simplify situations Firmata and Maxuino are typically used in. 164 | 165 | # Support 166 | 167 | ### IDEs 168 | 169 | Arduino 1.05 and 1.6.3 (tested for Due Serial and Teensy so far) 170 | 171 | Best Supported Board: 172 | The Teensy 3.0 and 3.1 and LC have the performance and memory that afford rich OSC implementations. 173 | Our primary test platform for new development is the Teensy 3.1 which currently offers the best performance 174 | of any of the Arduinos and variants. We greatly appreciate Paul Stoffregen's ongoing work 175 | with "best practice" engineering of high performance microcontrollers. 176 | 177 | ### Unsupported boards 178 | 179 | Arduino Yun and related openwrt/arduino hybrids (e.g. Draguino): 180 | 181 | Marco Brianza is exploring these interesting approaches to running this OSC library on the Atmel 32u4 in the Yun: 182 | https://github.com/cylinderlight/udp2serial 183 | https://github.com/cylinderlight/udp2serialSPI 184 | 185 | The Yun still lacks the Linux-side support to reliably move data between the 32u4 and the router's cpu. We recommend that you add a Teensy to the USB port of an OpenWrt router to get good performance and reliability with our library. 186 | 187 | # Testing 188 | 189 | OSC for Arduino comes with a small suite of tests to validate its functionality and test compatibility when new platforms come out. The tests are broken into a number of individual `.ino` files located in the `test` folder. 190 | 191 | The tests require [ArduinoUnit](https://github.com/mmurdoch/arduinounit) to be installed in the `libraries` folder. The results of the test are printed to the Serial console. 192 | 193 | Tested on: 194 | 195 | * Esplora 196 | * Leonardo 197 | * Teensy 3.x 198 | * Mega 2560 199 | 200 | # Performance 201 | 202 | Currently best performance is achieved with Arduinos with built-in USB Serial, i.e. Teensy 3.0, Teensy 2.0 and 2.0++ and Leanardo variants (12Mbps max). 203 | 204 | This is because the Wiznet 5100 used in the Ethernet Arduino and shields uses really slow SPI (0.3Mbps). This will change as people retool to use the much faster Wiznet 5200 which has been measured with the Due at 6Mbps. 205 | 206 | References: 207 | * http://forum.pjrc.com/threads/17951-WIZ820io-Ethernet-and-2nd-power-supply-with-teensy-3-0 208 | * http://arduino.cc/forum/index.php?topic=139147.0 209 | 210 | The serial examples use a 9600 baud rate which is reliable on most of the FTDI based Arduinos. The slow rate is required for Arduino's without clock chips such as the TinyLili. Once you have established that things work at 9600 baud you will find it very beneficial to increase the rate. e.g. `Serial.begin(345600); // !! 115200, 230400, 345600, 460800 X` 211 | 212 | # Roadmap 213 | 214 | * support for special OSC types in CNMAT's "o." especially subbundles 215 | * examples for recent OSC support in node.js and Node Red 216 | * nested bundles 217 | * performance tuning 218 | * integrate spark core examples 219 | * Better Time Tags that avoid the overflow limitation of Arduino timer code 220 | * Time Tag synchronization 221 | * Bluetooth LE 222 | * TCP/IP Examples 223 | * examples for more applications (i.e. TouchOSC, Processing with SLIP) 224 | * deadline scheduling of OSC 64-bit timetags 225 | * Support for Arduino WiFi 226 | * ADK support 227 | 228 | We welcome and appreciate your contributions and feedback. 229 | 230 | # New in this release 231 | 232 | * Teensy LC support 233 | * compatibility with latest Arduino IDE and Teensyduino 234 | * Beginnings of support for timetags with initial implementations for teensy 3, teensy 2 and Atmega Arduinos 235 | * Sketches compile also in MPIDE for PIC32's there has been limited testing on the Fubarino MINI 236 | (watch out on this platform: it connects and numbers digital pins in use for USB and clock XTAL!) 237 | * Added Boolean type according to OSC 1.0 optional type spec. (lightly tested) -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/SLIPEncodedSerial.cpp: -------------------------------------------------------------------------------- 1 | #include "SLIPEncodedSerial.h" 2 | 3 | /* 4 | CONSTRUCTOR 5 | */ 6 | //instantiate with the tranmission layer 7 | //use HardwareSerial 8 | SLIPEncodedSerial::SLIPEncodedSerial(HardwareSerial &s){ 9 | serial = &s; 10 | rstate = CHAR; 11 | } 12 | 13 | static const uint8_t eot = 0300; 14 | static const uint8_t slipesc = 0333; 15 | static const uint8_t slipescend = 0334; 16 | static const uint8_t slipescesc = 0335; 17 | /* 18 | SERIAL METHODS 19 | */ 20 | bool SLIPEncodedSerial::endofPacket() 21 | { 22 | if(rstate == SECONDEOT) 23 | { 24 | rstate = CHAR; 25 | return true; 26 | } 27 | if (rstate==FIRSTEOT) 28 | { 29 | if(serial->available()) 30 | { 31 | uint8_t c =serial->peek(); 32 | if(c==eot) 33 | { 34 | serial->read(); // throw it on the floor 35 | } 36 | } 37 | rstate = CHAR; 38 | return true; 39 | } 40 | return false; 41 | } 42 | int SLIPEncodedSerial::available(){ 43 | back: 44 | int cnt = serial->available(); 45 | 46 | if(cnt==0) 47 | return 0; 48 | if(rstate==CHAR) 49 | { 50 | uint8_t c =serial->peek(); 51 | if(c==slipesc) 52 | { 53 | rstate = SLIPESC; 54 | serial->read(); // throw it on the floor 55 | goto back; 56 | } 57 | else if( c==eot) 58 | { 59 | rstate = FIRSTEOT; 60 | serial->read(); // throw it on the floor 61 | goto back; 62 | } 63 | return 1; // we may have more but this is the only sure bet 64 | } 65 | else if(rstate==SLIPESC) 66 | return 1; 67 | else if(rstate==FIRSTEOT) 68 | { 69 | if(serial->peek()==eot) 70 | { 71 | rstate = SECONDEOT; 72 | serial->read(); // throw it on the floor 73 | return 0; 74 | } 75 | rstate = CHAR; 76 | }else if (rstate==SECONDEOT) { 77 | rstate = CHAR; 78 | } 79 | 80 | return 0; 81 | 82 | } 83 | 84 | //reads a byte from the buffer 85 | int SLIPEncodedSerial::read(){ 86 | back: 87 | uint8_t c = serial->read(); 88 | if(rstate==CHAR) 89 | { 90 | if(c==slipesc) 91 | { 92 | rstate=SLIPESC; 93 | goto back; 94 | } 95 | else if(c==eot){ 96 | 97 | return -1; // xxx this is an error 98 | } 99 | return c; 100 | } 101 | else 102 | if(rstate==SLIPESC) 103 | { 104 | rstate=CHAR; 105 | if(c==slipescend) 106 | return eot; 107 | else if(c==slipescesc) 108 | return slipesc; 109 | else { 110 | // insert some error code here 111 | return -1; 112 | } 113 | 114 | } 115 | else 116 | return -1; 117 | } 118 | 119 | // as close as we can get to correct behavior 120 | int SLIPEncodedSerial::peek(){ 121 | uint8_t c = serial->peek(); 122 | if(rstate==SLIPESC) 123 | { 124 | if(c==slipescend) 125 | return eot; 126 | else if(c==slipescesc) 127 | return slipesc; 128 | } 129 | return c; 130 | } 131 | 132 | //the arduino and wiring libraries have different return types for the write function 133 | #if defined(WIRING) || defined(BOARD_DEFS_H) 134 | 135 | //encode SLIP 136 | void SLIPEncodedSerial::write(uint8_t b){ 137 | if(b == eot){ 138 | serial->write(slipesc); 139 | return serial->write(slipescend); 140 | } else if(b==slipesc) { 141 | serial->write(slipesc); 142 | return serial->write(slipescesc); 143 | } else { 144 | return serial->write(b); 145 | } 146 | } 147 | void SLIPEncodedSerial::write(const uint8_t *buffer, size_t size) { while(size--) write(*buffer++); } 148 | #else 149 | //encode SLIP 150 | size_t SLIPEncodedSerial::write(uint8_t b){ 151 | if(b == eot){ 152 | serial->write(slipesc); 153 | return serial->write(slipescend); 154 | } else if(b==slipesc) { 155 | serial->write(slipesc); 156 | return serial->write(slipescesc); 157 | } else { 158 | return serial->write(b); 159 | } 160 | } 161 | size_t SLIPEncodedSerial::write(const uint8_t *buffer, size_t size) { size_t result; while(size--) result = write(*buffer++); return result; } 162 | 163 | #endif 164 | 165 | void SLIPEncodedSerial::begin(unsigned long baudrate){ 166 | serial->begin(baudrate); 167 | } 168 | //SLIP specific method which begins a transmitted packet 169 | void SLIPEncodedSerial::beginPacket() { serial->write(eot); } 170 | 171 | //signify the end of the packet with an EOT 172 | void SLIPEncodedSerial::endPacket(){ 173 | serial->write(eot); 174 | 175 | } 176 | 177 | void SLIPEncodedSerial::flush(){ 178 | serial->flush(); 179 | } 180 | 181 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/SLIPEncodedSerial.h: -------------------------------------------------------------------------------- 1 | /* 2 | Extends the Serial class to encode SLIP over serial 3 | */ 4 | 5 | #ifndef SLIPEncodedSerial_h 6 | #define SLIPEncodedSerial_h 7 | 8 | 9 | #include "Arduino.h" 10 | #include 11 | #include 12 | 13 | 14 | class SLIPEncodedSerial: public Stream{ 15 | 16 | private: 17 | enum erstate {CHAR, FIRSTEOT, SECONDEOT, SLIPESC } rstate; 18 | 19 | //the serial port used 20 | HardwareSerial * serial; 21 | 22 | 23 | public: 24 | 25 | //the serial port used 26 | SLIPEncodedSerial(HardwareSerial & ); 27 | 28 | 29 | int available(); 30 | int read(); 31 | int peek(); 32 | void flush(); 33 | 34 | //same as Serial.begin 35 | void begin(unsigned long); 36 | 37 | //SLIP specific method which begins a transmitted packet 38 | void beginPacket(); 39 | 40 | //SLIP specific method which ends a transmittedpacket 41 | void endPacket(); 42 | // SLIP specific method which indicates that an EOT was received 43 | bool endofPacket(); 44 | 45 | 46 | //the arduino and wiring libraries have different return types for the write function 47 | #if defined(WIRING) || defined(BOARD_DEFS_H) 48 | void write(uint8_t b); 49 | void write(const uint8_t *buffer, size_t size); 50 | 51 | #else 52 | //overrides the Stream's write function to encode SLIP 53 | size_t write(uint8_t b); 54 | size_t write(const uint8_t *buffer, size_t size); 55 | 56 | //using Print::write; 57 | #endif 58 | 59 | }; 60 | 61 | 62 | #endif -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/SLIPEncodedUSBSerial.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "SLIPEncodedUSBSerial.h" 3 | 4 | /* 5 | CONSTRUCTOR 6 | */ 7 | //instantiate with the tranmission layer 8 | 9 | #if (defined(CORE_TEENSY) && defined(USB_SERIAL)) || (!defined(CORE_TEENSY) && defined(__AVR_ATmega32U4__)) || defined(__SAM3X8E__) || (defined(_USB) && defined(_USE_USB_FOR_SERIAL_)) || defined(BOARD_maple_mini) 10 | 11 | 12 | //USB Serials 13 | SLIPEncodedUSBSerial::SLIPEncodedUSBSerial( 14 | 15 | #if defined(CORE_TEENSY) 16 | usb_serial_class 17 | #elif defined(__SAM3X8E__) || defined(__AVR_ATmega32U4__) 18 | Serial_ 19 | #elif defined(__PIC32MX__) || defined(BOARD_maple_mini) 20 | USBSerial 21 | #else 22 | #error unknown platform 23 | #endif 24 | &s){ 25 | serial = &s; 26 | rstate = CHAR; 27 | } 28 | 29 | static const uint8_t eot = 0300; 30 | static const uint8_t slipesc = 0333; 31 | static const uint8_t slipescend = 0334; 32 | static const uint8_t slipescesc = 0335; 33 | /* 34 | SERIAL METHODS 35 | */ 36 | 37 | bool SLIPEncodedUSBSerial::endofPacket() 38 | { 39 | if(rstate == SECONDEOT) 40 | { 41 | rstate = CHAR; 42 | return true; 43 | } 44 | if (rstate==FIRSTEOT) 45 | { 46 | if(serial->available()) 47 | { 48 | uint8_t c =serial->peek(); 49 | if(c==eot) 50 | { 51 | serial->read(); // throw it on the floor 52 | } 53 | } 54 | rstate = CHAR; 55 | return true; 56 | } 57 | return false; 58 | } 59 | int SLIPEncodedUSBSerial::available(){ 60 | back: 61 | int cnt = serial->available(); 62 | 63 | if(cnt==0) 64 | return 0; 65 | if(rstate==CHAR) 66 | { 67 | uint8_t c =serial->peek(); 68 | if(c==slipesc) 69 | { 70 | rstate = SLIPESC; 71 | serial->read(); // throw it on the floor 72 | goto back; 73 | } 74 | else if( c==eot) 75 | { 76 | rstate = FIRSTEOT; 77 | serial->read(); // throw it on the floor 78 | goto back; 79 | } 80 | return 1; // we may have more but this is the only sure bet 81 | } 82 | else if(rstate==SLIPESC) 83 | return 1; 84 | else if(rstate==FIRSTEOT) 85 | { 86 | if(serial->peek()==eot) 87 | { 88 | rstate = SECONDEOT; 89 | serial->read(); // throw it on the floor 90 | return 0; 91 | } 92 | rstate = CHAR; 93 | }else if (rstate==SECONDEOT) { 94 | rstate = CHAR; 95 | } 96 | 97 | return 0; 98 | 99 | } 100 | 101 | //reads a byte from the buffer 102 | int SLIPEncodedUSBSerial::read(){ 103 | back: 104 | uint8_t c = serial->read(); 105 | if(rstate==CHAR) 106 | { 107 | if(c==slipesc) 108 | { 109 | rstate=SLIPESC; 110 | goto back; 111 | } 112 | else if(c==eot){ 113 | 114 | return -1; // xxx this is an error 115 | } 116 | 117 | return c; 118 | } 119 | else 120 | if(rstate==SLIPESC) 121 | { 122 | rstate=CHAR; 123 | if(c==slipescend) 124 | return eot; 125 | else if(c==slipescesc) 126 | return slipesc; 127 | else { 128 | // insert some error code here 129 | return -1; 130 | } 131 | 132 | } 133 | else 134 | return -1; 135 | } 136 | #ifdef FUTUREDEVELOPMENT 137 | int SLIPEncodedUSBSerial::readBytes( uint8_t *buffer, size_t size) 138 | { 139 | int count = 0; 140 | while(!endofPacket() && available() && (size>0)) 141 | { 142 | int c = read(); 143 | if(c>=0) 144 | { 145 | *buffer++ = c; 146 | ++count; 147 | --size; 148 | 149 | } 150 | else 151 | break; 152 | } 153 | return count; 154 | } 155 | #endif 156 | 157 | // as close as we can get to correct behavior 158 | int SLIPEncodedUSBSerial::peek(){ 159 | uint8_t c = serial->peek(); 160 | if(rstate==SLIPESC) 161 | { 162 | if(c==slipescend) 163 | return eot; 164 | else if(c==slipescesc) 165 | return slipesc; 166 | } 167 | return c; 168 | } 169 | 170 | //the arduino and wiring libraries have different return types for the write function 171 | #if defined(WIRING) || defined(BOARD_DEFS_H) 172 | 173 | //encode SLIP 174 | void SLIPEncodedUSBSerial::write(uint8_t b){ 175 | if(b == eot){ 176 | serial->write(slipesc); 177 | return serial->write(slipescend); 178 | } else if(b==slipesc) { 179 | serial->write(slipesc); 180 | return serial->write(slipescesc); 181 | } else { 182 | return serial->write(b); 183 | } 184 | } 185 | 186 | void SLIPEncodedUSBSerial::write(const uint8_t *buffer, size_t size) 187 | { 188 | while(size--) 189 | write(*buffer++); 190 | } 191 | 192 | #else 193 | //encode SLIP 194 | size_t SLIPEncodedUSBSerial::write(uint8_t b){ 195 | if(b == eot){ 196 | serial->write(slipesc); 197 | return serial->write(slipescend); 198 | } else if(b==slipesc) { 199 | serial->write(slipesc); 200 | return serial->write(slipescesc); 201 | } else { 202 | return serial->write(b); 203 | } 204 | } 205 | size_t SLIPEncodedUSBSerial::write(const uint8_t *buffer, size_t size) 206 | { 207 | size_t result; 208 | while(size--) 209 | result = write(*buffer++); return result; 210 | } 211 | #endif 212 | 213 | void SLIPEncodedUSBSerial::begin(unsigned long baudrate){ 214 | serial->begin(baudrate); 215 | } 216 | //SLIP specific method which begins a transmitted packet 217 | void SLIPEncodedUSBSerial::beginPacket() { serial->write(eot); } 218 | 219 | //signify the end of the packet with an EOT 220 | void SLIPEncodedUSBSerial::endPacket(){ 221 | serial->write(eot); 222 | #if defined(CORE_TEENSY) 223 | serial->send_now(); 224 | #endif 225 | } 226 | 227 | void SLIPEncodedUSBSerial::flush(){ 228 | serial->flush(); 229 | } 230 | #endif 231 | 232 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/SLIPEncodedUSBSerial.h: -------------------------------------------------------------------------------- 1 | /* 2 | Extends the Serial class to encode SLIP over serial 3 | */ 4 | #include "Arduino.h" 5 | 6 | #ifndef SLIPEncodedUSBSerial_h 7 | #define SLIPEncodedUSBSerial_h 8 | 9 | 10 | #include 11 | 12 | 13 | #if (defined(CORE_TEENSY) && defined(USB_SERIAL)) || (!defined(CORE_TEENSY) && defined(__AVR_ATmega32U4__)) || defined(__SAM3X8E__) || (defined(_USB) && defined(_USE_USB_FOR_SERIAL_)) || defined(BOARD_maple_mini) 14 | 15 | 16 | //import the serial USB object 17 | #if defined (__MK20DX128__) || defined (__MK20DX512__) || defined(BOARD_maple_mini) || defined(CORE_TEENSY) 18 | #include 19 | #elif defined(__SAM3X8E__) 20 | #include 21 | #elif defined(__PIC32MX__) 22 | #include "HardwareSerial.h" 23 | #elif defined(__AVR_ATmega32U4__) 24 | // leonardo 25 | //#include "Platform.h" 26 | #include "USBAPI.h" 27 | #include 28 | #else 29 | #error Unknown USB port 30 | #endif 31 | 32 | 33 | 34 | class SLIPEncodedUSBSerial: public Stream{ 35 | 36 | private: 37 | enum erstate {CHAR, FIRSTEOT, SECONDEOT, SLIPESC } rstate; 38 | //different type for each platform 39 | 40 | #if defined(CORE_TEENSY) 41 | usb_serial_class 42 | #elif defined(__SAM3X8E__) || defined(__AVR_ATmega32U4__) 43 | Serial_ 44 | #elif defined(__PIC32MX__) || defined(BOARD_maple_mini) 45 | USBSerial 46 | #else 47 | #error Unknown USBserial type 48 | #endif 49 | * serial; 50 | 51 | public: 52 | SLIPEncodedUSBSerial( 53 | //different constructor for each platform 54 | #if defined(CORE_TEENSY) 55 | usb_serial_class 56 | #elif defined(__SAM3X8E__) || defined(__AVR_ATmega32U4__) 57 | Serial_ 58 | #elif defined(__PIC32MX__) || defined(BOARD_maple_mini) 59 | USBSerial 60 | #else 61 | #error Unknown USBserial type 62 | #endif 63 | & ); 64 | 65 | int available(); 66 | int read(); 67 | int readBytes( uint8_t *buffer, size_t size); 68 | 69 | int peek(); 70 | void flush(); 71 | 72 | //same as Serial.begin 73 | void begin(unsigned long); 74 | //SLIP specific method which begins a transmitted packet 75 | void beginPacket(); 76 | //SLIP specific method which ends a transmittedpacket 77 | void endPacket(); 78 | // SLIP specific method which indicates that an EOT was received 79 | bool endofPacket(); 80 | 81 | 82 | //the arduino and wiring libraries have different return types for the write function 83 | #if defined(WIRING) || defined(BOARD_DEFS_H) 84 | void write(uint8_t b); 85 | void write(const uint8_t *buffer, size_t size); 86 | 87 | #else 88 | //overrides the Stream's write function to encode SLIP 89 | size_t write(uint8_t b); 90 | size_t write(const uint8_t *buffer, size_t size); 91 | //using Print::write; 92 | #endif 93 | 94 | }; 95 | #endif 96 | 97 | 98 | 99 | #endif -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/examples/ESP8266ReceiveBundle/ESP8266ReceiveBundle.ino: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------------------- 2 | 3 | Open Sound Control (OSC) library for the ESP8266 4 | 5 | Example for receiving open sound control (OSC) bundles on the ESP8266 6 | Send integers '0' or '1' to the address "/led" to turn on/off the built-in LED of the esp8266. 7 | 8 | This example code is in the public domain. 9 | 10 | --------------------------------------------------------------------------------------------- */ 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | char ssid[] = "*****************"; // your network SSID (name) 18 | char pass[] = "*******"; // your network password 19 | 20 | // A UDP instance to let us send and receive packets over UDP 21 | WiFiUDP Udp; 22 | const IPAddress outIp(10,40,10,105); // remote IP (not needed for receive) 23 | const unsigned int outPort = 9999; // remote port (not needed for receive) 24 | const unsigned int localPort = 8888; // local port to listen for UDP packets (here's where we send the packets) 25 | 26 | 27 | OSCErrorCode error; 28 | unsigned int ledState = LOW; // LOW means led is *on* 29 | 30 | void setup() { 31 | pinMode(BUILTIN_LED, OUTPUT); 32 | digitalWrite(BUILTIN_LED, ledState); // turn *on* led 33 | 34 | Serial.begin(115200); 35 | 36 | // Connect to WiFi network 37 | Serial.println(); 38 | Serial.println(); 39 | Serial.print("Connecting to "); 40 | Serial.println(ssid); 41 | WiFi.begin(ssid, pass); 42 | 43 | while (WiFi.status() != WL_CONNECTED) { 44 | delay(500); 45 | Serial.print("."); 46 | } 47 | Serial.println(""); 48 | 49 | Serial.println("WiFi connected"); 50 | Serial.println("IP address: "); 51 | Serial.println(WiFi.localIP()); 52 | 53 | Serial.println("Starting UDP"); 54 | Udp.begin(localPort); 55 | Serial.print("Local port: "); 56 | Serial.println(Udp.localPort()); 57 | 58 | } 59 | 60 | 61 | void led(OSCMessage &msg) { 62 | ledState = msg.getInt(0); 63 | digitalWrite(BUILTIN_LED, ledState); 64 | Serial.print("/led: "); 65 | Serial.println(ledState); 66 | } 67 | 68 | void loop() { 69 | OSCBundle bundle; 70 | int size = Udp.parsePacket(); 71 | 72 | if (size > 0) { 73 | while (size--) { 74 | bundle.fill(Udp.read()); 75 | } 76 | if (!bundle.hasError()) { 77 | bundle.dispatch("/led", led); 78 | } else { 79 | error = bundle.getError(); 80 | Serial.print("error: "); 81 | Serial.println(error); 82 | } 83 | } 84 | } 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/examples/ESP8266sendMessage/ESP8266sendMessage.ino: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------------------- 2 | 3 | Open Sound Control (OSC) library for the ESP8266 4 | 5 | Example for sending messages from the ESP8266 to a remote computer 6 | The example is sending "hello, osc." to the address "/test". 7 | 8 | This example code is in the public domain. 9 | 10 | --------------------------------------------------------------------------------------------- */ 11 | #include 12 | #include 13 | #include 14 | 15 | char ssid[] = "*****************"; // your network SSID (name) 16 | char pass[] = "*******"; // your network password 17 | 18 | WiFiUDP Udp; // A UDP instance to let us send and receive packets over UDP 19 | const IPAddress outIp(10,40,10,105); // remote IP of your computer 20 | const unsigned int outPort = 9999; // remote port to receive OSC 21 | const unsigned int localPort = 8888; // local port to listen for OSC packets (actually not used for sending) 22 | 23 | void setup() { 24 | Serial.begin(115200); 25 | 26 | // Connect to WiFi network 27 | Serial.println(); 28 | Serial.println(); 29 | Serial.print("Connecting to "); 30 | Serial.println(ssid); 31 | WiFi.begin(ssid, pass); 32 | 33 | while (WiFi.status() != WL_CONNECTED) { 34 | delay(500); 35 | Serial.print("."); 36 | } 37 | Serial.println(""); 38 | 39 | Serial.println("WiFi connected"); 40 | Serial.println("IP address: "); 41 | Serial.println(WiFi.localIP()); 42 | 43 | Serial.println("Starting UDP"); 44 | Udp.begin(localPort); 45 | Serial.print("Local port: "); 46 | Serial.println(Udp.localPort()); 47 | 48 | } 49 | 50 | void loop() { 51 | OSCMessage msg("/test"); 52 | msg.add("hello, osc."); 53 | Udp.beginPacket(outIp, outPort); 54 | msg.send(Udp); 55 | Udp.endPacket(); 56 | msg.empty(); 57 | delay(500); 58 | } 59 | 60 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/examples/PatternMatching/PatternMatching.ino: -------------------------------------------------------------------------------- 1 | /* 2 | The library has four methods for doing pattern matching on address. 3 | 'match' and 'fullMatch' are specific to OSCMessages while route and dispatch work on both messages and bundles. 4 | 5 | OSCMessage: 6 | match - matches the message's address pattern against an address. returns the number of characters matched from the address passed in. 7 | fullMatch - returns true if the pattern was a complete match against the address 8 | 9 | OSCMessage && OSCBundle: 10 | route - calls a function with the matched OSCMessage(s) and the number of matched characters in the address as the parameters 11 | dispatch - calls a function with each OSCMessage which was fully matched by the pattern 12 | 13 | /////////////////////////////////////////////////////////////////////////////////////////////////// 14 | OSC Regular expression pattern matching rules from http://opensoundcontrol.org/spec-1_0 15 | 16 | 1. '?' in the OSC Address Pattern matches any single character 17 | 2. '*' in the OSC Address Pattern matches any sequence of zero or more characters 18 | 3. A string of characters in square brackets (e.g., "[string]") in the OSC Address Pattern matches any character in the string. 19 | Inside square brackets, the minus sign (-) and exclamation point (!) have special meanings: 20 | two characters separated by a minus sign indicates the range of characters between the given two in ASCII collating sequence. 21 | An exclamation point at the beginning of a bracketed string negates the sense of the list, meaning that the list matches any character not in the list. 22 | 4. A comma-separated list of strings enclosed in curly braces (e.g., "{foo,bar}") in the OSC Address Pattern matches any of the strings in the list. 23 | 5. Any other character in an OSC Address Pattern can match only the same character. 24 | /////////////////////////////////////////////////////////////////////////////////////////////////// 25 | */ 26 | 27 | #include 28 | 29 | void setup() { 30 | Serial.begin(38400); 31 | } 32 | 33 | void loop(){ 34 | //a heavily patterned message address 35 | OSCMessage msg0("/{input,output}/[0-2]/[!ab]/*"); 36 | //match will traverse as far as it can in the pattern 37 | //it returns the number of characters matched from the pattern 38 | int patternOffset = msg0.match("/input/1"); 39 | if (patternOffset>0){ 40 | //string multiple 'match' methods together using the pattern offset parameter to continue matching where it left off 41 | //use 'fullMatch' to test if the entire pattern was matched. 42 | if(msg0.fullMatch("/c/anything", patternOffset)){ 43 | Serial.println("Match: '/input/1/c/anything' against the pattern '/{input,output}/[0-2]/[abc]/*'"); 44 | } 45 | } 46 | //write over the other message address 47 | OSCMessage msg1("/partialMatch"); 48 | //match will return 0 if it did not reach the end or a '/' 49 | if(!msg1.match("/partial")){ 50 | Serial.println("No Match: '/partial' against the pattern '/partialMatch'"); 51 | } 52 | OSCMessage msg2("/output/[0-2]"); 53 | //'route' is uses 'match' to allow for partial matches 54 | //it invokes the callback with the matched message and the pattern offset as parameters to the callback 55 | msg2.route("/output", routeOutput); 56 | //'dispatch' uses 'fullMatch' so it does not allow for partial matches 57 | //invokes the callback with only one argument which is the matched message 58 | msg2.dispatch("/output/1", routeOutputOne); 59 | delay(1000); 60 | } 61 | 62 | //called after matching '/output' 63 | //the matched message and the number of matched characters as the parameters 64 | void routeOutput(OSCMessage &msg, int patternOffset){ 65 | Serial.println("Match: '/output'"); 66 | //string multiple 'route' methods together using the pattern offset parameter. 67 | msg.route("/0", routeZero, patternOffset); 68 | } 69 | 70 | //called after matching '/0' 71 | void routeZero(OSCMessage &msg, int addressOffset){ 72 | Serial.println("Match: '/output/0'"); 73 | } 74 | 75 | //called after matching '/output/1' 76 | void routeOutputOne(OSCMessage &msg){ 77 | Serial.println("Match: '/output/1'"); 78 | } 79 | 80 | 81 | /** 82 | * 83 | * TROUBLESHOOTING: 84 | * Because of a bug in the Arduino IDE, it sometimes thinks that the '*' in combination with '/' is the opening or closing of a multiline comment 85 | * This can be fixed by escaping the '/' with '\' or using the octal value of '*' which is '\052' 86 | * for example: 87 | * "/*" == "/\052" == "\/*" 88 | * 89 | **/ 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/examples/SerialCallResponse/SerialCallResponse.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Serial Call Response 3 | Send responses to calls for information from a remote host 4 | */ 5 | 6 | #include 7 | #include 8 | 9 | #ifdef BOARD_HAS_USB_SERIAL 10 | #include 11 | SLIPEncodedUSBSerial SLIPSerial( thisBoardsSerialUSB ); 12 | #else 13 | #include 14 | SLIPEncodedSerial SLIPSerial(Serial1); 15 | #endif 16 | 17 | OSCBundle bundleOUT; 18 | 19 | /** 20 | * ANALOG 21 | * 22 | * called when the address matches "/a" 23 | * 24 | * format: 25 | * /analog/(pin) 26 | * /u = analogRead with pullup 27 | * 28 | **/ 29 | 30 | void routeAnalog(OSCMessage &msg, int addrOffset ){ 31 | int pinMatched; 32 | pinMatched = msg.match("/0", addrOffset); 33 | if(pinMatched){ 34 | if (msg.fullMatch("/u", pinMatched+addrOffset)) pinMode(analogInputToDigitalPin(0), INPUT_PULLUP); //set the pullup 35 | //do the analog read and send the results 36 | bundleOUT.add("/analog/0").add((int32_t)analogRead(0)); 37 | } 38 | pinMatched = msg.match("/1", addrOffset); 39 | if(pinMatched){ 40 | if (msg.fullMatch("/u", pinMatched+addrOffset)) pinMode(analogInputToDigitalPin(1), INPUT_PULLUP); //set the pullup 41 | //do the analog read and send the results 42 | bundleOUT.add("/analog/1").add((int32_t)analogRead(1)); 43 | } 44 | pinMatched = msg.match("/2", addrOffset); 45 | if(pinMatched){ 46 | if (msg.fullMatch("/u", pinMatched+addrOffset)) pinMode(analogInputToDigitalPin(2), INPUT_PULLUP); //set the pullup 47 | //do the analog read and send the results 48 | bundleOUT.add("/analog/2").add((int32_t)analogRead(2)); 49 | } 50 | pinMatched = msg.match("/3", addrOffset); 51 | if(pinMatched){ 52 | if (msg.fullMatch("/u", pinMatched+addrOffset)) pinMode(analogInputToDigitalPin(3), INPUT_PULLUP); //set the pullup 53 | //do the analog read and send the results 54 | bundleOUT.add("/analog/3").add((int32_t)analogRead(3)); 55 | } 56 | pinMatched = msg.match("/4", addrOffset); 57 | if(pinMatched){ 58 | if (msg.fullMatch("/u", pinMatched+addrOffset)) pinMode(analogInputToDigitalPin(4), INPUT_PULLUP); //set the pullup 59 | //do the analog read and send the results 60 | bundleOUT.add("/analog/4").add((int32_t)analogRead(4)); 61 | } 62 | pinMatched = msg.match("/5", addrOffset); 63 | if(pinMatched){ 64 | if (msg.fullMatch("/u", pinMatched+addrOffset)) pinMode(analogInputToDigitalPin(5), INPUT_PULLUP); //set the pullup 65 | //do the analog read and send the results 66 | bundleOUT.add("/analog/5").add((int32_t)analogRead(5)); 67 | } 68 | } 69 | 70 | /** 71 | * MAIN METHODS 72 | * 73 | * setup and loop, bundle receiving/sending, initial routing 74 | */ 75 | void setup() { 76 | SLIPSerial.begin(9600); // set this as high as you can reliably run on your platform 77 | #if ARDUINO >= 100 78 | while(!Serial) 79 | ; // Leonardo bug 80 | #endif 81 | 82 | 83 | } 84 | 85 | //reads and routes the incoming messages 86 | void loop(){ 87 | OSCBundle bundleIN; 88 | 89 | int size; 90 | 91 | while(!SLIPSerial.endofPacket()) 92 | if ((size =SLIPSerial.available()) > 0) 93 | { 94 | while(size--) 95 | bundleIN.fill(SLIPSerial.read()); 96 | } 97 | if(!bundleIN.hasError()) 98 | { 99 | bundleIN.route("/analog", routeAnalog); 100 | //send the outgoing response message 101 | SLIPSerial.beginPacket(); 102 | bundleOUT.send(SLIPSerial); 103 | SLIPSerial.endPacket(); 104 | bundleOUT.empty(); // empty the bundle ready to use for new messages 105 | } 106 | } 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/examples/SerialEcho/SerialEcho.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Serial USB ports are bidirectional. 4 | 5 | This example can be extended to build routers and forwarders of OSC packets 6 | */ 7 | 8 | #include 9 | 10 | #ifdef BOARD_HAS_USB_SERIAL 11 | #include 12 | SLIPEncodedUSBSerial SLIPSerial( thisBoardsSerialUSB ); 13 | #else 14 | #include 15 | SLIPEncodedSerial SLIPSerial(Serial1); 16 | #endif 17 | 18 | void setup() { 19 | //begin SLIPSerial just like Serial 20 | SLIPSerial.begin(9600); // set this as high as you can reliably run on your platform 21 | #if ARDUINO >= 100 22 | while(!Serial) 23 | ; // Leonardo bug 24 | #endif 25 | 26 | } 27 | 28 | void loop(){ 29 | OSCBundle bndl; 30 | int size; 31 | //receive a bundle 32 | 33 | while(!SLIPSerial.endofPacket()) 34 | if( (size =SLIPSerial.available()) > 0) 35 | { 36 | while(size--) 37 | bndl.fill(SLIPSerial.read()); 38 | } 39 | 40 | if(!bndl.hasError()) 41 | { 42 | static int32_t sequencenumber=0; 43 | // we can sneak an addition onto the end of the bundle 44 | bndl.add("/micros").add((int32_t)micros()); // (int32_t) is the type of OSC Integers 45 | bndl.add("/sequencenumber").add(sequencenumber++); 46 | bndl.add("/digital/5").add(digitalRead(5)==HIGH); 47 | bndl.add("/lsb").add((sequencenumber &1)==1); 48 | SLIPSerial.beginPacket(); // mark the beginning of the OSC Packet 49 | bndl.send(SLIPSerial); 50 | SLIPSerial.endPacket(); 51 | } 52 | } 53 | 54 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/examples/SerialReceive/SerialReceive.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Set the LED according to incoming OSC control 3 | */ 4 | #include 5 | #include 6 | 7 | #ifdef BOARD_HAS_USB_SERIAL 8 | #include 9 | SLIPEncodedUSBSerial SLIPSerial( thisBoardsSerialUSB ); 10 | #else 11 | #include 12 | SLIPEncodedSerial SLIPSerial(Serial1); 13 | #endif 14 | 15 | void LEDcontrol(OSCMessage &msg) 16 | { 17 | if (msg.isInt(0)) 18 | { 19 | pinMode(LED_BUILTIN, OUTPUT); 20 | digitalWrite(LED_BUILTIN, (msg.getInt(0) > 0)? HIGH: LOW); 21 | } 22 | else if(msg.isString(0)) 23 | { 24 | int length=msg.getDataLength(0); 25 | if(length<5) 26 | { 27 | char str[length]; 28 | msg.getString(0,str,length); 29 | if((strcmp("on", str)==0)|| (strcmp("On",str)==0)) 30 | { 31 | pinMode(LED_BUILTIN, OUTPUT); 32 | digitalWrite(LED_BUILTIN, HIGH); 33 | } 34 | else if((strcmp("Of", str)==0)|| (strcmp("off",str)==0)) 35 | { 36 | pinMode(LED_BUILTIN, OUTPUT); 37 | digitalWrite(LED_BUILTIN, LOW); 38 | } 39 | } 40 | } 41 | 42 | } 43 | 44 | 45 | void setup() { 46 | SLIPSerial.begin(9600); // set this as high as you can reliably run on your platform 47 | #if ARDUINO >= 100 48 | while(!Serial) 49 | ; // Leonardo bug 50 | #endif 51 | 52 | } 53 | //reads and dispatches the incoming message 54 | void loop(){ 55 | OSCBundle bundleIN; 56 | int size; 57 | 58 | while(!SLIPSerial.endofPacket()) 59 | if( (size =SLIPSerial.available()) > 0) 60 | { 61 | while(size--) 62 | bundleIN.fill(SLIPSerial.read()); 63 | } 64 | 65 | if(!bundleIN.hasError()) 66 | bundleIN.dispatch("/led", LEDcontrol); 67 | 68 | } 69 | 70 | 71 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/examples/SerialReceivewithServo/SerialReceivewithServo.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Control a servo according to incoming OSC control 3 | * 4 | */ 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | #ifdef BOARD_HAS_USB_SERIAL 11 | #include 12 | SLIPEncodedUSBSerial SLIPSerial( thisBoardsSerialUSB ); 13 | #else 14 | #include 15 | SLIPEncodedSerial SLIPSerial(Serial1); 16 | #endif 17 | 18 | Servo myservo; 19 | 20 | void servoControl(OSCMessage &msg) 21 | { 22 | if (msg.isInt(0)) 23 | { 24 | myservo.write(msg.getInt(0)); 25 | } 26 | #ifdef TEMPoraray 27 | else if (msg.isFloat(0)) 28 | { 29 | //test if that pin is a PWM 30 | if (digitalPinHasPWM(LED_BUILTIN)) 31 | { 32 | pinMode(LED_BUILTIN, OUTPUT); 33 | analogWrite(LED_BUILTIN, (int)(msg.getFloat(0)*127.0f)); 34 | } 35 | else 36 | SoftPWMSet(LED_BUILTIN, (int)(msg.getFloat(0)*127.0f)); 37 | } 38 | #endif 39 | 40 | } 41 | 42 | void setup() { 43 | SLIPSerial.begin(9600); 44 | 45 | myservo.attach(13); 46 | myservo.write(90); 47 | 48 | #if ARDUINO >= 100 49 | while(!Serial) 50 | ; // Leonardo bug 51 | #endif 52 | 53 | 54 | } 55 | //reads and dispatches the incoming message 56 | void loop(){ 57 | OSCBundle bundleIN; 58 | int size; 59 | 60 | while(!SLIPSerial.endofPacket()) 61 | if( (size =SLIPSerial.available()) > 0) 62 | { 63 | while(size--) 64 | bundleIN.fill(SLIPSerial.read()); 65 | } 66 | 67 | if(!bundleIN.hasError()) 68 | bundleIN.dispatch("/servo", servoControl); 69 | 70 | } 71 | 72 | 73 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/examples/SerialSendBundle/SerialSendBundle.ino: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | Make an OSC bundle and send it over SLIP serial 4 | 5 | OSCBundles allow OSCMessages to be grouped together to preserve the order and completeness of related messages. 6 | They also allow for timetags to be carried to represent the presentation time of the messages. 7 | */ 8 | #include 9 | #include 10 | 11 | #ifdef BOARD_HAS_USB_SERIAL 12 | #include 13 | SLIPEncodedUSBSerial SLIPSerial( thisBoardsSerialUSB ); 14 | #else 15 | #include 16 | SLIPEncodedSerial SLIPSerial(Serial1); 17 | #endif 18 | 19 | 20 | void setup() { 21 | //begin SLIPSerial just like Serial 22 | SLIPSerial.begin(9600); // set this as high as you can reliably run on your platform 23 | #if ARDUINO >= 100 24 | while(!Serial) 25 | ; // Leonardo bug 26 | #endif 27 | 28 | } 29 | 30 | void loop(){ 31 | //declare the bundle 32 | OSCBundle bndl; 33 | //BOSCBundle's add' returns the OSCMessage so the message's 'add' can be composed together 34 | bndl.add("/analog/0").add((int32_t)analogRead(0)); 35 | bndl.add("/analog/1").add((int32_t)analogRead(1)); 36 | bndl.add("/digital/5").add((digitalRead(5)==HIGH)?"HIGH":"LOW"); 37 | 38 | 39 | SLIPSerial.beginPacket(); 40 | bndl.send(SLIPSerial); // send the bytes to the SLIP stream 41 | SLIPSerial.endPacket(); // mark the end of the OSC Packet 42 | bndl.empty(); // empty the bundle to free room for a new one 43 | 44 | bndl.add("/mouse/step").add((int32_t)analogRead(0)).add((int32_t)analogRead(1)); 45 | bndl.add("/units").add("pixels"); 46 | SLIPSerial.beginPacket(); 47 | bndl.send(SLIPSerial); // send the bytes to the SLIP stream 48 | SLIPSerial.endPacket(); // mark the end of the OSC Packet 49 | bndl.empty(); // empty the bundle to free room for a new one 50 | 51 | delay(100); 52 | } 53 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/examples/SerialSendBundleWithTimeTag/SerialSendBundleWithTimeTag.ino: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | Make an OSC bundle and send it over SLIP serial 4 | 5 | OSCBundles allow OSCMessages to be grouped together to preserve the order and completeness of related messages. 6 | They also allow for timetags to be carried to represent the presentation time of the messages. 7 | */ 8 | #include 9 | #include 10 | #include 11 | 12 | #ifdef BOARD_HAS_USB_SERIAL 13 | #include 14 | SLIPEncodedUSBSerial SLIPSerial( thisBoardsSerialUSB ); 15 | #else 16 | #include 17 | SLIPEncodedSerial SLIPSerial(Serial1); 18 | #endif 19 | 20 | 21 | void setup() { 22 | //begin SLIPSerial just like Serial 23 | SLIPSerial.begin(9600); // set this as high as you can reliably run on your platform 24 | #if ARDUINO >= 100 25 | while(!Serial) 26 | ; // Leonardo bug 27 | #endif 28 | 29 | } 30 | 31 | void loop(){ 32 | //declare the bundle 33 | OSCBundle bndl; 34 | osctime_t timetag; 35 | 36 | //OSCBundle's add' returns the OSCMessage so the message's 'add' can be composed together 37 | bndl.add("/analog/0").add((int32_t)adcRead(0, &timetag)); 38 | bndl.add("/analog/0/time").add(timetag); 39 | 40 | bndl.add("/analog/1").add((int32_t)adcRead(1, &timetag)); 41 | bndl.add("/analog/1/time").add(timetag); 42 | 43 | bndl.add("/digital/5").add((digitalRead(5)==HIGH)?"HIGH":"LOW"); 44 | 45 | SLIPSerial.beginPacket(); 46 | bndl.setTimetag(oscTime()); 47 | bndl.send(SLIPSerial); // send the bytes to the SLIP stream 48 | SLIPSerial.endPacket(); // mark the end of the OSC Packet 49 | bndl.empty(); // empty the bundle to free room for a new one 50 | 51 | delay(100); 52 | } 53 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/examples/SerialSendMessage/SerialSendMessage.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* 4 | Make an OSC message and send it over serial 5 | */ 6 | 7 | #ifdef BOARD_HAS_USB_SERIAL 8 | #include 9 | SLIPEncodedUSBSerial SLIPSerial( thisBoardsSerialUSB ); 10 | #else 11 | #include 12 | SLIPEncodedSerial SLIPSerial(Serial1); 13 | #endif 14 | 15 | 16 | void setup() { 17 | //begin SLIPSerial just like Serial 18 | SLIPSerial.begin(9600); // set this as high as you can reliably run on your platform 19 | #if ARDUINO >= 100 20 | while(!Serial) 21 | ; //Leonardo "feature" 22 | #endif 23 | } 24 | 25 | 26 | void loop(){ 27 | //the message wants an OSC address as first argument 28 | OSCMessage msg("/analog/0"); 29 | msg.add((int32_t)analogRead(0)); 30 | 31 | SLIPSerial.beginPacket(); 32 | msg.send(SLIPSerial); // send the bytes to the SLIP stream 33 | SLIPSerial.endPacket(); // mark the end of the OSC Packet 34 | msg.empty(); // free space occupied by message 35 | 36 | delay(20); 37 | } 38 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/examples/UDPCallResponse/UDPCallResponse.ino: -------------------------------------------------------------------------------- 1 | /* 2 | UDP Call Response 3 | 4 | Send responses to calls for information from a remote host 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | //UDP communication 14 | EthernetUDP Udp; 15 | 16 | //the Arduino's IP 17 | IPAddress ip(128, 32, 122, 252); 18 | 19 | //port numbers 20 | const unsigned int inPort = 8888; 21 | const unsigned int outPort = 9999; 22 | 23 | 24 | //everything on the network needs a unique MAC 25 | #if defined(__MK20DX128__) 26 | // Teensy 3 has MAC burned in 27 | static byte mac[6]; 28 | void read(uint8_t word, uint8_t *mac, uint8_t offset) { 29 | FTFL_FCCOB0 = 0x41; // Selects the READONCE command 30 | FTFL_FCCOB1 = word; // read the given word of read once area 31 | 32 | // launch command and wait until complete 33 | FTFL_FSTAT = FTFL_FSTAT_CCIF; 34 | while(!(FTFL_FSTAT & FTFL_FSTAT_CCIF)); 35 | 36 | *(mac+offset) = FTFL_FCCOB5; // collect only the top three bytes, 37 | *(mac+offset+1) = FTFL_FCCOB6; // in the right orientation (big endian). 38 | *(mac+offset+2) = FTFL_FCCOB7; // Skip FTFL_FCCOB4 as it's always 0. 39 | } 40 | void read_mac() { 41 | read(0xe,mac,0); 42 | read(0xf,mac,3); 43 | } 44 | #else 45 | void read_mac() {} 46 | byte mac[] = { 47 | 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // you can find this written on the board of some Arduino Ethernets or shields 48 | #endif 49 | 50 | //outgoing messages 51 | 52 | OSCBundle bundleOUT; 53 | 54 | //converts the pin to an osc address 55 | char * numToOSCAddress( int pin){ 56 | static char s[10]; 57 | int i = 9; 58 | 59 | s[i--]= '\0'; 60 | do 61 | { 62 | s[i] = "0123456789"[pin % 10]; 63 | --i; 64 | pin /= 10; 65 | } 66 | while(pin && i); 67 | s[i] = '/'; 68 | return &s[i]; 69 | } 70 | 71 | /** 72 | * ANALOG 73 | * 74 | * called when the address matches "/a" 75 | * 76 | * format: 77 | * /analog/(pin) 78 | * /u = analogRead with pullup 79 | * 80 | **/ 81 | 82 | void routeAnalog(OSCMessage &msg, int addrOffset ){ 83 | int pinMatched; 84 | pinMatched = msg.match("/0", addrOffset); 85 | if(pinMatched){ 86 | if (msg.fullMatch("/u", pinMatched+addrOffset)) pinMode(analogInputToDigitalPin(0), INPUT_PULLUP); //set the pullup 87 | //do the analog read and send the results 88 | bundleOUT.add("/analog/0").add((int32_t)analogRead(0)); 89 | } 90 | pinMatched = msg.match("/1", addrOffset); 91 | if(pinMatched){ 92 | if (msg.fullMatch("/u", pinMatched+addrOffset)) pinMode(analogInputToDigitalPin(1), INPUT_PULLUP); //set the pullup 93 | //do the analog read and send the results 94 | bundleOUT.add("/analog/1").add((int32_t)analogRead(1)); 95 | } 96 | pinMatched = msg.match("/2", addrOffset); 97 | if(pinMatched){ 98 | if (msg.fullMatch("/u", pinMatched+addrOffset)) pinMode(analogInputToDigitalPin(2), INPUT_PULLUP); //set the pullup 99 | //do the analog read and send the results 100 | bundleOUT.add("/analog/2").add((int32_t)analogRead(2)); 101 | } 102 | pinMatched = msg.match("/3", addrOffset); 103 | if(pinMatched){ 104 | if (msg.fullMatch("/u", pinMatched+addrOffset)) pinMode(analogInputToDigitalPin(3), INPUT_PULLUP); //set the pullup 105 | //do the analog read and send the results 106 | bundleOUT.add("/analog/3").add((int32_t)analogRead(3)); 107 | } 108 | pinMatched = msg.match("/4", addrOffset); 109 | if(pinMatched){ 110 | if (msg.fullMatch("/u", pinMatched+addrOffset)) pinMode(analogInputToDigitalPin(4), INPUT_PULLUP); //set the pullup 111 | //do the analog read and send the results 112 | bundleOUT.add("/analog/4").add((int32_t)analogRead(4)); 113 | } 114 | pinMatched = msg.match("/5", addrOffset); 115 | if(pinMatched){ 116 | if (msg.fullMatch("/u", pinMatched+addrOffset)) pinMode(analogInputToDigitalPin(5), INPUT_PULLUP); //set the pullup 117 | //do the analog read and send the results 118 | bundleOUT.add("/analog/5").add((int32_t)analogRead(5)); 119 | } 120 | } 121 | 122 | /** 123 | * MAIN METHODS 124 | * 125 | * setup and loop, bundle receiving/sending, initial routing 126 | */ 127 | void setup() { 128 | //setup ethernet part 129 | read_mac(); 130 | Ethernet.begin(mac,ip); 131 | Udp.begin(inPort); 132 | 133 | } 134 | 135 | //reads and routes the incoming messages 136 | void loop(){ 137 | OSCBundle bundleIN; 138 | int size; 139 | 140 | if( (size = Udp.parsePacket())>0) 141 | { 142 | // unsigned int outPort = Udp.remotePort(); 143 | 144 | while(size--) 145 | bundleIN.fill(Udp.read()); 146 | 147 | if(!bundleIN.hasError()) 148 | bundleIN.route("/analog", routeAnalog); 149 | 150 | // send the response bundle back to where the request came from 151 | Udp.beginPacket(Udp.remoteIP(), outPort); 152 | bundleOUT.send(Udp); 153 | Udp.endPacket(); 154 | bundleOUT.empty(); // empty the bundle ready to use for new messages 155 | } 156 | } 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/examples/UDPEcho/UDPEcho.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Leverage the UDP source IP and port calls to 4 | return OSC information back 5 | 6 | This example can be extended to build routers and forwarders of OSC packets 7 | 8 | */ 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | EthernetUDP Udp; 15 | 16 | //the Arduino's IP 17 | IPAddress ip(128, 32, 122, 252); 18 | 19 | //port numbers 20 | const unsigned int inPort = 8888; 21 | const unsigned int outPort = 9999; 22 | 23 | //everything on the network needs a unique MAC 24 | #if defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MKL26Z64__) 25 | // Teensy 3.x has MAC burned in 26 | static byte mac[6]; 27 | void read(uint8_t word, uint8_t *mac, uint8_t offset) { 28 |   FTFL_FCCOB0 = 0x41;             // Selects the READONCE command 29 |   FTFL_FCCOB1 = word;             // read the given word of read once area 30 | 31 |   // launch command and wait until complete 32 |   FTFL_FSTAT = FTFL_FSTAT_CCIF; 33 |   while(!(FTFL_FSTAT & FTFL_FSTAT_CCIF)); 34 | 35 |   *(mac+offset) =   FTFL_FCCOB5;       // collect only the top three bytes, 36 |   *(mac+offset+1) = FTFL_FCCOB6;       // in the right orientation (big endian). 37 |   *(mac+offset+2) = FTFL_FCCOB7;       // Skip FTFL_FCCOB4 as it's always 0. 38 | } 39 | void read_mac() { 40 |   read(0xe,mac,0); 41 |   read(0xf,mac,3); 42 | } 43 | #else 44 | void read_mac() {} 45 |  byte mac[] = { 46 |   0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // you can find this written on the board of some Arduino Ethernets or shields 47 | #endif 48 | 49 | void setup() { 50 | Ethernet.begin(mac,ip); 51 | Udp.begin(inPort); 52 | } 53 | 54 | void loop(){ 55 | OSCBundle bndl; 56 | int size; 57 | 58 | //receive a bundle 59 | if( (size = Udp.parsePacket())>0) 60 | { 61 | // unsigned int outPort = Udp.remotePort(); 62 | 63 | while(size--) 64 | bndl.fill(Udp.read()); 65 | 66 | if(!bndl.hasError()) 67 | { 68 | //and echo it back 69 | if(bndl.size() > 0) 70 | { 71 | static int32_t sequencenumber=0; 72 | 73 | // we can sneak an addition onto the end of the bundle 74 | bndl.add("/micros").add((int32_t)micros()); // (int32_t) is the type of OSC Integers 75 | bndl.add("/sequencenumber").add(sequencenumber++); 76 | 77 | Udp.beginPacket(Udp.remoteIP(), outPort); 78 | bndl.send(Udp); 79 | Udp.endPacket(); 80 | } 81 | } 82 | } 83 | } 84 | 85 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/examples/UDPReceive/UDPReceive.ino: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | /* 10 | * UDPReceiveOSC 11 | * Set a tone according to incoming OSC control 12 | * Adrian Freed 13 | */ 14 | 15 | //UDP communication 16 | 17 | 18 | EthernetUDP Udp; 19 | byte mac[] = { 20 | 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // you can find this written on the board of some Arduino Ethernets or shields 21 | 22 | //the Arduino's IP 23 | IPAddress ip(128, 32, 122, 252); 24 | 25 | //port numbers 26 | const unsigned int inPort = 8888; 27 | 28 | //converts the pin to an osc address 29 | char * numToOSCAddress( int pin){ 30 | static char s[10]; 31 | int i = 9; 32 | 33 | s[i--]= '\0'; 34 | do 35 | { 36 | s[i] = "0123456789"[pin % 10]; 37 | --i; 38 | pin /= 10; 39 | } 40 | while(pin && i); 41 | s[i] = '/'; 42 | return &s[i]; 43 | } 44 | 45 | /** 46 | * TONE 47 | * 48 | * square wave output "/tone" 49 | * 50 | * format: 51 | * /tone/pin 52 | * 53 | * (digital value) (float value) = freqency in Hz 54 | * (no value) disable tone 55 | * 56 | **/ 57 | 58 | void routeTone(OSCMessage &msg, int addrOffset ){ 59 | //iterate through all the analog pins 60 | for(byte pin = 0; pin < NUM_DIGITAL_PINS; pin++){ 61 | //match against the pin number strings 62 | int pinMatched = msg.match(numToOSCAddress(pin), addrOffset); 63 | if(pinMatched){ 64 | unsigned int frequency = 0; 65 | //if it has an int, then it's an integers frequency in Hz 66 | if (msg.isInt(0)){ 67 | frequency = msg.getInt(0); 68 | } //otherwise it's a floating point frequency in Hz 69 | else if(msg.isFloat(0)){ 70 | frequency = msg.getFloat(0); 71 | } 72 | else 73 | noTone(pin); 74 | if(frequency>0) 75 | { 76 | if(msg.isInt(1)) 77 | tone(pin, frequency, msg.getInt(1)); 78 | else 79 | tone(pin, frequency); 80 | } 81 | } 82 | } 83 | } 84 | 85 | void setup() { 86 | //setup ethernet part 87 | Ethernet.begin(mac,ip); 88 | Udp.begin(inPort); 89 | 90 | } 91 | //reads and dispatches the incoming message 92 | void loop(){ 93 | OSCBundle bundleIN; 94 | int size; 95 | 96 | if( (size = Udp.parsePacket())>0) 97 | { 98 | while(size--) 99 | bundleIN.fill(Udp.read()); 100 | 101 | if(!bundleIN.hasError()) 102 | bundleIN.route("/tone", routeTone); 103 | } 104 | } 105 | 106 | 107 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/examples/UDPSendBundle/UDPSendBundle.ino: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | Make an OSC bundle and send it over UDP 4 | 5 | OSCBundles allow OSCMessages to be grouped together 6 | to preserve the order and completeness of related messages. 7 | They also allow for timetags to be carried to represent the presentation time 8 | of the messages. 9 | */ 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | EthernetUDP Udp; 16 | 17 | //the Arduino's IP 18 | IPAddress ip(128, 32, 122, 252); 19 | //destination IP 20 | IPAddress outIp(128, 32, 122, 125); 21 | const unsigned int outPort = 9999; 22 | 23 | byte mac[] = { 24 | 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // you can find this written on the board of some Arduino Ethernets or shields 25 | void setup() { 26 | Ethernet.begin(mac,ip); 27 | Udp.begin(8888); 28 | } 29 | 30 | 31 | 32 | void loop(){ 33 | //declare the bundle 34 | OSCBundle bndl; 35 | 36 | //BOSCBundle's add' returns the OSCMessage so the message's 'add' can be composed together 37 | bndl.add("/analog/0").add((int32_t)analogRead(0)); 38 | bndl.add("/analog/1").add((int32_t)analogRead(1)); 39 | bndl.add("/digital/5").add((digitalRead(5)==HIGH)?"HIGH":"LOW"); 40 | 41 | Udp.beginPacket(outIp, outPort); 42 | bndl.send(Udp); // send the bytes to the SLIP stream 43 | Udp.endPacket(); // mark the end of the OSC Packet 44 | bndl.empty(); // empty the bundle to free room for a new one 45 | 46 | bndl.add("/mouse/step").add((int32_t)analogRead(0)).add((int32_t)analogRead(1)); 47 | bndl.add("/units").add("pixels"); 48 | 49 | Udp.beginPacket(outIp, outPort); 50 | bndl.send(Udp); // send the bytes to the SLIP stream 51 | Udp.endPacket(); // mark the end of the OSC Packet 52 | bndl.empty(); // empty the bundle to free room for a new one 53 | 54 | delay(1000); 55 | } 56 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/examples/UDPSendBundlewithTimeTag/UDPSendBundlewithTimeTag.ino: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | Make an OSC bundle and send it over UDP 4 | 5 | OSCBundles allow OSCMessages to be grouped together 6 | to preserve the order and completeness of related messages. 7 | They also allow for timetags to be carried to represent the presentation time 8 | of the messages. 9 | */ 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | 17 | EthernetUDP Udp; 18 | 19 | //the Arduino's IP 20 | IPAddress ip(128, 32, 122, 26); 21 | //destination IP 22 | IPAddress outIp(128, 32, 122, 25); 23 | const unsigned int outPort = 9999; 24 | 25 | byte mac[] = { 26 | 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // you can find this written on the board of some Arduino Ethernets or shields 27 | void setup() { 28 | Ethernet.begin(mac,ip); 29 | Udp.begin(8888); 30 | } 31 | 32 | 33 | 34 | void loop(){ 35 | //declare the bundle 36 | OSCBundle bndl; 37 | uint64_t timetag; 38 | 39 | //OSCBundle's add' returns the OSCMessage so the message's 'add' can be composed together 40 | bndl.add("/analog/0").add((int32_t)adcRead(0, &timetag)); 41 | bndl.add("/analog/0/time").add(timetag); 42 | 43 | bndl.add("/analog/1").add((int32_t)adcRead(1, &timetag)); 44 | bndl.add("/analog/1/time").add(timetag); 45 | 46 | Udp.beginPacket(outIp, outPort); 47 | bndl.setTimetag(oscTime()); 48 | bndl.send(Udp); // send the bytes to the SLIP stream 49 | Udp.endPacket(); // mark the end of the OSC Packet 50 | bndl.empty(); // empty the bundle to free room for a new one 51 | 52 | bndl.add("/mouse/step").add((int32_t)analogRead(0)).add((int32_t)analogRead(1)); 53 | bndl.add("/units").add("pixels"); 54 | 55 | Udp.beginPacket(outIp, outPort); 56 | bndl.setTimetag(oscTime()); 57 | bndl.send(Udp); // send the bytes to the SLIP stream 58 | Udp.endPacket(); // mark the end of the OSC Packet 59 | bndl.empty(); // empty the bundle to free room for a new one 60 | 61 | delay(100); 62 | } 63 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/examples/UDPSendMessage/UDPSendMessage.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* 4 | Make an OSC message and send it over UDP 5 | 6 | Adrian Freed 7 | */ 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | EthernetUDP Udp; 14 | 15 | //the Arduino's IP 16 | IPAddress ip(128, 32, 122, 252); 17 | //destination IP 18 | IPAddress outIp(128, 32, 122, 125); 19 | const unsigned int outPort = 9999; 20 | 21 | byte mac[] = { 22 | 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // you can find this written on the board of some Arduino Ethernets or shields 23 | void setup() { 24 | Ethernet.begin(mac,ip); 25 | Udp.begin(8888); 26 | 27 | } 28 | 29 | 30 | void loop(){ 31 | //the message wants an OSC address as first argument 32 | OSCMessage msg("/analog/0"); 33 | msg.add((int32_t)analogRead(0)); 34 | 35 | Udp.beginPacket(outIp, outPort); 36 | msg.send(Udp); // send the bytes to the SLIP stream 37 | Udp.endPacket(); // mark the end of the OSC Packet 38 | msg.empty(); // free space occupied by message 39 | 40 | delay(20); 41 | } 42 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/keywords.txt: -------------------------------------------------------------------------------- 1 | getOSCMessage KEYWORD1 2 | fill KEYWORD1 3 | send KEYWORD1 4 | dispatch KEYWORD1 5 | route KEYWORD1 6 | setTimetag KEYWORD1 7 | getTimetag KEYWORD1 8 | hasError KEYWORD1 9 | add KEYWORD2 10 | match KEYWORD2 11 | fullMatch KEYWORD2 12 | getInt KEYWORD2 13 | getFloat KEYWORD2 14 | getBlob KEYWORD2 15 | getString KEYWORD1 16 | getAddress KEYWORD1 17 | getDataLength KEYWORD1 18 | isInt KEYWORD1 19 | isFloat KEYWORD1 20 | isBlob KEYWORD1 21 | isString KEYWORD1 22 | empty KEYWORD1 23 | OSCBundle KEYWORD1 24 | OSCMessage KEYWORD1 25 | OSCMatch KEYWORD1 26 | OSCData KEYWORD1 27 | endTransmission KEYWORD1 28 | endofTransmission KEYWORD1 29 | SLIPEncodedSerial KEYWORD3 30 | SLIPEncodedUSBSerial KEYWORD3 31 | SLIPEncodedSPISerial KEYWORD3 32 | oscTime KEYWORD1 33 | adcRead KEYWORD1 34 | capacitanceRead KEYWORD1 35 | inputRead KEYWORD1 36 | ####################################### 37 | # Syntax Coloring Map SPI 38 | ####################################### 39 | ####################################### 40 | # Class 41 | ####################################### 42 | StreamSPI0 KEYWORD3 43 | 44 | ####################################### 45 | # Datatypes (KEYWORD1) 46 | ####################################### 47 | 48 | SPI KEYWORD1 49 | StreamSPI KEYWORD1 50 | 51 | ####################################### 52 | # Methods and Functions (KEYWORD2) 53 | ####################################### 54 | begin KEYWORD2 55 | end KEYWORD2 56 | transfer KEYWORD2 57 | setBitOrder KEYWORD2 58 | setDataMode KEYWORD2 59 | setClockDivider KEYWORD2 60 | 61 | 62 | ####################################### 63 | # Constants (LITERAL1) 64 | ####################################### 65 | SPI_CLOCK_DIV4 LITERAL1 66 | SPI_CLOCK_DIV16 LITERAL1 67 | SPI_CLOCK_DIV64 LITERAL1 68 | SPI_CLOCK_DIV128 LITERAL1 69 | SPI_CLOCK_DIV2 LITERAL1 70 | SPI_CLOCK_DIV8 LITERAL1 71 | SPI_CLOCK_DIV32 LITERAL1 72 | SPI_CLOCK_DIV64 LITERAL1 73 | SPI_MODE0 LITERAL1 74 | SPI_MODE1 LITERAL1 75 | SPI_MODE2 LITERAL1 76 | SPI_MODE3 LITERAL1 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "OSC", 3 | "keywords": "sound, encoding, OSC", 4 | "description": "Open Sound Control (OSC) is an open, transport-independent, message-based encidubg developed for communication among computers, sound synthesizers, and other multimedia devices.", 5 | "authors": [ 6 | { 7 | "name": "Adrian Freed", 8 | "email": "adrian@adrianfreed.com", 9 | "url": "http://www.adrianfreed.com" 10 | }, 11 | { 12 | "name": "Yotam Mann", 13 | "url": "http://yotammann.info" 14 | } 15 | ], 16 | "repository": 17 | { 18 | "type": "git", 19 | "url": "https://github.com/CNMAT/OSC.git" 20 | }, 21 | "frameworks": "arduino", 22 | "platforms": [ 23 | "atmelavr", 24 | "atmelsam", 25 | "teensy" 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/library.properties: -------------------------------------------------------------------------------- 1 | name=OSC 2 | version=1.3.3 3 | author=Adrian Freed , Yotam Mann 4 | maintainer=Adrian Freed 5 | sentence=Open Sound Control (OSC) 6 | paragraph=Open Sound Control (OSC) is an open, transport-independent, message-based protocol developed for communication among computers, sound synthesizers, and other multimedia devices. 7 | category=Device Control 8 | url=https://github.com/CNMAT/OSC 9 | architectures=* 10 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/test/OSCBundle_test/OSCBundle_test.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "TestPrint.h" 4 | 5 | #define HAS_DOUBLE sizeof(double) == 8 6 | 7 | test(bundle_address){ 8 | OSCBundle bundle; 9 | bundle.add("/address").add(1); 10 | assertEqual(bundle.size(), 1); 11 | OSCMessage msg = bundle.getOSCMessage("/address"); 12 | assertTrue(msg.isInt(0)); 13 | assertEqual(msg.getInt(0), 1); 14 | } 15 | 16 | test(bundle_message_position){ 17 | OSCBundle bundle; 18 | bundle.add("/one").add(1); 19 | bundle.add("/two").add(2); 20 | assertEqual(bundle.size(), 2); 21 | OSCMessage msg0 = bundle.getOSCMessage(0); 22 | assertTrue(msg0.isInt(0)); 23 | assertEqual(msg0.getInt(0), 1); 24 | OSCMessage msg1 = bundle.getOSCMessage(1); 25 | assertTrue(msg1.isInt(0)); 26 | assertEqual(msg1.getInt(0), 2); 27 | } 28 | 29 | test(bundle_add_message){ 30 | OSCMessage msg("/msg"); 31 | OSCBundle bundle; 32 | bundle.add(msg).add(1); 33 | assertEqual(bundle.size(), 1); 34 | OSCMessage test_msg = bundle.getOSCMessage(0); 35 | assertTrue(test_msg.isInt(0)); 36 | assertEqual(test_msg.getInt(0), 1); 37 | } 38 | 39 | void routeA(OSCMessage & msg, int offset){ 40 | assertTrue(msg.isInt(0)); 41 | assertEqual(msg.getInt(0), 1); 42 | } 43 | 44 | void routeB(OSCMessage & msg, int offset){ 45 | assertTrue(msg.isInt(0)); 46 | assertEqual(msg.getInt(0), 2); 47 | } 48 | 49 | test(bundle_route){ 50 | OSCMessage msg("/msg"); 51 | OSCBundle bundle; 52 | bundle.add("/a").add(1); 53 | bundle.add("/b/1").add(2); 54 | assertEqual(bundle.size(), 2); 55 | assertTrue(bundle.route("/a", routeA)); 56 | assertTrue(bundle.route("/b", routeB)); 57 | } 58 | 59 | void dispatchA(OSCMessage & msg){ 60 | assertTrue(msg.isInt(0)); 61 | assertEqual(msg.getInt(0), 1); 62 | } 63 | 64 | void dispatchB(OSCMessage & msg){ 65 | assertTrue(msg.isInt(0)); 66 | assertEqual(msg.getInt(0), 2); 67 | } 68 | 69 | test(bundle_dispatch){ 70 | OSCMessage msg("/msg"); 71 | OSCBundle bundle; 72 | bundle.add("/a").add(1); 73 | bundle.add("/b").add(2); 74 | assertEqual(bundle.size(), 2); 75 | assertTrue(bundle.route("/a", routeA)); 76 | assertTrue(bundle.route("/b", routeB)); 77 | } 78 | 79 | test(bundle_encode){ 80 | TestPrint printer; 81 | //this is the desired output 82 | uint8_t testBuffer[] = {35, 98, 117, 110, 100, 108, 101, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 47, 97, 0, 0, 44, 105, 0, 0, 0, 0, 0, 1, 0, 0, 0, 12, 47, 98, 0, 0, 44, 105, 0, 0, 0, 0, 0, 2}; 83 | OSCBundle bundle; 84 | bundle.add("/a").add(1); 85 | bundle.add("/b").add(2); 86 | bundle.send(printer); 87 | assertEqual(printer.size(), sizeof(testBuffer)); 88 | for (int i = 0; i < sizeof(testBuffer); i++){ 89 | assertEqual(testBuffer[i], printer.at(i)); 90 | } 91 | } 92 | 93 | test(bundle_decode){ 94 | uint8_t testBuffer[] = {35, 98, 117, 110, 100, 108, 101, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 47, 97, 0, 0, 44, 105, 0, 0, 0, 0, 0, 1, 0, 0, 0, 12, 47, 98, 0, 0, 44, 105, 0, 0, 0, 0, 0, 2}; 95 | OSCBundle bundle; 96 | bundle.fill(testBuffer, sizeof(testBuffer)); 97 | assertEqual(bundle.size(), 2); 98 | OSCMessage msgA = bundle.getOSCMessage("/a"); 99 | assertTrue(msgA.isInt(0)); 100 | assertEqual(msgA.getInt(0), 1); 101 | OSCMessage msgB = bundle.getOSCMessage("/b"); 102 | assertTrue(msgB.isInt(0)); 103 | assertEqual(msgB.getInt(0), 2); 104 | } 105 | 106 | test(bundle_decode_invalid){ 107 | uint8_t testBuffer[] = {35, 98, 117, 110, 100, 108, 101, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 47, 97, 0, 0, 44, 105, 0, 0, 0, 0, 0, 1, 0, 0, 0, 12, 47, 98, 0, 0, 44, 105, 0, 0, 0, 0, 2}; 108 | OSCBundle bundle; 109 | bundle.fill(testBuffer, sizeof(testBuffer)); 110 | assertTrue(bundle.hasError()); 111 | } 112 | 113 | 114 | void setup() 115 | { 116 | Serial.begin(9600); 117 | while(!Serial); // for the Arduino Leonardo/Micro only 118 | } 119 | 120 | void loop() 121 | { 122 | Test::run(); 123 | } 124 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/test/OSCBundle_test/TestPrint.h: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * A print class for testing the encoder 4 | */ 5 | class TestPrint : public Print { 6 | 7 | private: 8 | //a small test buffer 9 | uint8_t buffer[64]; 10 | 11 | //pointer to the current write spot 12 | int bufferPointer; 13 | 14 | public: 15 | 16 | TestPrint(){ 17 | bufferPointer = 0; 18 | } 19 | 20 | size_t write(uint8_t character) { 21 | buffer[bufferPointer++] = character; 22 | return character; 23 | } 24 | 25 | int size(){ 26 | return bufferPointer; 27 | } 28 | 29 | uint8_t at(int index){ 30 | return buffer[index]; 31 | } 32 | 33 | void clear(){ 34 | bufferPointer = 0; 35 | } 36 | }; 37 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/test/OSCData_test/OSCData_test.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define HAS_DOUBLE sizeof(double) == 8 5 | 6 | test(data_int){ 7 | int i = 1; 8 | OSCData datum(i); 9 | assertEqual(datum.getInt(), i); 10 | assertEqual(datum.type, 'i'); 11 | } 12 | 13 | test(data_float){ 14 | float f = 1.1; 15 | OSCData datum(f); 16 | assertEqual(datum.getFloat(), f); 17 | assertEqual(datum.type, 'f'); 18 | } 19 | 20 | test(data_string){ 21 | char * testStr = "data"; 22 | int testStrLen = strlen(testStr) + 1; 23 | OSCData datum(testStr); 24 | char str[testStrLen]; 25 | datum.getString(str, testStrLen); 26 | assertEqual(strcmp(str, testStr), 0); 27 | assertEqual(datum.type, 's'); 28 | } 29 | 30 | test(data_string_partial_copy){ 31 | char * testStr = "data"; 32 | int testStrLen = strlen(testStr) + 1; 33 | OSCData datum(testStr); 34 | char str[testStrLen]; 35 | assertEqual(datum.getString(str, 2), 2); 36 | assertEqual(strncmp(str, testStr, 2), 0); 37 | } 38 | 39 | test(data_bool){ 40 | bool f = false; 41 | OSCData datum(f); 42 | assertFalse(datum.getBoolean()); 43 | } 44 | 45 | test(has_double){ 46 | assertEqual(sizeof(double), 8); 47 | } 48 | 49 | test(data_double){ 50 | if (HAS_DOUBLE){ 51 | double d = 1.1; 52 | OSCData datum = OSCData(d); 53 | assertEqual(datum.getDouble(), d); 54 | assertEqual(datum.type, 'd'); 55 | } 56 | } 57 | 58 | test(data_blob){ 59 | uint8_t b[] = {0, 1, 2, 3}; 60 | OSCData datum(b, 4); 61 | uint8_t blob[4]; 62 | datum.getBlob(blob, 4); 63 | for (int i = 0; i < 4; i++){ 64 | assertEqual(blob[i], b[i]); 65 | } 66 | assertEqual(datum.type, 'b'); 67 | } 68 | 69 | test(data_blob_partial_copy){ 70 | uint8_t b[] = {0, 1, 2, 3}; 71 | OSCData datum(b, 4); 72 | uint8_t blob[4]; 73 | assertEqual(datum.getBlob(blob, 2), 2); 74 | for (int i = 0; i < 2; i++){ 75 | assertEqual(blob[i], b[i]); 76 | } 77 | } 78 | 79 | test(data_copy){ 80 | OSCData datum = OSCData(1); 81 | OSCData cpy(datum); 82 | assertEqual(cpy.getInt(), 1); 83 | assertEqual(cpy.type, 'i'); 84 | } 85 | 86 | 87 | void setup() 88 | { 89 | Serial.begin(9600); 90 | while(!Serial); // for the Arduino Leonardo/Micro only 91 | } 92 | 93 | void loop() 94 | { 95 | Test::run(); 96 | } 97 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/test/OSCMessage_encode_decode_test/OSCMessage_encode_decode_test.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "TestPrint.h" 4 | 5 | #define HAS_DOUBLE sizeof(double) == 8 6 | 7 | test(message_encode_int){ 8 | TestPrint printer; 9 | //this is the desired output 10 | uint8_t testBuffer[] = {47, 102, 111, 111, 0, 0, 0, 0, 44, 105, 105, 105, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 2, 255, 255, 255, 236}; 11 | OSCMessage msg("/foo"); 12 | msg.add(1); 13 | msg.add(2); 14 | msg.add(-20); 15 | msg.send(printer); 16 | assertEqual(printer.size(), sizeof(testBuffer)); 17 | for (int i = 0; i < sizeof(testBuffer); i++){ 18 | assertEqual(testBuffer[i], printer.at(i)); 19 | } 20 | } 21 | 22 | test(message_encode_string){ 23 | TestPrint printer; 24 | //this is the desired output 25 | uint8_t testBuffer[] = {47, 116, 101, 115, 116, 0, 0, 0, 44, 115, 115, 0, 104, 105, 0, 0, 104, 111, 119, 100, 121, 0, 0, 0}; 26 | OSCMessage msg("/test"); 27 | msg.add("hi"); 28 | msg.add("howdy"); 29 | msg.send(printer); 30 | assertEqual(printer.size(), sizeof(testBuffer)); 31 | for (int i = 0; i < sizeof(testBuffer); i++){ 32 | assertEqual(testBuffer[i], printer.at(i)); 33 | } 34 | } 35 | 36 | test(message_encode_float){ 37 | TestPrint printer; 38 | //this is the desired output 39 | uint8_t testBuffer[] = {47, 97, 100, 100, 114, 101, 115, 115, 0, 0, 0, 0, 44, 102, 102, 0, 63, 128, 0, 0, 192, 6, 102, 102}; 40 | OSCMessage msg("/address"); 41 | msg.add(1.0f); 42 | msg.add(-2.1f); 43 | msg.send(printer); 44 | assertEqual(printer.size(), sizeof(testBuffer)); 45 | for (int i = 0; i < sizeof(testBuffer); i++){ 46 | assertEqual(testBuffer[i], printer.at(i)); 47 | } 48 | } 49 | 50 | test(message_encode_double){ 51 | if (HAS_DOUBLE){ 52 | TestPrint printer; 53 | //this is the desired output 54 | uint8_t testBuffer[] = {47, 97, 0, 0, 44, 100, 100, 0, 64, 89, 0, 0, 0, 0, 0, 0, 63, 80, 98, 77, 210, 241, 169, 252}; 55 | OSCMessage msg("/a"); 56 | double d0 = 100; 57 | double d1 = 0.001; 58 | msg.add(d0); 59 | msg.add(d1); 60 | msg.send(printer); 61 | assertEqual(printer.size(), sizeof(testBuffer)); 62 | for (int i = 0; i < sizeof(testBuffer); i++){ 63 | assertEqual(testBuffer[i], printer.at(i)); 64 | } 65 | } 66 | } 67 | 68 | test(message_encode_blob){ 69 | TestPrint printer; 70 | //this is the desired output 71 | uint8_t testBuffer[] = {47, 98, 0, 0, 44, 98, 0, 0, 0, 0, 0, 5, 1, 2, 3, 4, 5, 0, 0, 0}; 72 | OSCMessage msg("/b"); 73 | uint8_t blob[] = {1, 2, 3, 4, 5}; 74 | msg.add(blob, 5); 75 | msg.send(printer); 76 | assertEqual(printer.size(), sizeof(testBuffer)); 77 | for (int i = 0; i < sizeof(testBuffer); i++){ 78 | assertEqual(testBuffer[i], printer.at(i)); 79 | } 80 | } 81 | 82 | test(message_encode_mixed){ 83 | TestPrint printer; 84 | //this is the desired output 85 | uint8_t testBuffer[] = {47, 109, 105, 120, 101, 100, 0, 0, 44, 115, 105, 102, 0, 0, 0, 0, 111, 110, 101, 0, 0, 0, 0, 1, 63, 128, 0, 0}; 86 | OSCMessage msg("/mixed"); 87 | msg.add("one"); 88 | msg.add(1); 89 | msg.add(1.0f); 90 | msg.send(printer); 91 | assertEqual(printer.size(), sizeof(testBuffer)); 92 | for (int i = 0; i < sizeof(testBuffer); i++){ 93 | assertEqual(testBuffer[i], printer.at(i)); 94 | } 95 | } 96 | 97 | test(message_decode_int){ 98 | uint8_t testBuffer[] = {47, 105, 110, 116, 115, 0, 0, 0, 44, 105, 105, 105, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 200, 255, 255, 255, 231}; 99 | OSCMessage msg; 100 | msg.fill(testBuffer, sizeof(testBuffer)); 101 | assertEqual(msg.size(), 3); 102 | assertTrue(msg.isInt(0)); 103 | assertTrue(msg.isInt(1)); 104 | assertTrue(msg.isInt(2)); 105 | assertEqual(msg.getInt(0), 1); 106 | assertEqual(msg.getInt(1), 200); 107 | assertEqual(msg.getInt(2), -25); 108 | } 109 | 110 | test(message_decode_float){ 111 | uint8_t testBuffer[] = {47, 102, 108, 111, 97, 116, 115, 0, 44, 102, 102, 0, 191, 128, 0, 0, 67, 72, 2, 143}; 112 | OSCMessage msg; 113 | msg.fill(testBuffer, sizeof(testBuffer)); 114 | assertEqual(msg.size(), 2); 115 | assertFalse(msg.isInt(0)); 116 | assertTrue(msg.isFloat(0)); 117 | assertTrue(msg.isFloat(1)); 118 | assertEqual(msg.getFloat(0), -1.0f); 119 | assertEqual(msg.getFloat(1), 200.01f); 120 | } 121 | 122 | test(message_decode_double){ 123 | if (HAS_DOUBLE){ 124 | uint8_t testBuffer[] = {47, 100, 0, 0, 44, 100, 0, 0, 64, 36, 5, 30, 184, 81, 235, 133}; 125 | OSCMessage msg; 126 | msg.fill(testBuffer, sizeof(testBuffer)); 127 | double d = 10.01; 128 | assertEqual(msg.size(), 1); 129 | assertTrue(msg.isDouble(0)); 130 | assertEqual(msg.getDouble(0), d); 131 | } 132 | } 133 | 134 | test(message_decode_string){ 135 | uint8_t testBuffer[] = {47, 115, 116, 114, 105, 110, 103, 115, 0, 0, 0, 0, 44, 115, 115, 0, 104, 101, 121, 0, 104, 105, 0, 0}; 136 | OSCMessage msg; 137 | msg.fill(testBuffer, sizeof(testBuffer)); 138 | assertEqual(msg.size(), 2); 139 | assertTrue(msg.isString(0)); 140 | assertTrue(msg.isString(1)); 141 | char str[4]; 142 | msg.getString(0, str, 5); 143 | assertEqual(strcmp(str, "hey"), 0); 144 | msg.getString(1, str, 3); 145 | assertEqual(strcmp(str, "hi"), 0); 146 | } 147 | 148 | test(message_decode_blob){ 149 | uint8_t testBuffer[] = {47, 98, 0, 0, 44, 98, 0, 0, 0, 0, 0, 4, 0, 1, 2, 3}; 150 | OSCMessage msg; 151 | msg.fill(testBuffer, sizeof(testBuffer)); 152 | assertEqual(msg.size(), 1); 153 | assertTrue(msg.isBlob(0)); 154 | uint8_t blob[4]; 155 | msg.getBlob(0, blob, 4); 156 | for (int i = 0; i < 4; i++){ 157 | assertEqual(i, blob[i]); 158 | } 159 | } 160 | 161 | test(message_decode_mixed){ 162 | uint8_t testBuffer[] = {47, 109, 105, 120, 101, 100, 0, 0, 44, 115, 105, 102, 0, 0, 0, 0, 111, 110, 101, 0, 0, 0, 0, 1, 63, 128, 0, 0}; 163 | OSCMessage msg; 164 | msg.fill(testBuffer, sizeof(testBuffer)); 165 | assertEqual(msg.size(), 3); 166 | assertTrue(msg.isString(0)); 167 | assertTrue(msg.isInt(1)); 168 | assertTrue(msg.isFloat(2)); 169 | assertEqual(msg.getInt(1), 1); 170 | assertEqual(msg.getFloat(2), 1.0f); 171 | } 172 | 173 | void setup() 174 | { 175 | Serial.begin(9600); 176 | while(!Serial); // for the Arduino Leonardo/Micro only 177 | } 178 | 179 | void loop() 180 | { 181 | Test::run(); 182 | } 183 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/test/OSCMessage_encode_decode_test/TestPrint.h: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * A print class for testing the encoder 4 | */ 5 | class TestPrint : public Print { 6 | 7 | private: 8 | //a small test buffer 9 | uint8_t buffer[64]; 10 | 11 | //pointer to the current write spot 12 | int bufferPointer; 13 | 14 | public: 15 | 16 | TestPrint(){ 17 | bufferPointer = 0; 18 | } 19 | 20 | size_t write(uint8_t character) { 21 | buffer[bufferPointer++] = character; 22 | return character; 23 | } 24 | 25 | int size(){ 26 | return bufferPointer; 27 | } 28 | 29 | uint8_t at(int index){ 30 | return buffer[index]; 31 | } 32 | 33 | void clear(){ 34 | bufferPointer = 0; 35 | } 36 | }; 37 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/test/OSCMessage_match_test/OSCMessage_match_test.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | test(message_address_match){ 6 | OSCMessage msg("/a/0"); 7 | assertEqual(msg.match("/a"), 2); 8 | assertEqual(msg.match("/a/0"), 4); 9 | } 10 | 11 | test(message_address_match_offset){ 12 | OSCMessage msg("/a/0"); 13 | assertEqual(msg.match("/0", 2), 2); 14 | assertEqual(msg.match("/1", 2), 0); 15 | } 16 | 17 | test(message_address_match_range){ 18 | OSCMessage msg("/[a-z]/0"); 19 | assertEqual(msg.match("/a"), 6); 20 | assertEqual(msg.match("/b/0"), 8); 21 | } 22 | 23 | test(message_address_match_or){ 24 | OSCMessage msg("/{a,b}/0"); 25 | assertEqual(msg.match("/a/0"), 8); 26 | assertEqual(msg.match("/b/0"), 8); 27 | assertEqual(msg.match("/c/0"), 0); 28 | } 29 | 30 | test(message_address_match_char){ 31 | OSCMessage msg("/a/?"); 32 | assertEqual(msg.match("/a/0"), 4); 33 | assertEqual(msg.match("/a/1"), 4); 34 | assertEqual(msg.match("/a/10"), 0); 35 | } 36 | 37 | test(message_address_match_star){ 38 | OSCMessage msg("/a/*"); 39 | assertEqual(msg.match("/a/0"), 4); 40 | assertEqual(msg.match("/a/10"), 4); 41 | assertEqual(msg.match("/a/100"), 4); 42 | } 43 | 44 | test(message_address_fullMatch){ 45 | OSCMessage msg("/a/0"); 46 | assertTrue(msg.fullMatch("/a/0")); 47 | assertFalse(msg.fullMatch("/a/1")); 48 | assertTrue(msg.fullMatch("/0", 2)); 49 | } 50 | 51 | void dispatchMsg(OSCMessage &m){ 52 | assertTrue(m.isInt(0)); 53 | assertEqual(m.getInt(0), 1); 54 | } 55 | 56 | test(message_address_dispatch){ 57 | OSCMessage msg("/a/[0-9]"); 58 | msg.add(1); 59 | assertTrue(msg.dispatch("/a/0", dispatchMsg)); 60 | assertTrue(msg.dispatch("/1", dispatchMsg, 2)); 61 | } 62 | 63 | 64 | void routeMsg(OSCMessage &m, int offset){ 65 | assertTrue(m.isInt(0)); 66 | assertEqual(m.getInt(0), 2); 67 | assertEqual(offset, 2); 68 | } 69 | 70 | test(message_address_route){ 71 | OSCMessage msg("/?/[0-9]"); 72 | msg.add(2); 73 | assertTrue(msg.route("/a", routeMsg)); 74 | assertTrue(msg.route("/b", routeMsg)); 75 | } 76 | 77 | void setup() 78 | { 79 | Serial.begin(9600); 80 | while(!Serial); // for the Arduino Leonardo/Micro only 81 | } 82 | 83 | void loop() 84 | { 85 | Test::run(); 86 | } 87 | -------------------------------------------------------------------------------- /Arduino-Code/OSC library - Backup/OSCuino/test/OSCMessage_test/OSCMessage_test.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define HAS_DOUBLE sizeof(double) == 8 5 | 6 | 7 | test(message_addres){ 8 | OSCMessage msg("/hihi"); 9 | char addr[6]; 10 | msg.getAddress(addr); 11 | assertEqual(strcmp(addr, "/hihi"), 0); 12 | } 13 | 14 | test(message_addres_offset){ 15 | OSCMessage msg("/foo/bar"); 16 | char addr[5]; 17 | msg.getAddress(addr, 4); 18 | assertEqual(strcmp(addr, "/bar"), 0); 19 | } 20 | 21 | test(message_copy){ 22 | OSCMessage msg("/hihi"); 23 | msg.add(1); 24 | OSCMessage cpy(&msg); 25 | assertEqual(cpy.size(), 1); 26 | assertTrue(cpy.isInt(0)); 27 | assertEqual(cpy.getInt(0), 1); 28 | } 29 | 30 | test(message_int){ 31 | OSCMessage msg("/foo"); 32 | msg.add(1); 33 | assertTrue(msg.isInt(0)); 34 | assertEqual(msg.getInt(0), 1); 35 | assertEqual(msg.getDataLength(0), 4); 36 | } 37 | 38 | test(message_float){ 39 | OSCMessage msg("/foo"); 40 | msg.add(1.0f); 41 | assertTrue(msg.isFloat(0)); 42 | assertEqual(msg.getFloat(0), 1.0f); 43 | assertEqual(msg.getDataLength(0), 4); 44 | } 45 | 46 | test(message_string){ 47 | OSCMessage msg("/foo"); 48 | msg.add("oh hi"); 49 | assertTrue(msg.isString(0)); 50 | char str[6]; 51 | msg.getString(0, str, 6); 52 | assertEqual(strcmp(str, "oh hi"), 0); 53 | assertEqual(msg.getDataLength(0), 6); 54 | } 55 | 56 | test(message_blob){ 57 | OSCMessage msg("/foo"); 58 | uint8_t b[] = {0, 1, 2, 3, 4}; 59 | msg.add(b, 5); 60 | assertTrue(msg.isBlob(0)); 61 | uint8_t blob[5]; 62 | msg.getBlob(0, blob, 5); 63 | for (int i = 0; i < 5; i++){ 64 | assertEqual(blob[i], b[i]); 65 | } 66 | //9 because it includes the 4 byte length 67 | assertEqual(msg.getDataLength(0), 9); 68 | } 69 | 70 | test(message_boolean){ 71 | OSCMessage msg("/foo"); 72 | msg.add(true); 73 | assertTrue(msg.isBoolean(0)); 74 | assertEqual(msg.getBoolean(0), true); 75 | assertEqual(msg.getDataLength(0), 0); 76 | } 77 | 78 | test(mixed_message_type){ 79 | OSCMessage msg("/foo"); 80 | msg.add(true); 81 | msg.add(1.0f); 82 | msg.add(2); 83 | msg.add("test"); 84 | assertEqual(msg.size(), 4); 85 | assertEqual(msg.getType(0), 'T'); 86 | assertTrue(msg.isBoolean(0)); 87 | assertFalse(msg.isBoolean(1)); 88 | assertTrue(msg.isFloat(1)); 89 | assertTrue(msg.isInt(2)); 90 | assertTrue(msg.isString(3)); 91 | assertEqual(msg.getInt(2), 2); 92 | assertEqual(msg.getInt(3), NULL); 93 | } 94 | 95 | void setup() 96 | { 97 | Serial.begin(9600); 98 | while(!Serial); // for the Arduino Leonardo/Micro only 99 | } 100 | 101 | void loop() 102 | { 103 | Test::run(); 104 | } 105 | -------------------------------------------------------------------------------- /Arduino-Code/ReceiveOSC/ReceiveOSC.ino: -------------------------------------------------------------------------------- 1 | /** 2 | * Receive OSC messages at NodeMCU from any OSC speaking sender. 3 | * Case: Switch an LED (connected to NodeMCU) on or off via Smartphone 4 | * Created by Fabian Fiess in November 2016 5 | * Inspired by Oscuino Library Examples, Make Magazine 12/2015, https://trippylighting.com/teensy-arduino-ect/touchosc-and-arduino-oscuino/ 6 | */ 7 | 8 | #include 9 | #include 10 | #include // for receiving OSC messages 11 | 12 | char ssid[] = "difix"; // your network SSID (name) 13 | char pass[] = "88288828"; // your network password 14 | 15 | // Button Input + LED Output 16 | const int ledPin = 14; // D5 pin at NodeMCU 17 | const int boardLed = LED_BUILTIN; // Builtin LED 18 | 19 | WiFiUDP Udp; // A UDP instance to let us send and receive packets over UDP 20 | const unsigned int localPort = 8000; // local port to listen for UDP packets at the NodeMCU (another device must send OSC messages to this port) 21 | const unsigned int destPort = 9000; // remote port of the target device where the NodeMCU sends OSC to 22 | 23 | unsigned int ledState = 1; // LOW means led is *on* 24 | 25 | void setup() { 26 | Serial.begin(115200); 27 | 28 | // Specify a static IP address for NodeMCU 29 | // If you erase this line, your ESP8266 will get a dynamic IP address 30 | WiFi.config(IPAddress(192,168,0,123),IPAddress(192,168,0,1), IPAddress(255,255,255,0)); 31 | 32 | // Connect to WiFi network 33 | Serial.println(); 34 | Serial.print("Connecting to "); 35 | Serial.println(ssid); 36 | WiFi.begin(ssid, pass); 37 | 38 | while (WiFi.status() != WL_CONNECTED) { 39 | delay(500); 40 | Serial.print("."); 41 | } 42 | 43 | Serial.println(""); 44 | Serial.println("WiFi connected"); 45 | Serial.println("IP address: "); 46 | Serial.println(WiFi.localIP()); 47 | 48 | Serial.println("Starting UDP"); 49 | Udp.begin(localPort); 50 | Serial.print("Local port: "); 51 | Serial.println(Udp.localPort()); 52 | 53 | // LED Output 54 | pinMode(boardLed, OUTPUT); 55 | pinMode(ledPin, OUTPUT); 56 | digitalWrite(boardLed, ledState); // turn *off* led 57 | } 58 | 59 | 60 | void loop() { 61 | OSCMessage msgIN; 62 | int size; 63 | if((size = Udp.parsePacket())>0){ 64 | while(size--) 65 | msgIN.fill(Udp.read()); 66 | if(!msgIN.hasError()){ 67 | msgIN.route("/1/toggleLED",toggleOnOff); 68 | } 69 | } 70 | } 71 | 72 | 73 | void toggleOnOff(OSCMessage &msg, int addrOffset){ 74 | ledState = (boolean) msg.getFloat(0); 75 | 76 | digitalWrite(boardLed, (ledState + 1) % 2); // Onboard LED works the wrong direction (1 = 0 bzw. 0 = 1) 77 | digitalWrite(ledPin, ledState); // External LED 78 | 79 | if (ledState) { 80 | Serial.println("LED on"); 81 | } 82 | else { 83 | Serial.println("LED off"); 84 | } 85 | ledState = !ledState; // toggle the state from HIGH to LOW to HIGH to LOW ... 86 | } 87 | -------------------------------------------------------------------------------- /Arduino-Code/SendOSC/SendOSC.ino: -------------------------------------------------------------------------------- 1 | /** 2 | * Send OSC messages from NodeMCU to another OSC speaking device. 3 | * Case: Press a button (connected to NodeMCU) and get informed about it on your smartphone screen 4 | * Created by Fabian Fiess in November 2016 5 | * Inspired by Oscuino Library Examples, Make Magazine 12/2015 6 | */ 7 | 8 | #include 9 | #include 10 | #include // for sending OSC messages 11 | 12 | char ssid[] = "difix"; // your network SSID (name) 13 | char pass[] = "88288828"; // your network password 14 | 15 | // Button Input + LED Output 16 | const int btnPin = 12; // D6 17 | const int ledPin = 14; // D5 18 | const int boardLed = LED_BUILTIN; // Builtin LED 19 | 20 | boolean isBtnChanged = false; 21 | int btnVal = 1; 22 | 23 | WiFiUDP Udp; // A UDP instance to let us send and receive packets over UDP 24 | const IPAddress destIp(192,168,0,3); // remote IP of the target device 25 | const unsigned int destPort = 9000; // remote port of the target device where the NodeMCU sends OSC to 26 | const unsigned int localPort = 8000; // local port to listen for UDP packets at the NodeMCU (another device must send OSC messages to this port) 27 | 28 | void setup() { 29 | Serial.begin(115200); 30 | 31 | // Specify a static IP address 32 | // If you erase this line, your ESP8266 will get a dynamic IP address 33 | WiFi.config(IPAddress(192,168,0,123),IPAddress(192,168,0,1), IPAddress(255,255,255,0)); 34 | 35 | // Connect to WiFi network 36 | Serial.println(); 37 | Serial.print("Connecting to "); 38 | Serial.println(ssid); 39 | WiFi.begin(ssid, pass); 40 | 41 | while (WiFi.status() != WL_CONNECTED) { 42 | delay(500); 43 | Serial.print("."); 44 | } 45 | 46 | Serial.println(""); 47 | Serial.println("WiFi connected"); 48 | Serial.println("IP address: "); 49 | Serial.println(WiFi.localIP()); 50 | 51 | Serial.println("Starting UDP"); 52 | Udp.begin(localPort); 53 | Serial.print("Local port: "); 54 | Serial.println(Udp.localPort()); 55 | 56 | // btnInput + LED Output 57 | pinMode(btnPin, INPUT); 58 | pinMode(ledPin, OUTPUT); 59 | pinMode(boardLed, OUTPUT); 60 | } 61 | 62 | void loop() { 63 | // read btnInput and send OSC 64 | OSCMessage msgOut("/1/buttonListener"); 65 | 66 | if(digitalRead(btnPin) != btnVal) { 67 | isBtnChanged = true; 68 | btnVal = digitalRead(btnPin); 69 | } 70 | 71 | if(isBtnChanged == true){ 72 | isBtnChanged = false; 73 | digitalWrite(ledPin, btnVal); 74 | digitalWrite(boardLed, (btnVal + 1) % 2); // strange, but for the builtin LED 0 means on, 1 means off 75 | Serial.print("Button: "); 76 | Serial.println(btnVal); 77 | msgOut.add(btnVal); 78 | } 79 | 80 | Udp.beginPacket(destIp, destPort); 81 | msgOut.send(Udp); 82 | Udp.endPacket(); 83 | msgOut.empty(); 84 | delay(100); 85 | } 86 | -------------------------------------------------------------------------------- /Arduino-Code/SendReceiveOSC/SendReceiveOSC.ino: -------------------------------------------------------------------------------- 1 | /** 2 | * Send and receive OSC messages between NodeMCU and another OSC speaking device. 3 | * Send Case: Press a physical button (connected to NodeMCU) and get informed about it on your smartphone screen 4 | * Receive Case: Switch an LED (connected to NodeMCU) on or off via Smartphone 5 | * Created by Fabian Fiess in November 2016 6 | * Inspired by Oscuino Library Examples, Make Magazine 12/2015 7 | */ 8 | 9 | #include 10 | #include 11 | #include // for sending OSC messages 12 | #include // for receiving OSC messages 13 | 14 | char ssid[] = "difix"; // your network SSID (name) 15 | char pass[] = "88288828"; // your network password 16 | 17 | // Button Input + LED Output 18 | const int btnPin = 12; // D6 pin at NodeMCU 19 | const int ledPin = 14; // D5 pin at NodeMCU 20 | const int boardLed = LED_BUILTIN; // Builtin LED 21 | 22 | boolean btnChanged = false; 23 | int btnVal = 1; 24 | 25 | WiFiUDP Udp; // A UDP instance to let us send and receive packets over UDP 26 | const IPAddress destIp(192,168,0,3); // remote IP of the target device 27 | const unsigned int destPort = 9000; // remote port of the target device where the NodeMCU sends OSC to 28 | const unsigned int localPort = 8000; // local port to listen for UDP packets at the NodeMCU (another device must send OSC messages to this port) 29 | 30 | unsigned int ledState = 1; // LOW means led is *on* 31 | 32 | void setup() { 33 | Serial.begin(115200); 34 | 35 | // Specify a static IP address for NodeMCU - only needeed for receiving messages) 36 | // If you erase this line, your ESP8266 will get a dynamic IP address 37 | WiFi.config(IPAddress(192,168,0,123),IPAddress(192,168,0,1), IPAddress(255,255,255,0)); 38 | 39 | // Connect to WiFi network 40 | Serial.println(); 41 | Serial.print("Connecting to "); 42 | Serial.println(ssid); 43 | WiFi.begin(ssid, pass); 44 | 45 | while (WiFi.status() != WL_CONNECTED) { 46 | delay(500); 47 | Serial.print("."); 48 | } 49 | 50 | Serial.println(""); 51 | Serial.println("WiFi connected"); 52 | Serial.println("IP address: "); 53 | Serial.println(WiFi.localIP()); 54 | 55 | Serial.println("Starting UDP"); 56 | Udp.begin(localPort); 57 | Serial.print("Local port: "); 58 | Serial.println(Udp.localPort()); 59 | 60 | // btnInput + LED Output 61 | pinMode(btnPin, INPUT); 62 | pinMode(ledPin, OUTPUT); 63 | pinMode(boardLed, OUTPUT); 64 | } 65 | 66 | void loop() { 67 | receiveOSC(); 68 | sendOSC(); 69 | } 70 | 71 | void sendOSC(){ 72 | // read btnInput and send OSC 73 | OSCMessage msgOut("/1/buttonListener"); 74 | 75 | if(digitalRead(btnPin) != btnVal) { 76 | btnChanged = true; 77 | btnVal = digitalRead(btnPin); 78 | } 79 | 80 | if(btnChanged == true){ 81 | btnChanged = false; 82 | digitalWrite(ledPin, btnVal); 83 | digitalWrite(boardLed, (btnVal + 1) % 2); // strange, but for the builtin LED 0 means on, 1 means off 84 | Serial.print("Button: "); 85 | Serial.println(btnVal); 86 | msgOut.add(btnVal); 87 | } 88 | 89 | Udp.beginPacket(destIp, destPort); 90 | msgOut.send(Udp); 91 | Udp.endPacket(); 92 | msgOut.empty(); 93 | delay(100); 94 | } 95 | 96 | void receiveOSC(){ 97 | OSCMessage msgIN; 98 | int size; 99 | if((size = Udp.parsePacket())>0){ 100 | while(size--) 101 | msgIN.fill(Udp.read()); 102 | if(!msgIN.hasError()){ 103 | msgIN.route("/1/toggleLED",toggleOnOff); 104 | } 105 | } 106 | } 107 | 108 | void toggleOnOff(OSCMessage &msg, int addrOffset){ 109 | ledState = (boolean) msg.getFloat(0); 110 | 111 | digitalWrite(boardLed, (ledState + 1) % 2); // Onboard LED works the wrong direction (1 = 0 bzw. 0 = 1) 112 | digitalWrite(ledPin, ledState); // External LED 113 | 114 | if (ledState) { 115 | Serial.println("LED on"); 116 | } 117 | else { 118 | Serial.println("LED off"); 119 | } 120 | ledState = !ledState; // toggle the state from HIGH to LOW to HIGH to LOW ... 121 | } 122 | -------------------------------------------------------------------------------- /Hookup/Arduino_PinMapping.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janfiess/NodeMCU_OSC/79ebd9a0a320323f50cafb268acb095a67160994/Hookup/Arduino_PinMapping.jpg -------------------------------------------------------------------------------- /Hookup/Demo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janfiess/NodeMCU_OSC/79ebd9a0a320323f50cafb268acb095a67160994/Hookup/Demo.jpg -------------------------------------------------------------------------------- /Hookup/LayoutPart_NodeMCUV1.0.fzpz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janfiess/NodeMCU_OSC/79ebd9a0a320323f50cafb268acb095a67160994/Hookup/LayoutPart_NodeMCUV1.0.fzpz -------------------------------------------------------------------------------- /Hookup/SendReceive.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janfiess/NodeMCU_OSC/79ebd9a0a320323f50cafb268acb095a67160994/Hookup/SendReceive.fzz -------------------------------------------------------------------------------- /Hookup/SendReceive.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janfiess/NodeMCU_OSC/79ebd9a0a320323f50cafb268acb095a67160994/Hookup/SendReceive.jpg -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Voilà the project files for my instructable on YouTube: 2 | https://youtu.be/GKnuqrTxj9k 3 | 4 | This tutorial shows how to make a low budget NodeMCU wireless IoT controller communicate over OSC. The controller board is using an ESP8266 chip and is coded using Arduino. 5 | We cover all the steps (hooking up the board, installling the required software, coding) in order to make the controller board 6 | - receiving OSC messages (eg. to switch an LED on or off per smartphone) 7 | - sending OSC messages (eg. to get informed via smartphone that a button is pressed). 8 | 9 | In order to follow this instructable, you need some hardware and software: 10 | 11 | NodeMCU v1.0 (ESP8266 Wifi module with integrated programmer and micro USB connection) 12 | 13 | Arduino IDE 1.6.5 and up 14 | 15 | Button, LED, Resistors (eg. 220 ohms and 10kohms) 16 | 17 | Micro USB cable for programming the NodeMCU 18 | 19 | TouchOSC app for your smartphone or tablet (for 4,99 euros: Android: https://play.google.com/store/apps/details?id=net.hexler.touchosc_a&hl=deor or iOS: https://itunes.apple.com/de/app/touchosc/id288120394?mt=8) 20 | 21 | TouchOSC desktop editor for configuring the mobile interfaces: http://hexler.net/software/touchosc 22 | On current Mac OS operating systems (now is 2016 - Java 8), you may have trouble running the app because it was developed with Java 6. To get such apps running install https://support.apple.com/kb/DL1572?viewlocale=en_US&locale=en_US 23 | 24 | Wifi network with SSID and password 25 | 26 | ESP8266 library for Arduino: http://arduino.esp8266.com/stable/package_esp8266com_index.json 27 | 28 | OSCuino library for Arduino: https://github.com/CNMAT/OSC 29 | -------------------------------------------------------------------------------- /TouchOSC/Arduino+OSC.touchosc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janfiess/NodeMCU_OSC/79ebd9a0a320323f50cafb268acb095a67160994/TouchOSC/Arduino+OSC.touchosc --------------------------------------------------------------------------------