Preface - Programming for Musicians and Digital Artists: Creating music with ChucK (2015)

Programming for Musicians and Digital Artists: Creating music with ChucK (2015)

Preface

Welcome to ChucK!!

We tend to do our best work when we follow our true interests. ChucK was created because we genuinely love both music and programming—and for anyone who wants to make music with computers (or learn to do so). As the creator and chief designer of ChucK, I earnestly believe that programming is (or should be) a creative endeavor in and of itself. It should be fun, expressive, rewarding. And to create music through programming, well, that is doubly awesome.

I started working on ChucK in 2002, having started in the Computer Science PhD. program at Princeton University a year earlier. If rock music was my gateway-drug into music-making (and my undergrad alma mater Duke University my passage to programming) then Princeton was where I started putting these elements together. Although I couldn’t quite articulate it at the time, I was drawn to the elegance of certain features in programming languages, and aspired to create things, programmable software things, that empower people to make music, but in a way that was aesthetically nuanced and fun. I wanted to rock, and help others rock—with the computer.

Perry R. Cook was my adviser (one of the best things professionally and personally to happen to me); his work on physical interaction design and his Synthesis ToolKit (STK) were great inspiration. Also, Perry’s fun, whimsical, and imaginative personality helped set the tone and encouraged freedom in exploration. I still remember showing Perry the initial ideas for “a new programming language for music” glued together by the ChucK operator (which looks like =>, something you will see a lot in this book), and Perry saying, “Well that’s pretty insane. Go for it!”

Fact

Portions of my initial scribbling remained on Perry’s office whiteboard for the next five years, though I later discovered that it was due to a malfunction with the board that made it nearly impossible to erase.

Soon thereafter, and somewhat serendipitously, I designed the time and concurrency mechanisms (both intrinsic to how ChucK works) into the fledgling language. I say serendipitously because both components began as casual mind-wandering, but once I worked out how these mechanisms might function together, it resonated so deeply with my warped mind that I had to see it through. And thus began a journey to make ChucK that, surprisingly to me, remains stronger-than-ever over a decade later, and that has involved some of the craziest and most wonderful collaborators I have ever known.

Ajay Kapur was a crazy and most industrious undergrad in Perry’s lab, building the eTabla, eSitar, eDholak (a two-person Indian drum), who would go on to create entire orchestras of robotic machines. Wonderfully supportive of ChucK since the very beginning, Ajay pioneered new ways to teach computer music and interaction design with ChucK. Currently he teaches at CalArts and is the (and still crazy) associate dean of music technology there.

One day in 2004, a Princeton undergraduate student by the name of Spencer Salazar emailed me, confessed that he enjoys programming and building things, and asked if he could help with the ChucK project. Answering “yup” changed ChucK forever, for Spencer turned out to be a monster coder and a most thoughtful innovator. In addition to adding support for joysticks, mice, keyboards, WiiMotes (via the HID interfaces, covered in chapter 10), Spencer authored the miniAudicle, the ChucK development environment used in this book. And all that was in the first year! Serial support, ChuGins, Chugens, and Chubgraphs are among his recent additions (covered in appendix H). Spencer is now pursuing a PhD. at Stanford University’s CCRMA.

Fact

Spencer and I are avid StarCraft fans, and semi-regularly get owned online by players who possess actual skill. Ajay once played StarCraft for 8 hours straight on a road trip to Montreal, and has never played since (that I know of). Perry, to my knowledge, has never touched the game.

By this point, you are probably getting a sense of the type of crazy (and actually pretty laid-back) folks who labored to make ChucK happen. The list doesn’t stop there. Philip Davidson and Ari Lazier both contributed large chunks of ChucK; Phil and I even built a prototype for a real-time animated development environment called the Audicle (a rough predecessor to the miniAudicle). Ananya Misra and Matt Hoffman pitched in generously and threw down large servings of new functionality, while elsewhere Adam Tindale wrote a ChucK manual. Meanwhile, sage individuals like Paul Lansky, Roger Dannenberg, Andrew Appel, and Brian Kernighan (all programming language creators themselves) generously dispensed wisdom on the direction of ChucK.

The online ChucK community formed between 2003 and 2004, and we started to rapidly release bug fixes and new features (and new bugs). It was magical how folks we have never met stepped up to generously contribute to an open source project and community such as this. One particularly notable individual is Kassen Oud, who has shepherded countless new users, answered endless questions, and generally distributed peace and good will to all ChucK users for more than 10 years. (Kassen is credited on the ChucK website as Sporksperson, Forum Moderator, and ChucKian Sherpa.) I have never met Kassen face-to-face, though I sense a kindred spirit out there!

There is a rule of software development from The Mythical Man-Month (a great treatise on how humans create software) that says: plan to throw one away. The idea is that when building something new, the first implementation is often not architected suitably. One should not fear starting over, armed with the knowledge gained from the initial endeavor (this is actually a pretty good rule for many things in life). In 2005, I completely overhauled ChucK’s core to support arrays and objects, and made it easier to add a bazillion other features. This turned out to be a good move, for the (totally insane) Princeton Laptop Orchestra (PLOrk) started that fall, led by the magnificent Dan Trueman and Perry, with Scott Smallwood and myself as teaching assistants. ChucK was to be used as a primary programming and teaching tool.

This was another transformative moment, for it was the first time we taught ChucK in a formal classroom setting, for a full semester, to 15 college freshmen with no previous programming experience. It also happened to be the first time anybody has ever taught a laptop orchestra, so we literally had to make it up as we went along. It was delightfully harrowing and exhilarating because we were neither guided nor bounded by established rules. The course turned out to be a resounding success, ChucK was battle-tested like never before, and we knew we could teach ChucK to pretty much anyone who has the heart and interest to learn.

Awesome things continued to happen, for Rebecca Fiebrink arrived in 2006 to begin her PhD. and I found a most dear and amazing collaborator. During the one year we overlapped at Princeton (before I left to teach at Stanford University), Rebecca and I accomplished a rather insane amount of new ChucK-related things, including the Small Musically Expressive Laptop Toolkit (ChucK SMELT), as well as the architecture for Unit Analyzers in ChucK. Through all of this, I can say that cool things happen because (and really only because) of great people involved, and ChucK definitely embodies the personalities of the folks who make it.

In 2007 (and while still working on my PhD. dissertation on ChucK) I joined the faculty at Stanford University’s Center for Computer Research in Music and Acoustics (CCRMA, pronounced “karma”). CCRMA Director Chris Chafe (another kindred spirit) was already teaching ChucK in his courses, and I started to do the same in the all-new Stanford Laptop Orchestra (SLOrk), complete with speakers arrays fashioned out of IKEA salad bowls. (Presently, with Spencer and me both at CCRMA, it is the central hub of ChucK research and development.)

As if things weren’t crazy enough already, I cofounded a startup in 2008 called Smule, aimed to bring computer-mediated music-making to a wide audience on mobile devices, and in synergy with academic computer music research. Spencer was a founding developer and Perry a founding adviser. ChucK became our rapid prototyping platform and part of the core audio engine. I designed Ocarina, an app that transformed the iPhone into an expressive flute-like instrument, and even allowed users to listen in on each other around the world, and used ChucK as the audio and interaction engine. To date, ChucK is on more than 10 million iPhones via the Ocarina and Ocarina 2 apps for iPhone.

Meanwhile, more and more people in and beyond academic institutions are programming with ChucK. For example, Ajay has fashioned an entire curriculum at CalArts to teach music technology with ChucK (audio programming), processing (visual programming), and Arduino (microcontroller). Through a NSF-funded initiative, Ajay and Perry set out to create a ChucK-based curriculum aimed at digital art students. They got the proverbial band back together to write this book.

Why we use Chuck

As devoted users of ChucK, we each have own reasons for using it. Perry loves ChucK because he needs to program often to keep his sanity, and ChucK is “the only language that lets me drop in for a few seconds, or as long as I like, and get something gratifying done. If I have an idea, I can try it out immediately in ChucK.”

Spencer likes ChucK because it allows him to clearly and concisely express complex and nuanced aesthetic ideas in code. “Moreso than any other tool, ChucK gives me both the ability to control computational processes and the means to synthesize them satisfyingly.”

As a robotic artist, Ajay works with MIDI from custom-built controllers and for custom built robotic instruments. “The power of ChucK has been the multithreading and how I can have multiple processes running sensor data, actuator control and composition processes all at different rates! This is why I use the language in teaching computer science to artists... showing them a language paradigm of the future...”

We asked a few other people why they use ChucK, and here is what they had to say:

[ChucK] suggests a mindset in approaching music, and the design of music, the experimentation with music, and the learning of coding. [...] I like the way that ChucK makes me think, and I was really depressed about music programming before I found ChucK.

Rebecca Fiebrink Lecturer in Graphics and Interaction Department of Computing Goldsmiths, University of London

With ChucK, I can easily think about the flow of time and how I might combine multiple musical layers simultaneously. It is the only language I know that is inherently contrapuntal, and it is by nature extraordinarily musical (and fun) to code with.

Dan Trueman Professor of Music, Princeton University

[...] when everything worked the way it was supposed to, when my spontaneous arrangement of computer lingo transformed into a musical composition, it was a truly amazing experience. The ability to control duration and pitch with loops, integers, and frequency notation sent me on a serious power trip. (On learning to program with ChucK)

Anna Wittstruck Princeton University, class of 2008

And so now here we are—and here you are—with a book on ChucK. But really it’s a book about learning to get the computer to help you express yourself, sonically, interactively, and musically. To this end, I will leave you with a bit of advice on learning ChucK.

· Don’t panic. When things don’t work as you expect, don’t be discouraged. ChucK is a language for experimenting with sounds, music, and interactions, and even the most seasoned programmer will make mistakes and introduce bugs in their code. Don’t think too much about the fact you are programming, and let your logic, curiosity, and creative vision drive you.

· Stick with it. It doesn’t matter what your experience with programming is (even if it’s zero; even if you think it’s less than zero)—as long as you have interest, then you can learn to ChucK. Also, coding to make sound is one of the best and fastest ways to learn programming; for one, you can immediately hear the results of your actions.

· Do the suggested exercises and examples found throughout the book and don’t be afraid to experiment. You might start by tweaking the numbers in related sample programs and listening to the result, and as you start to grok how the code works, incorporate your own logic and imagination into the code, or incorporate it into your own creations.

· Listen. It’s all about making sound, so use your ear and use it often!

In closing, I feel a combination of happiness (that people are using ChucK to be creative, expressive, and making music) and perpetual dread/consternation (I know where all the “potholes” are in the implementation). That adds up to a great deal of gratitude to everyone who has bravely programmed a line of ChucK, who has created a new sound, interaction, or a new piece of music, and to anyone who wants to learn.

So as we like to say in ChucK land (where you now find yourself): the time is now. There is no better time than the present. Have fun and make whimsical, wonderful music!