Mercurial > hg > movesynth
changeset 41:5b6f63b6f76d
Updated grid_mapper and specification
author | Tim MB <tim.murraybrowne@eecs.qmul.ac.uk> |
---|---|
date | Tue, 01 Mar 2011 14:09:59 +0000 |
parents | e1b88e546699 |
children | 0d8f90974775 |
files | Specification.txt tim_grid_mapper/grid_mapper.py |
diffstat | 2 files changed, 21 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/Specification.txt Tue Mar 01 12:28:46 2011 +0000 +++ b/Specification.txt Tue Mar 01 14:09:59 2011 +0000 @@ -43,6 +43,9 @@ i0 - identifier of person f1, f2, f3 - x, y, z of person +/stopperson i0 +sent when person i0 leaves the view + Send OSC to Joe: (defined above)
--- a/tim_grid_mapper/grid_mapper.py Tue Mar 01 12:28:46 2011 +0000 +++ b/tim_grid_mapper/grid_mapper.py Tue Mar 01 14:09:59 2011 +0000 @@ -18,7 +18,9 @@ # make noise). #### OSC OPTIONS - THESE NEED TO BE SET MANUALLY #### -my_port = 12344 # to receive OSC messages from kinect +my_port = 12343 # to receive OSC messages from kinect + +debugging = True # display incoming packets # Both joe and ableton ip addresses are now read from the file ip_addresses.txt # which is written to by the set_ip_addresses() function. @@ -122,11 +124,21 @@ currently_playing[channel] = None +def stopperson_handler(address, tags, data, clinet_address): + ''' Handles OSC input matching 'stopperson' + + Called when a person leaves the screen. + ''' + flush(data[0]) + def person_handler(address, tags, data, client_address): ''' Handles OSC input matching the 'person' tag. `data` should be in form [person_id, x, y, z] ''' + if debugging: + print('Received packet:') + print(str(data)) pitch, velocity, channel, cc1, cc2 = grid_map(*data) channel = channel + 1 cc1, cc2 = int(round(cc1)), int(round(cc2)) @@ -136,7 +148,7 @@ if cc2 != last_value_sent[(channel, 2)]: send_to_ableton([channel, 2, cc2], '/cc') last_value_sent[(channel, 2)] = cc2 - + ## Format data for Joe - done using Specification.txt on 2011-02-15 @@ -229,6 +241,7 @@ server = ThreadingOSCServer(('localhost', my_port)) # Register OSC callbacks: server.addMsgHandler('/person', person_handler) + server.addMsgHandler('/stopperson', stopperson_handler) t = Thread(target=server.serve_forever) t.start() if server.running and t.is_alive(): @@ -297,8 +310,8 @@ f = open(save_file, 'w') f.write( '''# This is a cache. These addresses will be overridden by Python if you set something different. Do not leave comments here they will be overridden -ableton = %s # set Ableton IP and port -joe = %s # set Joe's processing IP and port +%s # set Ableton IP and port +%s # set Joe's processing IP and port ''' % (str(ableton),str(joe)) ) f.flush() @@ -317,7 +330,7 @@ start() while True: try: - print(repr(input())) + print(eval(input())) except Exception as e: print('Caught %s:' % repr(e)) exception = e