Zum Hauptinhalt

Lesson 8 - Sending data from a smart device to Pure Data with TouchOSC

Download and setup of TouscOSC. How to send data from a smart device to a Pure data patch and being sure to receive them.

Lesson 8:

edu sharing object


00:05 - Lesson 08. Sending data from a smart device to Pure Data with TouchOSC. 12:00 - In this tutorial we are going to see how it is possible to send data from a smart device to Pure Data over a network. Which kind of data are we speaking about? If you own a smart device, e.g. an iPhone, Android phone, Windows tablet and so on, one of the things that happens quite often is that when you rotate your device the screen automatically adapts to the new orientation. Do you know what makes it possible? It is due to two different sensors that are embedded in our devices: a gyroscope and an accelerometer. 00:50 - Both work in conjunction in order to detect the orientation of a device along three axes, conventionally named x, y and z, which correspond to horizontal, vertical and depth, respectively. So when we speak about data we are specifically looking at the data of the accelerometer. These are the data we want to retrieve and not only these ones, as you will see! 01:15 - In order to send this data we need to download and install on our smartphones the app “TouchOSC”. Let’s go to the AppStore or Google Play and look for it . . . here we go. 01:43 - Unfortunately this app is not free and I couldn’t find another one that is open-source and as easy to use as this one. The good news is that it costs less than 6 euros and allows you to transform the data coming from the device on which it has been installed, in a bundle or as a flow of packages, sent over a network, received and finally decoded by another software such as Pure Data. 02:10 - You might wonder, why do we need to send data over a network? The goal is to create an instrument, in the form of a Pure Data patch, and to control it without using a keyboard and mouse but rather with our own body gestures, retrieved by holding a smart device in our hands. Once you have installed TouchOSC you can open it. 02:34 - The first thing you need to do is to click on the first line named “OSC”. 02:43 - In this panel we set some information that will allow TouchOSC to “talk” to our patches. First the “Enabled” switch needs to be set on. 02:58 - Then we have “host”. Here we need to put the IP address of the machine we want to send data to. 03:08 - Finding it is really easy. On Macintosh machines it is visible at the following path: “System Preferences > Network” and it is this one. 03:26 - On Windows machines it is slightly different and you need to go to “Start Icon > Settings > Network & Internet > Advanced options”, then scroll down to the “Properties” section to see the IP address of the machine. 03:56 - Now you need to type the exact same number in the host panel on TouchOSC. 04:05 - The last thing we need to do is to assign a “port” to our outgoing messages. Therefore in “Port (outgoing)” panel type whatever number with 4 digits bigger than 5000. I’m currently using 9000 for example. 04:21 - Two important suggestions for now: always use a different port number for each smart device, otherwise the data coming from different devices will interfere with each other!!! 03:34 - Now we can select “TouchOSC”, go back and select “Done”. This graphic user interface or something similar will appear. Let’s discard it because for the moment it is not relevant. We did the first step; the smartphone is now set. Let’s now go back to Pure Data and create a brand new patch. Be sure that the computer hosting Pure Data and the smart device you are using to send data are logged into the same network, otherwise you won’t be able to send any data. Be aware that whenever you select a different network, IP numbers change. 05:16 - If you downloaded the folder that is provided as documentation to this series, then create a new object, which you should now already know how to do that (ctrl_1/cmd_1) and then type inside of it “abs underscore oscListener”. 05:38 - The object we just created is a special one and it is not available by default because I implemented this for you. 05:47 - This object actually contains inside of it another patch, so it’s like a Russian doll. It’s easy to recognise such kinds of objects because the name I gave it is prepended with “abs underscore” where “abs” stands for “abstraction”. To have a look at the patch inside, exit the “edit” mode, ctrl_E/cmd_E and click on the object name. 06:18 - As you can see this embedded patch is more complex than the patches we know but you don’t have to worry about that. All you need to know for the moment is that the core objects, capable of receiving and interpreting the messages coming from the smartphone are these two: “netreceive” and “oscparse”. 06:41 - Now you can look at each of their help files if you want to understand how they work, otherwise just close the abstraction; it is ready to be used! Only two things are missing. First we need to tell this fancy object, or more precisely “abstraction”, at which port it needs to listen. 07:02 - So we create a message, ctrl_2/cmd_2, and type “listen” and then the same port number we assigned as “Port (outgoing)” in TouchOSC. I will type 9000. 07:20 - The flow of data is continuous so we also need to create a message to gate the flow. All we need to do is to copy/paste the “listen” message we already created and edit it into “listen 0”. 07:37 - This will stop the flow. 07:43 - The very last thing to do is to create three “numberboxes” and connect them to the first three outlets. 08:05 - Are you ready? Let’s exit the “edit” mode, and click on “listen 9000” and now you can see data coming and you can start to move your smartphone. Congratulations, this was a big achievement! 08:23 - If the data are not coming for some reason, be sure that both smart device and computer you want to send data to are logged into the same network. 08:35 - Then please check that you have typed the correct IP address inside TouchOSC and that the port number corresponds on both devices. If the problem persists you might have some settings that prevent communication over network or the ports are not properly set. I suggest you either turn off the firewall if one is present or ask the support of the person in charge of the IT Department of your school. So which kind of data are we receiving? Or, in other words, what are accelerometer data? The accelerometer measures the acceleration of a body in three axes, x, y and z, and dynamically senses the movement or vibrations of our smartphone. In the next tutorial we are going to see how we can couple this data with the synthesis techniques we have learned.

Example Patch:


edu sharing object

Zuletzt geändert: Dienstag, 12. September 2023, 18:23