Cocoa & ObjC

Aug 11 00:35

looping via NSThread vs NSTimer

There are many posts out there on the internet discussing the pros and cons of running an update loop on iPhone (or on desktop for that matter) via an NSTimer vs NSThread, and many suggest they can squeeze an extra 3-5fps out of using an NSThread. So after this discussion on the openFrameworks forum, and with help from Robert Carlsen, I added this feature as an option to ofxiPhone. By default the update loop is still triggered from an NSTimer for backwards compatibility (and safety), but if in your testApp::setup() you call iPhoneEnableLoopInThread(), then the loop will be initialized to run in a separate NSThread and throttled by mach_absolute_time(). It is very much in its infancy (uploading to SVN as I type) but seems to do the job (obviously you'll need to write threadsafe code if you use it).

May 12 14:10

MSA Remote for iPhone

Controlling VDMX + Ableton Live
Controlling Java / fluid simulation with TUIO
Controlling custom multitouch paint application with TUIO

MSA Remote is a remote control application for iPhone & iPod Touch that sends OSC messages over the wifi network. This allows you to control any OSC supporting applications such as Max/MSP/Jitter, PureData, Reaktor, VDMX, vvvv, Resolume, Quartz Composer etc. as well as any custom applications such as interactive installations, audio/visual performances, multitouch capable surfaces etc.

By mapping the OSC to midi on desktop (e.g. using OSCulator) allows further control of any application which supports midi such as Ableton Live, Cubase, Logic Pro, 3DSMax etc. In addition, developers can easily integrate OSC into their applications knowing it can be controlled remotely.

The application can be distributed to visitors, guests, members of the public etc. to interact with an installation or performance, or used by dedicated performers.

Available on the iPhone App Store

Get it from the iTunes App Store here.




- Multitouch information sent using standard TUIO protocol for instant integration with existing TUIO clients
- Accelerometer data for each axis (x, y, z) is sent
- 64 faders (8 pages of 8 faders)
- 64 triggers (8 pages of 8 triggers)
- 108 key (9 octaves) VELOCITY SENSITIVE polyphonic keyboard. Yes, the harder you hit the keys, the greater the velocity.
- Settings are automatically saved and restored
- Multitouch area orientation can be set as desired
- All information on protocols are documented in the app

Controlling VDMX & Ableton Live simultaneously

In this video, OSCulator is routing the OSC (& TUIO) messages coming from MSA Remote to midi and forwarding to Ableton Live (for audio) and VDMX (for visuals) simultaneously. Nothing is done in post, the same signal is controlling both audio and video. Video demonstrates faders, triggers, and velocity sensitive keys - yes velocity sensitive. The harder you hit the keys, the louder the sound (or whatever you want to map it to).

Controlling Java/ fluid simulation with TUIO

Source code for the sketch can be found here:

Controlling custom multitouch paint application with TUIO

Graffiti Wall is a product that Tangible Interaction had already developed a while ago and have been using commercially. It was built on TUIO from the beginning, so when I passed on a copy of MSA Remote (via ad-hoc), they were able to immediately integrate it with their app without any modifications.

Graffiti Wall meets MSA Remote from Alex Beim on Vimeo.

OSCulator (osc->midi)

Camille Troillard, the mastermind behind OSCulator was kind enough to add some features (and sample patches) to his app to make handling the data coming from MSA Remote and converting to midi as seamless as possible.

  • The /msaremote/fader protocol is recognized and faders are automatically setup to forward to midiCC with same number as the slider.
  • The /msaremote/trigger protocol is recognized and triggers are automatically setup to forward to midi notes with constant velocity.
  • The /msaremote/bank protocol is recognized and triggers are automatically setup to forward to midi notes with constant velocity.
  • In the Osculator/Sample Patches/iPhone folder there are two sample patches which map incoming msaremote keyboard OSC messages to midi notes with velocity. The basic patch maps each key to the relevant midi note, while the advanced patch has the keys setup so you can assign each key to a different event.


Blair Neal aka has created a Max MSP template (for Max5) to handle the OSC Messages coming from MSA Remote. Cheers Blair!

Download it here

MSA remote max template

Mar 29 11:31

Simple openFrameworks application on iPhone Sample 1

This is a tutorial in getting a very simple openFrameworks application running on iPhone with basic graphics, multitouch and accelerometer support (and one might say a simple particle system too!).

  • 10 Balls are moving around on screen and bouncing off the edges.
  • You can touch the screen with multiple fingers and drag the balls around (multitouch support)
  • You can tilt the iphone and the balls fall in that direction (accelerometer support).

...and all of this without touching a line of Objective C. It is actually one of the samples included in the ofxiPhone download - iPhone Touch+Accel Example. You can find it in the examples folder of the download, so if you load and run that project you can see the finished result. The code below is straight from that sample, warts and all :P

Mar 27 09:01

Developing for iPhone using openFrameworks and ofxiPhone

Note: Everytime I mention iPhone, I am in fact referring to iPhone & iPod Touch running OS 2+.

Update 29/03/2009

Just posted a simple example application source code and walk-through which can be found here.


Update 27/03/2009

openFrameworks 006 is now officially released! You can download a fat package for your system from, mac/linux/windows and now iPhone. I do recommend you keep an eye on the ofxiPhone SVN for updates and fixes.


What is this and what does it do?

ofxiPhone (along with ofxMultitouch & ofxAccelerometer) are addons for openFrameworks 006+ that allow you to develop for iPhone in plain old C/C++ just as you would on a normal desktop (mac, linux, windows). This means using the normal testApp.h, testApp.cpp, main.cpp; setup(), update(), draw(), mousePressed(), ofImage, ofTexture etc. and any other C++ classes you may have created. It also means that you can reuse your exact same code running on your desktop (mac osx, windows, linux) unchanged on the iPhone by just copying across your testApp.h, testApp.cpp, main.cpp and other source or resource files you may be using.

Feb 21 01:58

Meshmerizer for iPhone


An interactive, generative, audio-reactive visualization app for the iPhone and iPod Touch (what a mouthful!) (This is the continuation of what I originally called "The Meshulator").

Use your fingers to create and interact with abstract geometry in 2D or 3D. Very simple to use, just slide your fingers over the screen and try different gestures. Tilt the device to look at the shape from different angles. Options for two different kinds of audio-reactive behaviour (microphone input - iPhone only): deforming based on audio, or completely generative driven by audio. If you feel adventurous, you can play with plenty of customizable parameters to adjust coloring, physics, shape etc. Or if that feels too intimidating just click 'randomize' to make the settings random and experiment.

It was written with a custom version of openFrameworks (pre-006) and an early version of the ofxiPhone addon. Information on openFrameworks and ofxiPhone at

Available on the iPhone App Store

Get it from the iTunes App Store here.


Meshmerizer 25Meshmerizer 27Meshmerizer 31Meshmerizer 07Meshmerizer 02Meshmerizer 18Meshmerizer 01Meshmerizer 06Meshmerizer 04Meshmerizer 03Meshmerizer 19Meshmerizer 11Meshmerizer 20Meshmerizer 21Meshmerizer 22Meshmerizer 23Meshmerizer 15Meshmerizer 29

(video is of an early version missing some features)

Made with openFrameworks.

Feb 10 01:07

"Jackson Pollock by Miltos Manetas" for iPhone - 4/5 stars."You will find yourself showing people this application …and then, not getting your iPhone back because they want to keep painting." - "I like the fact that the app is not just a port of the website, but includes enhancements which take advantage of the features of the iPhone." - "...the most jollificating paint app for iPhone and iPod Touch. It’s like getting a Jackson Pollock soul inside you...Definitely worth having it on your phone for. Well worth $0.99"

iPhone adaptation of Miltos Manetas' website (original flash developed by Stamen Design). Save your pictures and send them to, the best Pollocks will be published in an upcoming book.

The video below shows the basic features of v1.0. In the current version (v1.1) ability to choose your own colors has been added to allow the creation of more controlled paintings like those seen in the images below.

Available on the iPhone App Store

Get it from the iTunes App Store here.

Quick paintings created with "Jackson Pollock by Miltos Manetas" for iPhone:
'Sun in the sky behind apple tree' by Memo'Black Swan' by Memo'Still Life Studies - bunch of fruit on table' by Memo'Blood' by Memo'Color on Black' by Memo'Good Times' by Jane'Amore 2' by Memo

Made with openFrameworks.

Feb 09 01:51

Gold Dust for iPhone

Version 1.1 is now in the appStore. New version brings serious optimizations thus max amount of dust is now tripled.

This is a port of my original gold dust app ( to iPhone. Of course it doesn't translate exactly but this is my first attempt to capture the essence of the original demo. Unfortunately I don't think this video manages to capture the behavior of the glittery gold dust either, but it's free so you can try it for yourself :P.

It was written with a custom version of openFrameworks (pre-006) and an early version of the ofxiPhone addon. Information on openFrameworks and ofxiPhone at

Available on the iPhone App Store

Get it from the iTunes App Store here.

Made with openFrameworks.

Feb 05 15:36

NSArray vs. C Array performance comparison Part II - makeObjectsPerformSelector


In Part I, I compared the random access performance of a C float* to an NSMutableArray of NSNumbers, and on average the float* performed more than 400 times faster than the NSMutableArray. While those figures are accurate, they don't represent the optimal way of using NSArrays. NSNumbers can also be slow and there are faster linear enumeration methods than objectAtIndex. So I thought I'd modify the example using custom objects and sending messages to all objects, using floats in both cases. Note: these tests are conducted on an iPhone 3G as that's the target platform I was interested in.

Feb 05 14:57

NSArray vs. C Array performance comparison


The classes provided by Cocoa for handling data sets (NSDictionary, NSArray, NSSet etc.) provide a very nice interface for managing information, without having to worry about the bureaucracy of memory management, reallocation etc. Of course this does come at a cost though. I think it's pretty obvious that say using an NSArray of NSNumbers is going to be slower than a C Array of floats for simple iterations, so I decided to do some tests, and the results were pretty shocking! I wasn't expecting it to be this bad. Note: these tests are conducted on an iPhone 3G as that's the target platform I was interested in.

Jan 26 01:28

The Meshulator on iPhone, Take 1

Early tests of Meshmerizer for iPhone

Screengrabs can be seen at
(they look so much more aliased than they do on the iPhone screen, I should do some FSAA)

Meshulator iPhone  - 01Meshulator iPhone  - 02Meshulator iPhone  - 03Meshulator iPhone  - 04Meshulator iPhone  - 05Meshulator iPhone  - 06Meshulator iPhone  - 07Meshulator iPhone  - 08Meshulator iPhone  - 09Meshulator iPhone  - 10Meshulator iPhone  - 11Meshulator iPhone  - 12Meshulator iPhone  - 13Meshulator iPhone  - 14

Made with openFrameworks.

Jan 12 14:34

Memory Management with Objective C / Cocoa / iPhone

Now that the iPhone SDK is out, iPhone/iPod Touch has sold millions and the App Store is pretty popular, there are many people taking to iPhone and Cocoa Touch development. While the SDK is very well designed and pretty quick to get into, the biggest hurdle is usually the unique language that Apple (and previously NextStep) chose for its development on OSX and iPhone: Objective C. At first glance it looks hideous and unlike anything most people using C based syntax are used to (C, C++, ActionScript, JavaScript, Java, C#, GLSL etc.). But once you get your head around it, you really come to love it and understand why this choice was made.

One of the biggest obstacles most people have to get their head around when they first start Objective C / Cocoa development is the memory management - and it's actually very beautiful when it finally dawns on you how simple it really is (though this may take a couple of proper projects!). In fact, I found it so useful, I wrote a little class for C++ for similar functionality (


Oct 27 02:13

MSA QT Player - Fullscreen Quicktime player across multiple video-outs


** Update 27/10/08 - Version 1.1 **

Added loop mode configurable from the preferences.plist


MSAQTPlayer is a Mega Super Awesome (& mega super basic), fullscreen / multiple output Quicktime player with fast, greater-than-4096-pixels support.

I wrote this app for an installation because I needed to play a 4,800 x 600 Quicktime file across 2 outputs on my graphics card, each feeding 3 triple heads to go into 6 projectors, and I couldn't find a single application that could do it.

Most video applications which can output across multiple video-outs cannot play files larger than the maximum size of a texture (usually 4096 pixels). And even if the movie resolution fits in a texture, they are very slow because they convert each frame to a texture and upload to the graphics card. The only application I found which could play a large file is Quicktime Pro, but that cannot output across multiple video-outs.

MSA QTPlayer is a native Cocoa app which can do this (using QTKit and OSX 10.5) .

Apr 18 12:35

WiiToMidi Mac OSX Midi Driver (wii2midi)


WiiToMidi (wii2midi) is an open-source Mac OSX driver to convert Wiimote and Nunchuk (Niintendo Wii motion based controllers) data to midi. Its a Cocoa application based on the DarwiinRemote WiiRemote framework. Mike Verdone wrote the main app transmitting the values and button presses as midi. I added the modules to calculate and transmit an additional 16 midi cc messages. These are for calculating/transmitting the velocity, position offset and orientation for both the wiimote and nunchuk.