aboutsummaryrefslogtreecommitdiffstats
path: root/random241osc.py
diff options
context:
space:
mode:
authorDavid Runge <david.runge@frqrec.com>2014-01-31 11:48:32 +0100
committerDavid Runge <david.runge@frqrec.com>2014-01-31 11:48:32 +0100
commit9ea16a768cd4143d2a3508d7193f8d0d784e40be (patch)
tree44baccc06244854d8efc5814f2b13917a24a7e74 /random241osc.py
parentf36bab3657757251435c676f91991873387e324d (diff)
downloadrandom241-9ea16a768cd4143d2a3508d7193f8d0d784e40be.tar.gz
random241-9ea16a768cd4143d2a3508d7193f8d0d784e40be.tar.bz2
random241-9ea16a768cd4143d2a3508d7193f8d0d784e40be.tar.xz
random241-9ea16a768cd4143d2a3508d7193f8d0d784e40be.zip
First commit, still some TODOs
Diffstat (limited to 'random241osc.py')
-rwxr-xr-xrandom241osc.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/random241osc.py b/random241osc.py
new file mode 100755
index 0000000..3d95f69
--- /dev/null
+++ b/random241osc.py
@@ -0,0 +1,31 @@
+#import OSC as osc
+import liblo as osc
+import logging
+
+# Declare an empty target
+target = None
+
+
+# Connect to the server
+def connect_to_server(hostname, port):
+ global target
+ if (hostname or port) is None:
+ target = osc.Adress('127.0.0.1', 57120, osc.TCP)
+ else:
+ try:
+ target = osc.Address(hostname, port, osc.TCP)
+ except osc.AddressError, err:
+ logging.error(err)
+
+
+# Send a osc_message to the server
+def send_osc_msg_to_server(randomness):
+ global target
+ # if the message is not empty and longer than 1
+ if randomness is not None and len(randomness) > 1:
+ msg = osc.Message("/random")
+ msg.add(randomness[0], randomness[1])
+ try:
+ osc.send(target, msg)
+ except:
+ logging.error('OSC: Sending of message failed.')