Skip to content

Working with Pure Data

anupam110191 edited this page Jan 22, 2015 · 9 revisions

Pure Data is a useful software application which can allow you to send OSC messages back and forth with the Processing software. Similar to the Max MSP application, it works by creating different objects and connecting them from input to output.

In our project, Pure Data was used as a replacement "RIME" to test whether the Processing code was compiling successfully. The only information required would be the IP Address and the Port you wish to send the information to.

Initially we used an iPhone application called "TouchOSC" which allows us to send and receive OSC messages to different devices. To download touchOSC visit http://hexler.net/software/touchosc. Here you will find a lot of information about how to use TouchOSC with Pure Data. Once the connection was made successfully, we began creating Pure Data functions to send OSC messages directly to the Processing application containing the main Viper code. Since RIME will be sending the messages to a different port, we can create a test station where we send each message to all ports between 12000 and 12015. The port can be set by inputting the number of the port on the last line of the JSON message you wish to send. The port number will depend on which port the receiving device is set to. For example, if it is set to 11000 you will put 11000 in the last line of the message.

The messages should be sent in a JSON format as shown in the image included. Additionally, the channel in which the messages will be sent is determined by the Device Identification number. By keeping the Device ID the same for all the messages we can send all of them through one single channel.

Below are step by step instructions on the Installation and Use of Pure Data. Additionally I have included an image of the test station to clarify the steps.

Installation

  • To install PD first go to puredata.info/downloads and click on the PD- Extended icon.

  • Once installed you will see two screens, one which tracks where you send or receive messages from and one which allows you to create such messages.

Use

  • To be able to send messages from PD to processing we need to use the empty screen in which we can create objects.

  • First create an object called “sendOSC”. An object can be created by clicking on the "put" drop down menu from the top bar and then clicking on "object".

  • Create another object called “send /rime deviceId oijgoaij2ojgawojfiawfjoa method create posX 0 posY 0 background 0 image ocean.jpg id 9”. This is the sample message we want to send to processing. It will cause a background image of a particular file (“ocean.jpg”) appear on the screen.

    • The “/rime” indicates where the message is coming from.
    • The deviceID is specific to the channel in which the message is travelling through, so changing the deviceID means changing the channel. The Id itself is an arbitrary value with 24 characters. The Ids are located in the Viper folder inside a file called registeredDevices.txt. By adding another arbitrary Id of 24 characters, we open up another channel to send the messages through.
    • The “method” can be “create” or “update” depending on what we want to manipulate. In this case we want to create a new image on the screen.
    • Pos X and Pos Y will determine where in the screen the image will be placed relative to the origin. -The “background” indiciates that the image should appear behind any other images that are called upon later.
    • The Id number refers to the particular image you want to manipulate. In this case id 9 will refer to the file ocean.jpg.
  • We create a final object as such “connect 206.87.128.212 11000”.

    • This will determine where we want to send our messages. The host IP address of the system you would like to send to is the first parameter and the port is the second.
  • Connect the output of the message object and the connect object to the input of the sendOSC object. This will now allow us to send OSC messages by clicking on first the connect object an then the message object.

  • You can use the tracking screen to check whether you have succesfully connected to a particular system. Additionally you can check for OSC messages which are sent from other systems to yours.

PD Test Station

As shown in the instructions, the sending of the messages must be done manually through Pure Data by pressing the message object. In RIME we expect this to occur through a series of gestures.

To fully test the system, we need to send every type of command such as "Grey" or "Blur" to Processing and observe the result. Additionally, we need to test for commands which are not in the system to show that it will only work for predefined image manipulations.

When this application is used as a replacement for RIME, we find that the image manipulations occur as expected.