Pure Data (Pd) is already a free, convenient tool for making synths, effects, and sequencers and other musical generators. But imagine stripping away all the things that tie it to a platform – UI, specific hardware support – so it will run just about anywhere, on anything, in any context.

That’s what libpd, a free, embeddable, open source (BSD) tool for making interactive music, does. Coders can take their favorite language and their favorite platform, and just plug in the power of Pd. They don’t even have to know almost anything about Pd – they can let an intrepid Pd patcher create the interactive sound effects and dynamic music for their game and just drop a patch into their assets.

One of the most powerful applications for this is the ability to add interactive music and sound to mobile apps, on iOS and Android, without writing and testing a bunch of custom DSP code. And that has enabled the use of libpd in apps as successful as Inception: The App. With music by Hans Zimmer and a custom “dream” experience created by RjDj, that app racked up millions of downloads in under a couple of months, and then, far from sitting idle on the app launch screen, went on to clock in over a century of user “dreamtime.”

Okay, so, you’re sold. You want to see what this thing can do, and maybe try it out, and you’re wondering where to start. So, here’s some good news: there’s a new site and a new book to get you going.

The site: libpd.cc

libpd has a new home on the Web, both in the form of a new GitHub repository to organize all the code and docs and samples, and a site that brings together a showcase of what the apps does and points you to where to learn more. The single destination is now hosted here by CDM:


I built that site, so please, if there’s anything you’d like to see or you’ve got your own work created with libpd, let me know about it.

Even just having selected a few key highlights of apps built with libpd, it’s impressive what people are already doing with this tool:

libpd Showcase

The book, and a chat with its author

A new book published by O’Reilly focuses on building mobile apps using libpd, for iOS and Android. (iPhone, iPod touch, Android phones and tablets, and yes, even that “new iPad” introduced yesterday are therefore all fair game.)

You can read a section of the book right here on CDM, for a taste of what’s in store:
How to Make a Music App for iOS, Free, with libpd: Exclusive Book Excerpt

It’s an exceptional, comprehensive look at development using libpd, covering iOS and Android, but also a complete look at the libpd API and how to use it. For Pd patchers just getting started with iOS and Android, it includes all of the basics of how to use libpd in your mobile development environment. For mobile developers new to Pd and patching, it makes clear how you’d communicate with Pd, so you can either dive into Pd yourself or properly interface with patches made by musicians, composers, and sound designers with whom you may be collaborating. It’s an ideal title for anyone interested in taking a game and giving it a more dynamic soundtrack – in sound effects, music or both – or for people building mobile musical instruments and effects, sonic toys, interactive albums, or, really, anything at all that involves sound or music. Since it walks you through the entire development experience, you can sit down with it in the course of a few evenings, and get a complete picture of how to integrate Pd with your development workflow.

Dr. Peter Brinkmann, the principal developer of libpd, is the author of the title. I asked Peter to explain a little bit about the book, who it’s for (hint: you!), and what’s in it (hint: stuff you want to read!) …

CDM: How did this book come about? And the book process really helped drive improvements to libpd, too?

Peter B.: Shawn Wallace, an editor at O’Reilly, contacted me last summer and asked whether I would be interested in writing a short book on libpd. I was interested, and so I talked to my [Google] manager (“No conflict — we all have time-consuming hobbies!”) as well as a couple of colleagues who had written books for O’Reilly. They made a token attempt to dissuade me, but it was clear that they had enjoyed writing their books, and they seemed quite proud of the result, too.

Once I had made up my mind to write a book, the next question was whether to self-publish or go with O’Reilly. Self-publishing is a viable option these days, but then I decided that I really wanted an animal on the cover. Besides, I had never written a book before, and having the support of O’Reilly’s editorial staff made the prospect seem less daunting.

The first draft was done in mid-November, but at that time it was basically science fiction because it presented libpd the way I wanted it to be, not the way it was at the time.

So, after the bulk of the writing was done, libpd needed to be revised so that it would actually be in agreement with the book. In particular, Rich Eakin and I rewrote the iOS components for better performance and usability. That delayed the book by a month or so, which turned out to be a great stroke of luck because that was when I discovered that Xcode 4.2 had changed the entire development model by introducing automatic reference counting, instantly rendering existing
texts obsolete. That included my chapter on iOS, and so I had to sit down and rewrite it.

After that, the rest happened rather quickly — getting reviews, revising the draft, going through the production process. O’Reilly’s toolchain is remarkably efficient, using asciidoc and docbook in a Subversion repository. The editorial staff is great, too. I’m amazed to see how quickly it all came together.

How did you approach writing the book?

For the first draft, I just imagined that I was teaching a class on libpd. When you’re lecturing in front of an audience, you don’t have time to polish every sentence; you just have to talk and maintain some sense of momentum. That approach helps a lot when facing a blank page. After that, it’s many, many rounds of revisions to eliminate weak or redundant sentences.

For the sample code, I picked one project that uses all major components of libpd. That provided a natural progression from idea to completion, while touching on all important points in their proper context. I’m basically providing running commentary on my thought process when making an app, including common mistakes and pitfalls. Like this, readers will know how to recognize and work around most problems.

Another trick is to write more than necessary. The first draft contained a lot of gratuitous editorializing. Those parts were never meant to make it into the finished text, but they were fun to write and they kept me going when I wasn’t quite sure what to write next.

Who it’s for?

The book explains how to patch for libpd, and how to write apps with libpd, with special emphasis on the interface between Pd patches and application code. It’s for mobile developers who want to add real-time audio synthesis to their projects, as well as sound designers who want to deploy their work on mobile devices. It’s light on prerequisites; if you know how to write a basic app for Android or iOS, you’re ready to read the book.

Ed.: I’d add to that, given that there are such great tutorials on app development for Android and iOS – even many of them free, including some very worthwhile documentation from Google and Apple — if you’ve messed with Pd, you should give the book a try. And if you haven’t messed with Pd, this could be a great excuse. This book won’t teach you Pd, but it’ll make very clear how to glue everything together. -PK

Why does a book like this matter? What do you hope will come out of it?

I hope that the book will help popularize real-time procedural audio, in games and other apps. I’m thrilled to see all the projects that use libpd, and I hope that the book will help people create even more awesomeness of this kind. One thing I only fully realized when writing the book is that libpd lets developers use DSP code like a media file: An audio developer creates a Pd patch, and the app developer just drops it into the resources of the app and loads and
triggers it as needed. I guess this was implicit in a blog post I wrote on workflow and prototyping a year ago, but I think the DSP-as-media angle is even more powerful. I hope that the book will bring this out.

The book project has already improved libpd. Whenever I faced the choice between fixing an awkward bit of code or explaining the awkwardness in the book, I chose to fix the code. That took care of all the little things that were sort of bothering me but didn’t seem significant enough to spend time on. It also gave us a deadline for a number of related things that we wanted to do, such as migrating to GitHub and launching the new website, libpd.cc. Ed.: Cough. Yes, glad that gave me that deadline – and thanks to Peter B. for the extra push! -PK

Congrats to Peter on his first animal-on-a-cover! It’s really a great book: you read it, and feel like making more new things, inventing new creations that produce sound and music. And that’s a very good thing.