Notifications
Clear all

[Closed] TCP listener for iPhone controller

I’m developing a script to use an iPhone as a motion controller by sending the gyro, accelerometer and compass data via wifi to Max.

The iPhone app is already available and its called ‘GyroOSC’ it isn’t written by me and its an ‘Open Sound Controller’, what it does is it sends the data to an ip : port via tcp/ip.

I’m a advanced programmer in several languages but dotnet is not one of them and certainly not when it’s shoehorned into maxscript

So I need some help to setup the TCP/IP connection in maxscript so I can access the data, so far I got this:


  sock = dotNetClass "System.Net.Sockets.TcpListener" 
  
  type = dotNetClass "System.Int32"
  prt = dotnet.ValueToDotNetObject 9999 type
  
  socket=dotNetObject sock  prt
  
  showproperties  socket
  showmethods socket
  showEvents socket
  dotNet.showConstructors socket
  
  

Now I’m stuck… what I’m looking for is to create an event handler for when data comes.

(Another route is to find and OSC to Midi converter program and use Max’s midi function to do things but that is plan B )

9 Replies

Hey jonadb,
Did you ever find success with this? I know it was a while back. You have probably seen touchOSC and its use via MIDI and Max’s motion cap http://vimeo.com/34205207 . I would be interested to see what you’ve come up with.

jonah

@Jonadb,

Maybe you could also try a different approach and make it offline. I mean recording the data in a file witouth streamming it directly to the maxscript, and then access the file on the phone (vía web or itunes) or send it by email…

There is an App made by John Rand that does something like this, its the External Point3 Data.

@jonahhawk

Nice stuff that iPad rig control. Do you know the new Maide Control for iPad? Maybe you’ll find it interesting too: http://www.youtube.com/watch?v=V7V-UkDQUQo

Not sure how he is doing it, but Artur Leao/Kameleon is doing something with his existing iDevCam app.

-Eric

@Recubo,
I’ve done file streaming between Max and Grasshopper. It is clunky and slow. Max has issues with reading files which are actively being written to… It’s not the cleanest route. MIDI is cool but it seems like OSCis better suited.

TouchOSC is pretty sweet. It gives you the accelerometer and orientation of the device. (it's also available for Android) You can build a UI with many different control types. The connection to grasshopper via [gHowl]( http://www.grasshopper3d.com/group/ghowl)is  very straight forward. I'd love to see a similar .NET connection in Max. [Liblo]( http://opensoundcontrol.org/implementation/liblo-lightweight-osc-api)looks  interesting but it's in C. I'm an intermediate MaxScripter and a noob at C#.NET let alone C.

iDevCam is limited to one type of control, camera/navigation. You can pipe the output of touchOSC into any (float) value in grasshopper. You can set the domain of each control and map them en mass with gHowl dispatch…

I’ve been a Max user since the DOS days I still have my R4 box, books and floppy disks. But grasshopper is such a pleasure to work with. It is a truly visual programming environment. It’s open and extensible much like max has always been… I’ll stop evangelizing and go rant in the grasshopper forums.

Hey guys, nice work there! I’m actually using UDP, seems best for my needs. Like you’ve said, iDevCam is limited for now because my main intention was to create a controller for camera navigation but it can easily be adapted to control whatever values. I’ve actually included something new in 1.5 where you can control the timelime (play/pause/etc) in the iPhone. I will probably free the control to be able to move/rotate/drive any kind of object, wiring it to other values too but I’ll need to study an UI where you can do that, or else the app will look messier than it is (I totally suck at UI design xD)

If you need any help, drop me an email.

Since Kameleon finished the iPhone thing before I had a chance I took a different turn

I’ve created a thing called ‘Nexus’ and it’s a way of connecting Max to other Max instances (think object syncing, copy/paste etc) or make it connect to completely different apps or even webservers… but I’m completely swamped with client jobs so it’s on hold but It will come soon, can’t wait to start working on it again!

Looking for information, I found this:

http://techarttiki.blogspot.com/2009/12/maxscript-dotnet-sockets-with-python.html

Which might be quite interesting for our purposes

Jonah, nice experiment! I did not know Grasshopper.

Sockets for maxscript/dotnet, the Nexus evolved from these experiments:

http://forums.cgsociety.org/showthread.php?t=1015202