├── LICENSE ├── readme.md └── OSC_DataMonitor ├── OSCListener.pde └── OSC_DataMonitor.pde /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Kasper Kamperman 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # OSC (Open Sound Control) Data Monitor 2 | 3 | Monitor incoming OSC data on your network with this little program. A quick way to check if you have communication with OSC sending equipment in your network. See [kasperkamperman.com/blog/osc-datamonitor/](https://www.kasperkamperman.com/blog/osc-datamonitor/) for a video walkthrough. 4 | 5 | This repo contains the source code for Processing 4. You have to install the used libraries yourself in order to run it (OscP5, ControlP5). 6 | 7 | You can get the Windows and (signed) MacOS applications [here on Lemonsqueezy](https://kasperkamperman.lemonsqueezy.com/checkout/buy/03e29103-797b-4eb7-9f7c-231094426cf7) (price $7.99). 8 | 9 | If you are on Linux or another OS I recommend you to use Processing and build the application yourself if you need. 10 | 11 | --- 12 | 13 | Thanks to [Andreas Schlegel (sojamo)](http://sojamo.com) for the excellent [OscP5](http://www.sojamo.de/libraries/oscp5/) and [ControlP5](https://github.com/sojamo/controlp5) libraries on which this program heavily relies. 14 | 15 | This monitor was originally developed for a [databending workshop](https://code.google.com/archive/p/osc-tools/). 16 | 17 | --- 18 | ## More info about the OSC protocol. 19 | 20 | * [YouTube video. The OSC protocol explained by me.](https://www.youtube.com/watch?v=0uOR2idKvrM) 21 | 22 | * [the_osc_protocol](http://www.osculator.net/doc/manual:the_osc_protocol) 23 | 24 | --- 25 | ## License 26 | 27 | MIT 28 | -------------------------------------------------------------------------------- /OSC_DataMonitor/OSCListener.pde: -------------------------------------------------------------------------------- 1 | // == OscListener =============================================== 2 | 3 | class MyOSCListener { 4 | 5 | int port; 6 | OscP5 osc; 7 | boolean filterMessage; 8 | 9 | MyOSCListener(int thePort) { 10 | port = thePort; 11 | osc = new OscP5(this,port); 12 | } 13 | 14 | public void stop() { 15 | osc.stop(); 16 | } 17 | 18 | public void oscEvent(OscMessage theOscMessage) { 19 | 20 | // store address in oscaddressesHash 21 | addOSCaddress(theOscMessage.addrPattern()); 22 | 23 | // normally all messages are filtered (pass through filter) 24 | // if there is an item in the oscFilteraddressedHash its 25 | // compared with the incoming message if the addresses in in the Hash list 26 | // the message is passed through. 27 | 28 | if(countFilteredaddresses>0) 29 | { filterMessage = false; 30 | 31 | if((Integer) oscaddressesHash.get(theOscMessage.addrPattern()) == 1) 32 | { filterMessage = true; 33 | } 34 | } 35 | else filterMessage = true; 36 | 37 | // only monitor message if filter pass through is true 38 | if(filterMessage) 39 | { // empty the monitor string 40 | monitor = ""; 41 | 42 | // dadd address pattern to string 43 | monitor = "["+port+"] " + theOscMessage.addrPattern(); 44 | 45 | typetag = theOscMessage.typetag(); 46 | 47 | // display each data item in the monitor. 48 | for(int i=0;imonitorListLength) 197 | { monitorList.remove(0); 198 | } 199 | 200 | mTextarea.setText(monitorDisplay); 201 | } 202 | 203 | // == ControlP5 events =========================================== 204 | 205 | //void listActiveOscPorts(int value) { 206 | // println(value); 207 | //} 208 | 209 | void controlEvent(ControlEvent theEvent) { 210 | 211 | if(theEvent.isController()) { 212 | 213 | int value = int(theEvent.getController().getValue()); 214 | String name = theEvent.getController().getName(); 215 | //print("control event from : "+name); 216 | //println(", value : "+value); 217 | 218 | if(name == "listActiveOscPorts") { 219 | int val = (int)listActiveOscPorts.getItem(value).get("value"); 220 | stopListeningToPort(val); 221 | } 222 | 223 | if(name == "listCommonOscPorts") { 224 | int val = (int)listCommonOscPorts.getItem(value).get("value"); 225 | startListeningToPort(val); 226 | } 227 | 228 | if(name == "listReceivedOscAddresses") { 229 | // check if item is already filtered 230 | String s = (String) oscaddressesList.get(value); 231 | 232 | if((Integer)oscaddressesHash.get(s) == 0) { 233 | listMonitorOSCAddresses.addItem(s, value); 234 | oscaddressesHash.put(s,new Integer(1)); 235 | countFilteredaddresses++; 236 | } 237 | } 238 | 239 | if(name == "listMonitorOSCAddresses") { 240 | String s = (String) oscaddressesList.get(value); 241 | 242 | listMonitorOSCAddresses.removeItem(s); 243 | countFilteredaddresses--; 244 | 245 | oscaddressesHash.put(s,new Integer(0)); 246 | } 247 | 248 | if(name == "add Port") { 249 | // trigger the textInput function below with the textInput data 250 | textInput.submit(); 251 | } 252 | 253 | if(name == "Clear views") { 254 | listReceivedOscAddresses.clear(); 255 | listMonitorOSCAddresses.clear(); 256 | monitorHash.clear(); 257 | monitorList.clear(); 258 | oscaddressesHash.clear(); 259 | oscaddressesList.clear(); 260 | countFilteredaddresses = 0; 261 | oscaddressCounter = 0; 262 | } 263 | 264 | } 265 | 266 | if (theEvent.isGroup()) { 267 | //int value = int(theEvent.getGroup().getValue()); 268 | 269 | //print("control event from : "+theEvent.getGroup().getName()); 270 | //println(", value : "+ value); 271 | 272 | if(theEvent.getGroup().getName()=="radioButton") 273 | { if(theEvent.getGroup().getValue() == 1) 274 | { monitorValueView = true; 275 | mTextarea.showScrollbar(); 276 | } 277 | else 278 | { monitorValueView = false; 279 | mTextarea.hideScrollbar(); 280 | } 281 | } 282 | 283 | 284 | } 285 | 286 | } 287 | 288 | public void textInput(String s) { 289 | s = trim(s); 290 | 291 | // check if text input is a valid port number. 292 | String[] m = match(s, "[^0-9]|[0-9]{6}"); 293 | 294 | if(m != null) 295 | { // print error in monitor 296 | monitorList.add((String) "- Please enter a number between 0 - 65535 "); 297 | } 298 | else 299 | { if(int(s)>65535) 300 | { // print error in monitor 301 | monitorList.add((String) "- Please enter a number between 0 - 65535 "); 302 | } 303 | else 304 | { // add the port number to listCommonOscPorts. 305 | listCommonOscPorts.addItem(s, int(s)); 306 | } 307 | } 308 | } 309 | 310 | public void startListeningToPort(int port) 311 | { // triggered when clicking item in listCommonOscPorts. 312 | 313 | // check if we are not already listening by checking the Hashmap 314 | // add new OscListener object to the oscP5Objects HashMap 315 | if(!oscP5Objects.containsKey(port)) 316 | { println(oscP5Objects.size()); 317 | // check if HashMap size() < 10 318 | if(oscP5Objects.size()<10) 319 | { MyOSCListener o = new MyOSCListener(port); 320 | 321 | oscP5Objects.put(port,o); 322 | // add item to listActiveOscPorts 323 | listActiveOscPorts.addItem(str(port), port); 324 | listCommonOscPorts.removeItem(str(port)); 325 | monitorList.add((String) "- Listening to port: "+port); 326 | } 327 | else 328 | { monitorList.add((String) "- Cannot listen to more than 10 ports"); 329 | } 330 | } 331 | else 332 | { monitorList.add((String) "- Already listening to port: "+port); 333 | } 334 | } 335 | 336 | public void stopListeningToPort(int port) 337 | { // triggered when clicking item in listActiveOscPorts 338 | 339 | if(oscP5Objects.containsKey(port)) 340 | { // get the port from the HashMap 341 | MyOSCListener o = (MyOSCListener) oscP5Objects.get(port); 342 | 343 | o.stop(); // stop listening 344 | oscP5Objects.remove(port); // remove port from HashMap 345 | 346 | // remove item from listActiveOscPorts 347 | String item = Integer.toString(port); 348 | listActiveOscPorts.removeItem(item); 349 | //listActiveOscPorts.addItem(str(port), port); 350 | listCommonOscPorts.addItem(str(port), port); 351 | monitorList.add((String) "- Stopped listening to port: "+port); 352 | } 353 | } 354 | 355 | void addOSCaddress(String s) { 356 | 357 | if (!oscaddressesHash.containsKey(s)) 358 | { // Hash used to check if the adres already was used before. 359 | //println("not in list yet: "+s+" "+oscaddressCounter); 360 | oscaddressesHash.put(s,new Integer(0)); 361 | 362 | // show in list. 363 | listReceivedOscAddresses.addItem(s,oscaddressCounter); 364 | oscaddressesList.add(new String(s)); // index will be the same as the oscaddressCounter 365 | oscaddressCounter++; 366 | } 367 | 368 | } 369 | --------------------------------------------------------------------------------