Week 16: Interface and Application Programming

Lecture Neil 18/05/2016

Tutorial Bas 20/05/2016 at FabLab Reykjavik

Assignment: write an application that interfaces with an input and/or output device that you made.

 

Thumbnail Image 1

1

For a long-term project that I am involved in, the platform we choose for development is Derivative’s TouchDesigner, a procedural, node-based, real-time, visual programming language used for building interactive 3D and 2D applications (see Derivative’s website). Since in this context I recently started to program with TouchDesigner myself too, for this week’s assignment I wanted to make a simple TouchDesigner application and find out how to use an ATtiny board to sense changes in the physical world as an input device for that application.

Thumbnail Image 1

2

To see what has been done before, I googled TouchDesigner + ATtiny and found … nothing. Then I searched for ATtiny on Derivative’s own website, but again found nothing. What I did find though on the Derivative website was a 2010 MIT Media Lab project using Arduino data as input from the outside world into a TouchDesigner application called The Never-Ending Drawing Machine. After having looked into this I trusted it would work about the same for an ATtiny board.

 

Thumbnail Image 1

3

The board I choose for this was the synchronous detection board I made in week 11. To get good and consistent data from the board I glued a piece of black neoprene next to a piece of white paper on the bottom of a small box and made a slit in the box allowing the board to be moved horizontally back and forth from position 1 to 2 while the box was closed.

 

Thumbnail Image 1

4

First thing to take care of now was how to get the board’s data into TouchDesigner. Since in TouchDesigner it is pretty easy to receive messages from the outside world using OSC, a simple way seemed to be to use the original hello.reflect.45.py and add some lines to it to connect to TouchDesigner and to send messages (calculated values) over OSC. For this a Python package was needed that was not installed on my machine, so I downloaded it here, unzipped it to my AppData\Local\Enthought\Canopy\User\Lib\site-packages folder and installed it using the python setup.py install command in CMD. I checked and could see the package, including OSC.py, was properly installed in the site-packages folder.

Thumbnail Image 1

5

Next thing to do was to add the extra lines in the hello.reflect.45.py script to connect to Touch Designer and to send messages . Since apart from using the sendOSC command to send messages I really didn’t know how to proceed, I asked my friend Víðir Hallgrímsson for help. He helped me to make both the adaptations to the python script (see screendump of first part of the adapted script) and the TouchDesigner application. For easy comparison I include both the original hello.reflect.45.py and the adapted version of the script.

 

Thumbnail Image 1

6

At the TouchDesigner side I wanted to keep things really simple: make the Trillium flower that appears standard when opening TouchDesigner change its movement, depending on the incoming values sent to TouchDesigner over OSC. To achieve this a few DATs (Data Operators; see end of text ) and CHOPs (CHannel Operators; see end of text) were added to the template operators, to start with an OSC In DAT for receiving and parsing full OSC packets using UDP, each packet being parsed and appended as a row in the DAT’s table. From there the values are read into a Table DAT to be used as input for a Constant CHOP named constant1.

 

Thumbnail Image 1

7

 

In this constant1 CHOP 3 new constant value channels were created: on_value, off_value and difference. By the way their respective values at any moment in time are graphically displayed on screen in the constant1 CHOP and by positioning the original script’s version of displaying these values next to it, it is easy to see that sending OSC messages from within the python script works really good to get the ATtiny sensor data into TouchDesigner.

Thumbnail Image 1

8

To make the Trillium flower change its intensity of movement depending on whether the synchronous detection board was held above the black surface or above the white surface in the box (comparable to the changes that can be seen in the graphic representation of this in the previous picture and the picture above), the constant1 CHOP was channelled to the noise CHOP that is part of the template operators (bottom left in first picture). For reference a second constant CHOP reffValue was created and also channelled to that noise CHOP. In reality the difference in movement was very minimal, even when changing the reffValue. My friend Víðir and I decided not to put more time in trying to enlarge the effect, blaming our lack of in-depth TouchDesigner knowledge for it. Apart from this I think my attempt to use an ATtiny sensor board as an input device for a TouchDesigner application was very successful.

 

Thumbnail Image 1

9

Addendum: A brief description of the types of operators that were used for this simple application can be read in the picture above. In-depth information about TouchDesigner operators can be can found here on the TouchDesigner wiki.

 

FILES: All files of this week can be found here.

 
© Inger Le Gué, Reykjavik 2016