You are here

Quartz Composer: OS X's Hidden Gem

Apple Notes By Mark Wherry
Published April 2007

While Mac users continue to wait in anticipation for new Mac hardware and software, we explore a really neat application you might not realise you even own, which lets you create your own MIDI- and audio-based visual performances.

It feels like the calm before the storm in the Mac world. Compared to last year, when, thanks to Apple's transition to Intel processors, barely a month went by without some new Mac-related product revision or introduction, this year we have yet to see any new Mac product, whether hardware or software. (I should add a writer's most important caveat to this remark: 'at the time of writing', which is the end of February 2007, incidentally.)

Quartz Composer: make sure you have the right MIDI ports enabled to receive MIDI from the Settings page of the Inspector for the MIDI Controllers node.Quartz Composer: make sure you have the right MIDI ports enabled to receive MIDI from the Settings page of the Inspector for the MIDI Controllers node.

On the software front, of course, what we're all waiting for is Mac OS X Leopard (which could arrive as soon as the end of March, according to some rumour sites on the web). All versions of Mac OS X have brought about significant improvements for musicians and audio engineers, and with Leopard making it possible to run complete 64-bit applications, it's going to be really interesting to see what apps like Logic Pro do to take advantage of the 64-bit processors shipping in almost every Mac right now.

Speaking of processors, with Intel now shipping quad-core chips and web sites like Anandtech (www.anandtech.com) proving that it's possible to give Mac Pros an unofficial quad-core heart transplant (giving you eight cores in total), a Mac Pro revision must surely be on the horizon as well. Despite a slow start, I think that 2007 could start to get more interesting very soon.

A Stoned Composer

In previous Apple Notes columns, we've looked at both the treasure chest of tools Apple supplies as part of its developer software, included with every copy of Mac OS X, and the potential of graphics technologies for music and audio. This month, in the first of a two-part series, we're going to look at an application that falls into both categories: Quartz Composer.

Quartz is the name for OS X's graphics engine, which takes care of rendering 2D graphics on-screen and compositing together images from multiple graphical sources. Such a simple description belies the full power of Quartz, as we shall see. To allow developers to easily create Quartz compositions, to produce interesting visual effects in their applications, Apple introduced a developer tool called Quartz Composer with Mac OS X Tiger. If you're not sure what type of visual effects we're talking about, the RSS Visualiser screensaver included in Tiger is a good example of the kinds of graphics Quartz makes possible.

Quartz Composer is a node-based system that allows you to build various graphical compositions by dragging around nodes that generate, render or manipulate visual sources and specifying how they behave with each other by making connections between the nodes. If you've ever used a modular synth such as Native Instruments' Reaktor or dabbled in Logic 's Environment window, you'll instantly grasp how to work with Quartz Composer.

The really interesting thing about Quartz Composer from an electronic musician's perspective is that among the many control sources you can use to manipulate the images are various MIDI and audio tools. This means you can easily create custom visuals that respond to incoming MIDI and audio signals. These have several uses, such as adding performance graphics to make a live show more interesting. While Quartz Composer is pretty deep, we're going to look at a simple example this month to get you started, before getting a little more advanced next time.

Romancing The Stone

The first step is to run Quartz Composer, located in the Developer/Applications/Graphics Tools folder. If you can't find this folder, make sure you have the Developer tools that came with OS X installed, and also make sure you're running Tiger (10.4). When the application opens, it prompts you to create a 'new composition from template', which you don't want to do, so click Cancel instead. Now, either click on the Quartz Composer icon in the dock or select File / New to create a blank composition.

Assuming you made all the right connections, Quartz Composer's Viewer window should look like this when the modulation wheel is all the way down.Assuming you made all the right connections, Quartz Composer's Viewer window should look like this when the modulation wheel is all the way down.Quartz Composer features two main windows: the Editor, where you build your compositions, and the Viewer, where you can see what your composition looks like as you build it. The Editor window has two sections: on the right is a grid where you drag around and connect nodes, and on the left is a list of nodes you can create. You can search for nodes by typing in keywords in the search field above the list.

Type 'renderer' into the search field and double-click the Sprite Renderer to create this node in the Editor (you can also drag entries from the list into the editing area to create them as nodes). You'll notice that a large white square has appeared in the viewer: this is the output of the Sprite Renderer. Now let's create an image to put into the Sprite Renderer. Type 'halo' into the search field and create a Lenticular Halo Generator.

Each node can have two columns of properties: the left column of properties is inputs and the right column is outputs. Drag from the Image output of the Lenticular Halo to the Image input on the Sprite; a yellow connection should be made between the two nodes and the viewer should now display the halo effect.

You can inspect the settings for nodes in an additional pop-up window called the Inspector, which you can open by choosing Editor / Show Inspector or clicking the Inspector icon on the Editor's toolbar. The Inspector always shows settings for the selected node in the Editor (the selected node has a blue outline), and quite often there will be multiple pages for a node, which you can navigate with the left and right arrows and the pop-up menu at the top of the Inspector.

Look at the Input Parameters page in the Inspector for the Sprite node. Let's change the size settings, so that the Sprite fills the entire Viewer, by editing the Width and Height values to '2'. These values indicate multipliers of the original size, so '1' is the original size, '2' is double the original size, and '0.5' would be half of the original size. Values can be edited by clicking on the value, entering the new value and pressing return, or by dialling in the value using the knob control.

Jewel Of The Nile

Now we've got a basic image being displayed, let's add some simple MIDI control. Type MIDI into the search field and create a MIDI Controllers node. By default, the MIDI Controllers node shows only pitch-bend and modulation, but more MIDI controllers can be added via the Settings page in the Inspector. In this page we also need to set what MIDI ports we can receive controllers from, by making sure they're checked in the Observed MIDI Sources pop-up menu. Also, note the Observed MIDI Channels settings, which let you specify what MIDI channels to listen to (note that the grey colour of the buttons actually means enabled; white is disabled). All MIDI Channels are enabled by default.

<em>Quartz Composer</em>'s Editor window, showing the completed composition described in the main text.Quartz Composer's Editor window, showing the completed composition described in the main text.

Now, back in the Editor, make a connection between the Modulation Wheel output on the MIDI Controllers node and the Halo Radius on the Lenticular Halo node. Now move the modulation wheel on your external MIDI controller; what do you see? Nothing. Exactly. Open the Input Parameters page in the Inspector for the Lenticular Halo, move the mod wheel again and notice that (assuming your MIDI system is working and you enabled the correct ports for the MIDI Controllers node) the Halo Radius parameter is indeed changing. So why don't we see anything? One thing to remember is that Quartz Composer actually normalises incoming MIDI Controllers to a floating-point number between '0' and '1', where '1' would normally be 127 — the highest MIDI Controller value. We need to make sure the value we're controlling does something meaningful between '0' and '1'. You can't manually change a value in the Inspector if that value is being controlled by another source, as in the case of the Halo Radius value, which is being controlled by the mod wheel. So you need to simply break the connection by clicking on the Halo Radius Input on the Lenticular Halo node and dragging it away from the node. Now, back in the Inspector, manually change the Halo Radius value with the slider and you'll notice this value goes from zero to 1000 — so sending in a mod wheel value of zero to '1' was obviously quite ineffectual!

However, all is not lost. Type 'math' into the search field and create a Numeric Math node. Drag the Modulation Wheel output of the MIDI Controllers node to the Initial Value input on the Math node, and drag the Resulting Value output on the Math node to the Halo Radius input on the Lenticular Halo node. In the Inspector, select the Input Parameters page for the Math node and set Operation #1 to Multiply and Operand #1 to 100. This means that all incoming values will be multiplied by 100. Now when you move the mod wheel you should notice the Halo Radius visibly changing.

Unfortunately, that's all we've got time for! Next month, we'll start to look at animating our effect using audio, and adding some neat stuttering effects triggered by MIDI notes. 

A Parallel Fusion

In February's Apple Notes, we briefly revisited the Parallels Desktop virtualisation software for Mac-Intel users, which allows other operating systems to run at near-native speeds alongside Mac OS X. As a company, Parallels are fairly recent to the world of virtualisation, and while they achieved great success last year with their Mac version, many expected long-established competitor VMWare to release a Mac OS X version of their popular virtualisation software when Intel Macs first became available. VMWare now have a public beta of Fusion, a virtualisation application for the Mac, in full swing. You can download a copy from www.vmware.com/products/beta/fusion.

Fusion 's performance is currently deliberately crippled, to allow developers to debug the application, but already there's support for neat features like the ability to run a 64-bit operating system, which you can't yet do in Parallels Workstation. There's an interesting video on YouTube that shows an experimental version of Fusion with support for virtualised 3D graphics with hardware acceleration (which Parallels are also said to be working on), allowing you to run graphically intensive applications on your virtual machine.

Published April 2007