Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

How to use OSC

in Questions Posts: 15

I now this sounds a little weird because I have made an AI already but I have been trying to work out OSC for over 2 hours now so can someone please help and paste example code at bottom

Comments

  • dave1707dave1707 Mod
    edited August 31 Posts: 7,923

    @joaquin Here's an example. Put this code on both devices and run it. It will show the IP address of the device it's running on. Put the IP address in the code below for the other devices so each device knows it's IP address and the other devices address. Then run this on both devices, move your finger around and the sprite will move on the other device.

    PS. There is also some code on the forum where I can transfer projects from one iPad to the other. I haven't found it yet.

    function setup()
        host = osc.start()  -- address of this ipad
        print(host)
        osc.host = "192.168.254.15"  -- put address of other ipad here
        x,y=0,0      
    end
    
    function draw()
        background(0)
        sprite("Planet Cute:Character Horn Girl",x,y)
    end
    
    function osc.listen(address, ...)
        arg={...}
        x=arg[1]
        y=arg[2]
    end
    
    function touched(t)
        if t.state==MOVING then
            osc.send("/",t.x,t.y)
        end
    end
    
  • dave1707dave1707 Mod
    Posts: 7,923

    @joaquin Here's a link to code I wrote to transfer project from one iPad to another.

    https://codea.io/talk/discussion/9464/the-new-osc-capability-in-2-7-is-wonderful#latest
    
  • edited August 31 Posts: 15

    Thanks

  • AnatolyAnatoly Mod
    edited September 2 Posts: 877

    @dave1707 Do you know if you can have only one connection (osc.host) or can you have multiple OSCs running?

    Edit: I can think of switching to the needed port every time before sending an event, but I'm sure there was another way of doing so, can't find right now.

Sign In or Register to comment.