December 15, 2008

How to Control Animata With OSC from Max/MSP and Pure Data

NOTE! I am moving my website over to http://mansteri.com/. The commenting has been disabled on this site. You can find this same article with commenting and everything by clicking this link: http://mansteri.com/2008/12/animata-osc/.

If you haven’t heard of Animata yet, you should head over to http://animata.kibu.hu/index.html and educate yourself. Download the software and go through the tutorials. I also recommend reading through the mailing list, it has tons of useful information.

Controlling Animata with a mouse and doing real-time animations is pretty cool by itself, but Animata really shows its true potential when you control it with OSC. Then you can start doing something like this:

There is a Processing example available from the Animata site that controls Animata with sound input.

HOW DOES IT WORK?

Unfortunately, the Kitchen Budapest guys are busy improving the software and there isn’t really good documentation available about the OSC messages needed to control Animata. I’ll try to go through all of the available messages and give you some examples in Pure Data and Max/MSP

I assume that you know something about OSC, Pure Data and Max/MSP, because I don’t want to write a huge post explaining everything from the beginning. I’m also assuming that you have spent some time learning the basics of Animata.

One more important thing. I’m using revision 35 of Animata compiled from the svn repository. NOTE! YOU WILL NEED TO COMPILE ANIMATA FROM THE SOURCE CODE TO MAKE THE /LAYERPOS MESSAGES WORK. IT IS NOT AVAILABLE IN THE BINARY VERSION ON THE ANIMATA WEBSITE. All the other messages I’m showing here do work with Animata 003 that is available from the site. OK, let’s start.

DOWNLOAD MY EXAMPLES. Contains the Animata Scene + Max and PD patches.

FORMATTING THE OSC MESSAGES

All incoming messages to Animata must be sent through port 7110. The “name” in the message refers to the name of the joint, bone or layer.

Moving a joint, x and y are float values:

/joint name x y

Control the length of a bone, value is a float between 0 and 1:

/anibone name value

Switch on and off a layer, on_off is 0 or 1:

/layervis name on_off

Set the transparency of the layer, value is a float between 0 and 1:

/layeralpha name value

The next two messages require the svn version:

Moving a layer in absolute mode, x and y are the position coordinates as float values:

/layerpos name x y

Moving a layer in relative mode, x and y is the amount of pixels you want the layer to move from it’s current position:

/layerdeltapos name x y

PURE DATA TO ANIMATA

I’m not really comfortable with Pure Data, but I was able to get all of the messages working except /layervis. I believe this is because Animata is very picky and is looking for real boolean values and Pure Data is sending integers when sending 0 or 1. This was just fixed by the Kitchen Budabest guys. The /layervis message works now. I have updated the code so please download the .zip again. You need to compile Animata again from the svn for this to work.

Pure Data to Animata


Pure Data to Animata with OSC from Matti Niinimäki on Vimeo.

There is a little problem, because Animata needs float values in the messages and Pure Data doesn’t have a separate number box for floats, so have to make sure the number you are sending is never an even number. I did this by multiplying the values by 0.999. If someone knows a better way, let me know.

MAX/MSP 5 TO ANIMATA

It’s pretty much the same deal with Max/MSP. The /layervis doesn’t work here either. This was fixed in the svn version (>36). My Max-patch has been updated so please download again.

Max to Animata


Max/MSP to Animata With OSC from Matti Niinimäki on Vimeo.

I didn’t add the /layerdeltapos to the example patches, because it’s really easy to lose your layers somewhere outside the window.

SENDING OSC FROM ANIMATA

There is also an option to send OSC messages from Animata. For this you need the SVN version. It simply works by clicking on the small OSC tick box on the Skeleton tab. The messages are sent through port 7111. The message format is: /joint name x y

Send OSC

QUARTZ COMPOSER

I’ve made a plugin for Quartz Composer that makes it really easy to control Animata from Quartz Composer. Check it out over here.

HOW ABOUT OPEN FRAMEWORKS, PROCESSING ETC.

Basically, any software or programming environment that is able to send OSC messages should be able to communicate with Animata.

Processing works perfectly and you can download the Sound Input example from the Animata website that will get you started. I’ll see if I can find the time to do a similar sample file for Processing also.

I’ve also had luck testing OpenFrameworks. Download the FAT version of OpenFrameworks and modify the oscSenderExample.

WHAT CAN YOU DO WITH THIS?

Whatever you want! Hook up audio input, MIDI controllers, sensors or computer vision to control real-time animations.

Check out my Mickey Mann project for an example on how to control Animata with an Arduino.

Here is the source code download link one more time.

Tags: , , , ,
Filed under: Animation,Programming,Tutorial,Video — Posted by: Månsteri @ 3:46

December 13, 2008

Tooniversity

Not many people know this, but Concordia University in Montréal also has a toon department deep inside the maze that is known as the EV building. The university officials would prefer to keep this knowledge as a secret, since the brutal self torture that goes on inside the faculty would shock many people. In the same way that the Average Joe or Jane does not want to know where the meat inside his/her burger comes from, no-one really wants to know the shocking truth about the stories behind your Saturday morning dose of laughter.


Tooniversity from Matti Niinimäki on Vimeo.

When watching cartoons, people rarely think about the amount of time and dedication the cartoon characters spend on perfecting their sketches and routines. Unfortunately, consumers love to see toons getting hurt. There is just something special about dropping heavy anvils on the heads of unsuspecting cartoon characters that appeals to the majority of viewers.

Like in all fields of entertainment, the competition in the cartoon business is also very harsh. You are only as good as your last fall from a huge cliff. That’s why all the aspiring cartoon students at tooniversities across the world practice new and inventive ways of getting themselves hurt.

A group of activists from PETT (People for the Ethical Treatment of Toons) have been able to sneak a spy camera inside the Tooniversity facilities at Concordia University. Because of their brave action, all the dirty secrets inside the Tooniversity will be exposed. Please go to http://tooniversity.originalhamsters.com
to find more information and sign a petition to stop this madness.

This project was made at Concordia University for Vincent Leclerc’s Tangible Media and Physical Computing class. You can find technical details from my class website

Tags: , , , , , ,
Filed under: Electronics,Programming,Video — Posted by: Månsteri @ 1:16

November 16, 2008

Arduino & Quartz Composer

Here is a quick solution on how to get the analog inputs from an Arduino into Quartz Composer. For now, this only supports the analog values. Reading the digital input pins is not hard to implement, but I still haven’t decided what is the best way to do that.

Sending serial data from QC to Arduino is a little bit trickier, but I will definitely try to work on that also.

What do you need for this to work?

Tags: , ,
Filed under: Electronics,Programming,Tutorial — Posted by: Månsteri @ 23:08

July 5, 2008

SMS and Quartz Composer Revisited

Some people have probably tried to use my tutorial on how to use SMS text messages with Quartz Composer. There were actually some errors in the php code in my tutorial as the wordpress WYSIWYG editor is actually a IWFUYBPWC (I will f*ck up your blog post with code) editor so it might not have worked for you. It’s fixed now. Thanks to Amon Robe for pointing this out.

http://originalhamsters.com/blog/2008/05/06/using-sms-text-messages-with-quartz-composer/

Tags: ,
Filed under: Programming,Tutorial — Posted by: Månsteri @ 21:13

May 27, 2008

SMS continued…

Here is what I did during the Mobil/and workshop

http://originalhamsters.com/sms/

You can find more information about the workshop here: http://www.mobil-and.fr/

Tags: , , ,
Filed under: Programming — Posted by: Månsteri @ 22:18

May 6, 2008

Using SMS Text Messages with Quartz Composer

Next week, I will be taking part in the Mobil/And workshop in ESADSE in Saint-Etienne, France. I was planning content for my speak during the workshop and came up with a rather cheap and robust way of using SMS text messages in Quartz Composer.

Previously, I had been able to come up with a hack that involved BluePhoneElite, AppleScript and iTunes to send SMS to Quartz Composer. I used this for example in the FF>> Media Festival last fall, but it was really awkward solution and you could only have the information of the latest message. So, I had to think of some better way.

This time around, I’m using the excellent Cocoa UltraSMS to send my SMS messages to a MySQL database. Then I’m using a small php-script to convert the database into an XML file which can be easily read and manipulated in Quartz Composer. Here’s how you do it:

WHAT DO YOU NEED

  • Computer running Mac OSX (I’m on an early 2008 Macbook Pro)
  • Mobile phone with bluetooth (I’m using Nokia 6103)
  • Cocoa UltraSMS -software (it’s free)
  • Quartz Composer
  • Empty MySQL database
  • Some PHP skills

1st STEP – Create the Database

Ok, let’s start. First of all, you need to create an empty MySQL database. For the purpose of this tutorial, I’m going to call my database sms_database.

2nd STEP – Cocoa UltraSMS

Then you need to download and install Cocoa UltraSMS. Setup your phone to connect with it and also insert the information of your database to the fields. Your settings will be different, of course.

After you click OK Cocoa UltraSMS will ask you if you want to create tables for your database. Click OK and and after that hit Start to connect to your phone. Now you can test the connection by sending yourself an SMS. The SMS In counter should increase and if you have Growl enabled you should also see the message in the Growl window.

3rd STEP – PHP lovin’

Now we need to somehow convert the information in the database to an XML file. I’m really far from being a PHP expert, but even I was able to do this, so if you have even a little bit of experience in PHP this shouldn’t be too hard. I used this tutorial to help me.

Here is the PHP code that you will need to upload to your server in order to make this work.

EDIT: As it seems to be almost impossible to paste any working code on WordPress as the WYSIWYG editor f*#%s it all up, I’ve decided to upload the code as a separate file. Download the .txt file here, modify the database settings and rename it to whatevernameyoulike.php. (Can anyone point me to a WordPress plugin that disables all the “intelligent” modifications the editor makes? I’ve tried a few and none of them work perfectly.)

Just upload the .php file to your server and point our browser to the url. It will look something like this http://originalhamsters.com/sms/sms.php

You might have noticed the strange lines in the php code like this one

$row['message'] = str_replace("|", "ö", $row['message']);

I’m using those just to display the Scandinavian letters properly. This really can’t be the best solution to do that, but it works for now, unless you want to use smilies that is. I’ll have to see how and where I should change the encoding settings to get this display properly without this hack.

4th STEP – Quartz Composer

Now for the easy part. In QC you need to just connect the XML Downloader to a couple of Structure Index Member -patches, modify the XML location to be the URL of your .php file and you are all set. Download here a simple .qtz file that just displays the latest message.

5th STEP – What next?

Now it’s just a matter of what to do with the data you receive from the messages. I have a bunch of different applications in mind. You will probably hear from them pretty soon. I just got this thing working today, so I haven’t had the time to test all the possibilities.

Of course, this same technique can be used to access SMS data from various other applications that can read XML files like Flash, Processing etc. I just used Quartz Composer as an example because it’s the environment I’m most comfortable with.

That’s it. Hopefully this is helpful to someone. I’ve seen many interactive installations where SMS messages are used, but I haven’t seen good documentation on how to do it anywhere. Feel free to comment here or email me if you have any improvements or questions.

Tags: , ,
Filed under: Programming,Tutorial — Posted by: Månsteri @ 17:29

June 28, 2007

Interactive Propaganda Generator

Here’s some documentation of a project we finished this spring at the university. It’s a project for a course in interface design.

Our group (Aku Meriläinen, Danilo Mascarenhas, Marjukka Parkkinen and Matti Niinimäki) decided to create a multi-user interface that would allow a group of people to work together or compete in creating some sort of a moving collage. At some point in the planning process the idea of communism and propaganda came to surface, so we decided to go with that idea. We experimented with different input devices and visual styles, but eventually this is what came out of it.

I’d like you to meet The Interactive Propaganda Generator. It’s designed to have two different sides or “teams” – the communists and the capitalists – that you can control with different input devices to produce a collage of the two sides shooting different items and symbols at each other. The scene consists of three layers: a changeable background, two characters (one for each side) and the propaganda-tubes. Here are the controls explained:

Control 1 – ReacTIVision fiducial tracking

  • The characters are selected and moved around on the screen by using paper dolls on a glass table
  • You can change the bodies and heads of the characters.
  • Included are all your favourite capitalist and communist icons from Ronald McDonald to Che Guevara
  • The paper dolls have fiducial symbols attached to their backside and the camera under the table tracks the ID and the position of the symbol
  • Tracking is done with ReacTIVision software

Control 2 – PlayStation2 Dance Pad

  • You can move the capitalist propaganda-tube around the screen with the dance pad
  • One button turns the tube on/off
  • Two buttons for changing the ammunition of the tube (missiles, bibles, money)
  • Two buttons for changing the background image
  • One button for activating the speech option for the capitalist character

Control 3 – PlayStation2 Dual Shock Controller

  • Some controls as the dance pad, but for the communist side

Control 4 – Audio Input

  • A microphone picks up the voices of the users and when the speech option is activated (from the dance pad or dual shock controller) the characters on screen will open and close their mouths based on the sound input

Here’s the hardware setup. Click the image for details.
All programming done with Quartz Composer. I could release the .qtz file but it’s not really useful to anyone because it depends on a very specific setup. Email me if you’re interested in details.

And finally some video. Unfortunately, we don’t have any better footage of the system in action but hopefully you’ll get some idea.

Tags: , , , ,
Filed under: Programming,Video — Posted by: Månsteri @ 11:41

May 24, 2007

Phidgets Patches for Quartz Composer from fdiv.net

I wrote a tutorial a while ago for building a cocoa app that will enable you to control Quartz Composer with Phidgets sensors. Now there’s a LOT easier way to achieve this. Just use the new QC patches from fdiv.net.

Tags: , ,
Filed under: Stuff That I Like — Posted by: Månsteri @ 19:23

February 1, 2007

Phidgets + Quartz Composer

We’re going to use Phidgets for a university project pretty soon, so I tried to come up with a way to control Quartz Composer with the Phidget sensors. Hiroaki has done Accelerometer and RFID custom patches that you can find here, but I want to use the Interface Kit 8/8/8 and be able to use all the different sensors.

I’m not smart enough to program my own patches for QC, but I was able to build a Cocoa application that sends the data from the sensors to the QC composition. I got a little help from the Phidget Interface Kit -sample code that you can download here and from the instructions found from the Phidgets forum. The code on the forum post didn’t work for me so here’s a small tutorial that shows you how build a Cocoa app that will control your Quartz Composer composition with Phidgets sensors.

What do you need?

- A computer running Mac OSX 10.4 with the developer tools installed
- Phidgets Interface Kit 8/8/8 + some sensors
- Download and install the Mac OSX Framework 21 from Phidgets website. This will also include the source code that you need for this tutorial.


OK. Let’s start

1)
Open the CocoaIFKit Xcode project from the /Examples/Source Code/CocoaIFKit folder.

2)
First we need to modify the project so that we can import and use a Quartz Composer Composition. These next steps are explained with more detail in the Quartz Composer programming guide by Apple and I recommend that you try the tutorials first, but I’ll go through the important stuff quickly.

- First, choose Project > Add to Project.
- Navigate to System/Library/Frameworks/Quartz.framework and add it to the project.
- Drag the Quartz.Framework to your Frameworks folder in the Groups & Files list
- Double click the MainMenu.nib file and Interface Builder launches.
- If you haven’t done this before, you have to install the Quart Composer palette to Interface Builder. Choose Tools > Palettes > Palette Preferences and click add.
- Navigate to /Developer/Extras/Palettes/ and add QuartzComposer.palette.
- Now your palette window should show the Quartz Composer palette. The blue thing is QCView and the green thing is QCPatchController.

- Drag the QCPatchController from the Palette window to the Instances tab in the MainMenu.nib window
- Go to the Cocoa Windows tab in the Palette window and drag a window to the Instances tab also. A new window appears.
- Your MainMenu.nib window should look something like this

- Select the new window and go to Tools > Show Inspector. In the Attributes section, make sure that the “Visible at launch time” is checked for the new window
- Now drag a QCView from the palette to the new window and resize the QCView the way you like it.
- Select the QCView and then open the Bindings pane of the Inspector window. Click the small triangle where it says patch.
- Choose QCPatchController from the “Bind to” pop-up menu. Enter patch in the Controller Key text field.

3)
OK. Now we need a QC Composition to use with our app. I won’t go to any details about using Quartz Composer. There’s plenty of info for that available and this tutorial is already becoming too long.

What you need to do is to create any kind of composition that has a published input with the name of sensorZero. I just used an Image With String connected to a Sprite and published the String input with the name sensorZero. Save the .qtz file to the CocoaIFKit folder. I used the name phidgets.qtz.

Back in Xcode, drag phidgets.qtz to the Resources folder in the Groups & Files list. In Interface Builder, select the QCPatchCotroller from the MainMenu.nib window and select the Attributes pane of the Inspector and click “Load from Composition File…” Navigate to your phidgets.qtz file. Choose File > Test Interface. You should see your composition in the window. The sensors won’t work in the testing mode.

4)
Now the application shows our composition, but we want to change the published value with the sensors. Read on and I’ll tell you how to do just that.

- Select the blue PhidgetInterfaceKitController from the instances tab. Then select the classes tab.
- Choose Classes > Add Outlet to PhidgetInterfaceKitController.
- Name the new outlet theController
- In the Instances tab, ctrl-click and drag from the PhidgetInterfaceKitController to the QCPatchController

- Choose Connect to connect the outlet.
- Save and go to Xcode again.

5)
Now we need to change the code so that the data goes from the sensors to the QC composition

- Double-click the PhidgetInterfaceKitController.h file.
- Add this to the list of outlets:

IBOutlet id theController;

- Close the window and double-click the PhidgetInterfaceKitController.m file.
- Find the SensorChange section and add this code there:

// sensors to Quartz Composer
if(Index==0){
[theController setValue:[NSNumber numberWithInt:(int)Value] forKeyPath:@”patch.sensorZero.value”];
}else if(Index==1){
[theController setValue:[NSNumber numberWithInt:(int)Value] forKeyPath:@”patch.sensorOne.value”];
}else if(Index==2){
[theController setValue:[NSNumber numberWithInt:(int)Value] forKeyPath:@”patch.sensorTwo.value”];
}else if(Index==3){
[theController setValue:[NSNumber numberWithInt:(int)Value] forKeyPath:@”patch.sensorThree.value”];
}else if(Index==4){
[theController setValue:[NSNumber numberWithInt:(int)Value] forKeyPath:@”patch.sensorFour.value”];
}else if(Index==5){
[theController setValue:[NSNumber numberWithInt:(int)Value] forKeyPath:@”patch.sensorFive.value”];
}else if(Index==6){
[theController setValue:[NSNumber numberWithInt:(int)Value] forKeyPath:@”patch.sensorSix.value”];
}else if(Index==7){
[theController setValue:[NSNumber numberWithInt:(int)Value] forKeyPath:@”patch.sensorSeven.value”];
}

- We only published the sensorZero from QC, but this code works with all the 8 analog inputs in the Interface Kit (Index numbers 0-7). So you can publish more values from QC. Just name them correctly: sensorZero, sensorOne, sensorTwo…
- Note! I’m a total amateur when it comes to Cocoa, so this code might not be the best way to do this but it works.

6)
That’s it. Save. Then choose Build and Go to see if it works.

If you want to change the QC composition, you need to reload the composition to the QCPatchController in Interface Builder and rebuild the app.

Pheew! This is the first tutorial I’ve ever written. I hope it’s useful to someone.

Tags: , ,
Filed under: Electronics,Programming,Tutorial — Posted by: Månsteri @ 9:29

January 29, 2007

Koala 0.5.1

OK. I’ll have to think of something else than this blog for Koala. I’m coming up with small improvements and new versions all the time.

Here’s Koala 0.5.1

- Keyboard shortcuts for video triggering
- Changed the buttons for the effects
- Fixed a bug with the audio sensitivity. It used to default to zero, now the default value is 1

Download Koala 0.5.1

Tags: , , ,
Filed under: Programming,Video — Posted by: Månsteri @ 16:53