changeset 22:d68f98883e63

This is the version that was vaguely working in the hub.
author Tim MB <tim.murraybrowne@eecs.qmul.ac.uk>
date Thu, 17 Feb 2011 18:00:02 +0000
parents 58fc7c2154cf
children ea0ff7df64f3
files Abletons max connection.maxpat tim_grid_mapper/grid_mapper.py
diffstat 2 files changed, 301 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/Abletons max connection.maxpat	Thu Feb 17 17:34:11 2011 +0000
+++ b/Abletons max connection.maxpat	Thu Feb 17 18:00:02 2011 +0000
@@ -1,9 +1,9 @@
 {
 	"patcher" : 	{
 		"fileversion" : 1,
-		"rect" : [ 86.0, 91.0, 895.0, 686.0 ],
+		"rect" : [ 204.0, 44.0, 988.0, 691.0 ],
 		"bglocked" : 0,
-		"defrect" : [ 86.0, 91.0, 895.0, 686.0 ],
+		"defrect" : [ 204.0, 44.0, 988.0, 691.0 ],
 		"openrect" : [ 0.0, 0.0, 0.0, 0.0 ],
 		"openinpresentation" : 0,
 		"default_fontsize" : 12.0,
@@ -20,8 +20,164 @@
 		"devicewidth" : 0.0,
 		"boxes" : [ 			{
 				"box" : 				{
+					"maxclass" : "newobj",
+					"text" : "udpsend localhost 12344",
+					"id" : "obj-32",
+					"fontname" : "Arial",
+					"numinlets" : 1,
+					"fontsize" : 12.0,
+					"numoutlets" : 0,
+					"patching_rect" : [ 747.0, 573.0, 144.0, 20.0 ]
+				}
+
+			}
+, 			{
+				"box" : 				{
+					"maxclass" : "newobj",
+					"text" : "prepend /person",
+					"id" : "obj-31",
+					"fontname" : "Arial",
+					"numinlets" : 1,
+					"fontsize" : 12.0,
+					"numoutlets" : 1,
+					"outlettype" : [ "" ],
+					"patching_rect" : [ 736.0, 533.0, 98.0, 20.0 ]
+				}
+
+			}
+, 			{
+				"box" : 				{
+					"maxclass" : "newobj",
+					"text" : "pak i f f f",
+					"id" : "obj-30",
+					"fontname" : "Arial",
+					"numinlets" : 4,
+					"fontsize" : 12.0,
+					"numoutlets" : 1,
+					"outlettype" : [ "" ],
+					"patching_rect" : [ 728.0, 454.0, 59.5, 20.0 ]
+				}
+
+			}
+, 			{
+				"box" : 				{
+					"maxclass" : "flonum",
+					"id" : "obj-29",
+					"fontname" : "Arial",
+					"numinlets" : 1,
+					"fontsize" : 12.0,
+					"numoutlets" : 2,
+					"outlettype" : [ "float", "bang" ],
+					"patching_rect" : [ 866.0, 403.0, 80.0, 20.0 ]
+				}
+
+			}
+, 			{
+				"box" : 				{
+					"maxclass" : "flonum",
+					"id" : "obj-27",
+					"fontname" : "Arial",
+					"numinlets" : 1,
+					"fontsize" : 12.0,
+					"numoutlets" : 2,
+					"outlettype" : [ "float", "bang" ],
+					"patching_rect" : [ 794.0, 403.0, 50.0, 20.0 ]
+				}
+
+			}
+, 			{
+				"box" : 				{
+					"maxclass" : "flonum",
+					"id" : "obj-25",
+					"fontname" : "Arial",
+					"numinlets" : 1,
+					"fontsize" : 12.0,
+					"numoutlets" : 2,
+					"outlettype" : [ "float", "bang" ],
+					"patching_rect" : [ 723.0, 399.0, 50.0, 20.0 ]
+				}
+
+			}
+, 			{
+				"box" : 				{
+					"maxclass" : "number",
+					"id" : "obj-23",
+					"fontname" : "Arial",
+					"numinlets" : 1,
+					"fontsize" : 12.0,
+					"numoutlets" : 2,
+					"outlettype" : [ "int", "bang" ],
+					"patching_rect" : [ 653.0, 403.0, 50.0, 20.0 ]
+				}
+
+			}
+, 			{
+				"box" : 				{
+					"maxclass" : "button",
+					"id" : "obj-21",
+					"numinlets" : 1,
+					"numoutlets" : 1,
+					"outlettype" : [ "bang" ],
+					"patching_rect" : [ 175.0, 322.0, 20.0, 20.0 ]
+				}
+
+			}
+, 			{
+				"box" : 				{
+					"maxclass" : "button",
+					"id" : "obj-19",
+					"numinlets" : 1,
+					"numoutlets" : 1,
+					"outlettype" : [ "bang" ],
+					"patching_rect" : [ 385.0, 319.0, 20.0, 20.0 ]
+				}
+
+			}
+, 			{
+				"box" : 				{
+					"maxclass" : "newobj",
+					"text" : "flush",
+					"id" : "obj-17",
+					"fontname" : "Arial",
+					"numinlets" : 2,
+					"fontsize" : 12.0,
+					"numoutlets" : 2,
+					"outlettype" : [ "int", "int" ],
+					"patching_rect" : [ 313.0, 356.0, 36.0, 20.0 ]
+				}
+
+			}
+, 			{
+				"box" : 				{
 					"maxclass" : "message",
-					"text" : "/pitch_vel_chan \"79 0 3\"",
+					"text" : "/chord",
+					"id" : "obj-16",
+					"fontname" : "Arial",
+					"numinlets" : 2,
+					"fontsize" : 12.0,
+					"numoutlets" : 1,
+					"outlettype" : [ "" ],
+					"patching_rect" : [ 358.0, 433.0, 44.0, 18.0 ]
+				}
+
+			}
+, 			{
+				"box" : 				{
+					"maxclass" : "newobj",
+					"text" : "udpsend 169.254.5.9 12345",
+					"id" : "obj-10",
+					"fontname" : "Arial",
+					"numinlets" : 1,
+					"fontsize" : 12.0,
+					"numoutlets" : 0,
+					"patching_rect" : [ 353.0, 538.0, 160.0, 20.0 ]
+				}
+
+			}
+, 			{
+				"box" : 				{
+					"maxclass" : "message",
+					"text" : "/pitch_vel_chan \"82 127 2\"",
 					"linecount" : 4,
 					"id" : "obj-9",
 					"fontname" : "Arial",
@@ -51,14 +207,15 @@
 , 			{
 				"box" : 				{
 					"maxclass" : "message",
-					"text" : "79 0 3",
+					"text" : "82 127 2",
+					"linecount" : 2,
 					"id" : "obj-6",
 					"fontname" : "Arial",
 					"numinlets" : 2,
 					"fontsize" : 12.0,
 					"numoutlets" : 1,
 					"outlettype" : [ "" ],
-					"patching_rect" : [ 403.0, 253.0, 50.0, 18.0 ]
+					"patching_rect" : [ 403.0, 253.0, 50.0, 32.0 ]
 				}
 
 			}
@@ -235,13 +392,139 @@
 					"numinlets" : 3,
 					"fontsize" : 12.0,
 					"numoutlets" : 0,
-					"patching_rect" : [ 306.0, 310.0, 61.0, 20.0 ]
+					"patching_rect" : [ 306.0, 404.0, 61.0, 20.0 ]
 				}
 
 			}
  ],
 		"lines" : [ 			{
 				"patchline" : 				{
+					"source" : [ "obj-29", 0 ],
+					"destination" : [ "obj-30", 3 ],
+					"hidden" : 0,
+					"midpoints" : [  ]
+				}
+
+			}
+, 			{
+				"patchline" : 				{
+					"source" : [ "obj-27", 0 ],
+					"destination" : [ "obj-30", 2 ],
+					"hidden" : 0,
+					"midpoints" : [  ]
+				}
+
+			}
+, 			{
+				"patchline" : 				{
+					"source" : [ "obj-25", 0 ],
+					"destination" : [ "obj-30", 1 ],
+					"hidden" : 0,
+					"midpoints" : [  ]
+				}
+
+			}
+, 			{
+				"patchline" : 				{
+					"source" : [ "obj-23", 0 ],
+					"destination" : [ "obj-30", 0 ],
+					"hidden" : 0,
+					"midpoints" : [  ]
+				}
+
+			}
+, 			{
+				"patchline" : 				{
+					"source" : [ "obj-30", 0 ],
+					"destination" : [ "obj-31", 0 ],
+					"hidden" : 0,
+					"midpoints" : [  ]
+				}
+
+			}
+, 			{
+				"patchline" : 				{
+					"source" : [ "obj-31", 0 ],
+					"destination" : [ "obj-32", 0 ],
+					"hidden" : 0,
+					"midpoints" : [  ]
+				}
+
+			}
+, 			{
+				"patchline" : 				{
+					"source" : [ "obj-21", 0 ],
+					"destination" : [ "obj-17", 0 ],
+					"hidden" : 0,
+					"midpoints" : [  ]
+				}
+
+			}
+, 			{
+				"patchline" : 				{
+					"source" : [ "obj-17", 1 ],
+					"destination" : [ "obj-1", 1 ],
+					"hidden" : 0,
+					"midpoints" : [  ]
+				}
+
+			}
+, 			{
+				"patchline" : 				{
+					"source" : [ "obj-19", 0 ],
+					"destination" : [ "obj-17", 0 ],
+					"hidden" : 0,
+					"midpoints" : [  ]
+				}
+
+			}
+, 			{
+				"patchline" : 				{
+					"source" : [ "obj-19", 0 ],
+					"destination" : [ "obj-16", 0 ],
+					"hidden" : 0,
+					"midpoints" : [  ]
+				}
+
+			}
+, 			{
+				"patchline" : 				{
+					"source" : [ "obj-17", 0 ],
+					"destination" : [ "obj-1", 0 ],
+					"hidden" : 0,
+					"midpoints" : [  ]
+				}
+
+			}
+, 			{
+				"patchline" : 				{
+					"source" : [ "obj-7", 0 ],
+					"destination" : [ "obj-17", 0 ],
+					"hidden" : 0,
+					"midpoints" : [  ]
+				}
+
+			}
+, 			{
+				"patchline" : 				{
+					"source" : [ "obj-7", 1 ],
+					"destination" : [ "obj-17", 1 ],
+					"hidden" : 0,
+					"midpoints" : [  ]
+				}
+
+			}
+, 			{
+				"patchline" : 				{
+					"source" : [ "obj-16", 0 ],
+					"destination" : [ "obj-10", 0 ],
+					"hidden" : 0,
+					"midpoints" : [  ]
+				}
+
+			}
+, 			{
+				"patchline" : 				{
 					"source" : [ "obj-3", 0 ],
 					"destination" : [ "obj-9", 1 ],
 					"hidden" : 0,
@@ -260,24 +543,6 @@
 			}
 , 			{
 				"patchline" : 				{
-					"source" : [ "obj-7", 1 ],
-					"destination" : [ "obj-1", 1 ],
-					"hidden" : 0,
-					"midpoints" : [  ]
-				}
-
-			}
-, 			{
-				"patchline" : 				{
-					"source" : [ "obj-7", 0 ],
-					"destination" : [ "obj-1", 0 ],
-					"hidden" : 0,
-					"midpoints" : [  ]
-				}
-
-			}
-, 			{
-				"patchline" : 				{
 					"source" : [ "obj-15", 0 ],
 					"destination" : [ "obj-7", 0 ],
 					"hidden" : 0,
--- a/tim_grid_mapper/grid_mapper.py	Thu Feb 17 17:34:11 2011 +0000
+++ b/tim_grid_mapper/grid_mapper.py	Thu Feb 17 18:00:02 2011 +0000
@@ -17,8 +17,8 @@
 
 #### OSC OPTIONS - THESE NEED TO BE SET MANUALLY ####
 my_port = 12344 # to receive OSC messages
-joe     = ('localhost', "THIS_MUST_BE_SET")
-ableton = ('localhost', "THIS_MUST_BE_SET")
+joe     = ('localhost', 12345)
+ableton = ('localhost', 12346)
 
 ### Constants for grid mapping:
 # The range of values that the input coordinates and output values may take:
@@ -30,6 +30,7 @@
 	'pitch'	: 0,
 	'cc1'   : 0,
 	'cc2'   : 0,
+	'velocity' : 0,
 }
 MAX = {
 	'x'     : 1.,
@@ -38,6 +39,7 @@
 	'pitch' : 15,
 	'cc1'   : 127,
 	'cc2'   : 127,
+	'velocity' : 127,
 }
 
 
@@ -64,7 +66,7 @@
 def send_to_joe(data, address='/test'):
 	'''Sends `data` to Joe directly as an OSC message.
 	'''
-	message = OSCMesssage(address)
+	message = OSCMessage(address)
 	message.extend(data)
 	client.sendto(message, joe)
 	print_d('==OSC Output to Joe %s:==\n    %s' % (joe, data))
@@ -79,10 +81,10 @@
 		send_to_joe([
 			'Turn off note %i on channel %i' % (pitch, channel), 
 			    # first string is ignored
-			pitch,       # pitch to turn off
+			int(pitch),       # pitch to turn off
 			0,                                # 0 to turn note off
 			127,                # doesn't matter for note-off (but never send 0)
-			channel,
+			int(channel),
 		])
 
 
@@ -91,7 +93,8 @@
 	
 	`data` should be in form [person_id, x, y, z]
 	'''
-	pitch, velocity, channel, cc1, cc2 = grid_map(data)
+	pitch, velocity, channel, cc1, cc2 = grid_map(*data)
+	
 	
 	## Format data for Joe - done using Specification.txt on 2011-02-15
 	
@@ -109,10 +112,10 @@
 		send_to_joe([
 			'Turn on note %i on channel %i' % (pitch, channel),
 				# first value is string which is ignored
-			pitch,    
+			int(pitch),    
 			1,        # 1 to turn note on
-			velocity, 
-			channel
+			int(velocity), 
+			int(channel)
 		])