Vol. 38 Issue 2 Reviews
Eric Lyon: Designing Audio Objects for Max/MSP and Pd

Softcover, 2012, ISBN 978-0-89579-715-5, 340 pages, illustrated, index, bibliography, CD-ROM, forward by David Zicarelli, afterword by Miller Puckette; available from A-R Editions, Inc., 8551 Research Way, Middleton, Wisconsin 53562, USA; telephone (608) 836-9000; electronic mail info@areditions.com; http://www.areditions.com/.

Reviewed by Robert S. Thompson
Atlanta, Georgia, USA

Lyon Book CoverEric Lyon’s Designing Audio Objects for Max/MSP and Pd is a superbly executed addition to the growing body of texts concerning sophisticated computer programming techniques for electronic musicians. The text explores techniques for the creation of audio objects (externals) in the C programming language for the data flow programs Max/MSP and Pure Data (Pd). External audio objects provide a means to enhance and extend the options provided by the core libraries of Max/MSP and Pd. Learning how to create and utilize them empowers the reach of the electronic musician, opening-up numerous creative possibilities. Creating one’s own custom audio objects provides the musician with the opportunity to devote programming time only to the task that is of immediate interest, such as designing a specialized audio processing tool like a flanger, without having to be overly concerned with the details of the programming environment within which it is operating.

The basic attraction of working with audio objects lies in the fact that these modular pieces of code can be loaded upon demand into the host program. Once the basic functioning of the DSP process is implemented, the user can interact with the new audio object in a variety of ways, and place it within the context of other objects. Furthermore, these objects can make use of all of the audio capabilities of the host program. Creating specific audio objects for signal processing tasks is often less cumbersome and more efficient than using a sub-patch, abstraction, or a collection of native objects to do the same thing. There is compactness and elegance in the use of such purpose-built externals, and over time the dedicated composer can develop and refine a collection of tools that personalize not only working methods but also the available sound palette for creative composing. Utilizing the comprehensive framework of Max and Pd the programmer can focus on the problem at hand, the algorithm itself, rather than the details that would allow the algorithm to work in real time. Audio plug-ins typically require some sort of specific interface, or a runtime environment would have to be created, in order to utilize them. However, the context for programming audio objects in Max and Pd avoids this requirement and is therefore much more inviting for the electronic musician. The open-ended, modular nature of Max and Pd allows for user-designed audio objects to function in many different ways and in imaginative combinations.

Max/MSP and Pure Data are established standards in the electronic music field, and both their utility and user base continues to grow impressively. The integration of Max/MSP into Ableton Live and the encapsulation of programs such as Csound, and RTCmix into Max and Pd are indications of the broadening appeal of these tools for electronic musicians working in numerous musical genres. Due to this expanding interest there are a number of good texts appearing that deal with the issues of sound design, synthesis techniques, and musical signal processing options provided by the programs. However, there is a need for a text that deals explicitly with the creation of external audio objects, their design, programming, debugging and integration, and the C programming and DSP skills required. Lyon’s book admirably fills this void and presents a highly cogent discussion of the various factors involved.

Presently, there are hundreds of audio objects for Max. Programmers outside of the primary development community are increasingly creating these objects. In a sense, Lyon’s book is written for these kinds of programmers - serious electronic musicians who want to expand the utility of Max/MSP and Pd in creative and idiosyncratic ways. One worthwhile side benefit of following through the projects in Designing Audio Objects is that one will gain a large amount of knowledge about digital signal processing, together with some excellent coding tips from a veteran computer music programmer.

The preface outlines the text’s philosophical approach and what readers need to know as they begin their journey. Lyon suggests that a basic acquaintance with the C programming language is all that is needed, and indeed his code examples and accompanying text are so clear that programmers will be coding right out of the gate, but serious students of the subject will be compelled to delve much deeper. Good companion texts include the C Primer Plus by Stephen Prata and the recent Designing Audio Effect Plug-Ins in C++ by Will Pirkle, in addition to those suggested by Lyon.

The book begins with a welcoming discussion such that an absolute beginner can get started with a minimum of frustration. Lyon takes a very practical and gentle approach with a very simple first project. Eschewing overly technical language and mathematics, Designing Audio Objects is decidedly didactic in tone, yet provides ample insights into not only the theoretical underpinnings of the programming languages themselves, but also aspects of the C programming language and key concepts of digital signal processing.

Throughout, the style of writing is brisk, lucid, and engaging, making the integration of technical details and treatment of complex topics much easier to understand. Lyon’s many years of teaching have lent his treatment an ease and elegance that is not often found in books of this type. He leads the reader through each page of the text, and each step of the many interesting projects, in a highly readable way, with a subtle humor that embellishes the detailed analyses of the projects and their realizations. His desire is to initiate electronic musicians into the joys of computer programming and to illuminate the arcane world of coding for musical signal processing. Obviously, many of the techniques learned can be adapted to other contexts such as the creation of Audio Unit and VST plugins. The book traverses a graceful progression, starting with very straightforward projects it moves on to rather sophisticated and detailed topics such as spectral processing. Here the text is highly illuminating and Lyon’s considerable experience with the phase vocoder and associated technologies shines through.There are few introductory discussions of the nuts and bolts of this topic as lucid and clear as this one.

The book is organized around a series of projects that the reader completes with the aid of excellent commentary. Each project has a clear programming objective, introducing, at a measured pace, increasingly complex concepts. The first few chapters provide a wealth of information for the novice. The concept of the audio object is introduced by first leading the reader through the process of building very simple programs. These projects become the basis for subsequent projects, and Lyon explains how to leverage and reuse the common code elements as additional projects are introduced.

The first chapter introduces the ‘coding mindset’ for creating audio objects, and covers the basics for editing and compiling code in both the Macintosh and Windows development environments. Here Lyon’s approach is carefully deliberate and admirably detailed as he leads the reader through the steps necessary for initial success in a helpful and easy going style. Focusing on the mechanical process of building externals, the author discusses methods for using some of the most popular IDEs (integrated development environments), providing along the way some sage advice for ‘future-proofing’ coding activities and projects. This opening chapter is particularly helpful for those who have not worked with SDK (software development kit) and IDE tools previously, and it introduces the most simple audio objects such as mirror~, which is used by the reader to test the development environment itself. The simple process that Lyon provides will quickly have programmers up and running for the rest of the book. Detailed instructions concerning compilation in OSX, Windows, and Linux are also included, and walkthroughs for both Max and Pd provide the reader with helpful details.

Following the introductory chapter, Lyon eases up on the brakes a little and begins a fascinating journey deeper into interesting areas of musical signal processing. Chapter two begins with a description of audio signals within the digital signal processing context, including a helpful definition of signal vectors. Using an easy to understand approach with a sine wave generator, Lyon explains how to program a sine object for both Max and Pd and contrasts this with an example in JavaScript code, nicely setting-up the remaining chapters and whetting the appetite of the reader.
Chapter three begins to develop the real focus of the text and is an elaborately detailed walkthrough of the creation of a new Max external, multy~ an audio object that multiples two signals together. Readers familiar with Max and Pd will realize that this audio object lends no new functionality per se, but this is not the point of the exercise. Complexity is kept out of the DSP algorithm purposely in order for the focus to remain squarely upon the coding and implementation processes. In some ways, this chapter is the key to the entire book, as it covers in detail the steps of designing, coding, compiling, and testing a new audio object. The chapter concludes with a section on how to rework multy~ for Pd, and how to compile it as a new object within that program. Chapter three also directs the reader to Appendix A, which contains a succinct discussion of pointer arithmetic.

Subsequent chapters focus on more elaborate projects, including a variable delay with feedback object and techniques for oscillator design and implementation (featuring a highly useful discussion of methods for creating smooth transitions between waveforms). Chapter four enlightens the reader about the limitations imposed by the signal vector size in Max. The project of implementing the feedback delay line as an audio object avoids these limitations and the chapter explores a number of key DSP concepts, such as dynamic memory allocation and the circular buffer. As is typical throughout the text, Lyon fully explores implementation problems and solutions in an articulate and readable manner. Basing the variable delay project, vdelay~, on the already completed multy~ is a wonderful approach, helping the reader to quickly grasp that core functions can be quite similar across different audio object designs. In the case of vdelay~, Lyon proceeds line by line through the code, clearly explaining each step. Chapter six presents a complex external for sample-accurate sequencing and explores programming methods that deviate from typical top-down approaches. Chapter seven is concerned with non-real-time processing techniques, and the utility of buffers in DSP programming. The salient differences between implementations in Max and Pd are discussed with ample illustrative examples.

Many readers will be familiar with the FFTease set of spectral objects for Max and Pd created by Lyon in collaboration with Christopher Penrose. The discussion of spectral processing techniques in chapter eight draws upon Lyon’s considerable experience with applications of the fast Fourier transform, and is a fascinating and very useful part of the text. The projects are highly illuminating for novices in spectral programming techniques and include objects such as clearner~, which performs “adaptive noise reduction” and scrubber~, which implements dynamic time-scaling. The reader is provided with complete realizations in both Max and Pd and is also introduced to some of the intricacies of the pfft~ system in Max.

Chapter nine returns to a previously described audio object, vdelay~ but with the expressed purpose of providing an example with which to explore more demanding programming concepts and techniques for code optimization, through the advanced use of pointers, and culminating in a new object called vpdelay~. Chapter ten deals with the relatively new addition to Max/MSP of attributes, which save the state of a Max audio object. Once again, Lyon draws upon a previously completed object (oscil~) and uses it as a basis for a new one (oscil_attributes~), which brings the potential for more user configurability in context. Chapter eleven focuses on debugging techniques and provides very helpful insights and tips on how bugs may creep into audio object implementations. In fact, Lyon is very much focused on debugging throughout the text but pays special attention here to techniques for preventing them in the first place. The project of chapter twelve involves porting a Csound unit generator (opcode) to Max. The opcode in question results in the audio object moogvcf~ and the chapter describes specifically how to port the code from Csound to Max, something that by this point, near the close of the book, the reader is well prepared to tackle. Chapter 13 explores a more compositional project, and one that is very interesting despite the brevity of the chapter. Drawing upon the work of Iannis Xenakis on the stochastic synthesis of timbre, the project implements his idea for a proposed audio object. Near the end of the text, code examples are less frequent since by now the reader is ready to make translations into code independently. Chapter 14 discusses the advent of Max for Live and how to consider audio object coding in this context. 

Lyon concludes his book with a short chapter of suggestions for moving further into the world of audio object creation, citing several important texts and also outlining the importance of delving ever deeper into of the SDK documentation of Max and the source code of Pd. Appendix A contains a short treatment of pointer arithmetic, while Appendix B has a listing of the contents of the CD-ROM that accompanies the book, including the project filenames and relevant chapters in the text, together with a list of the large number of Max and Pd patches that are discussed in the book. The CD-ROM itself is well produced and functions well on both Windows and Max computers. Code examples are perfectly readable in the text, enumerated (with clear callouts to line numbers in the text), commented, and well formatted. This makes referencing the code directly in the book as profitable as examining the programming code in your IDE of choice.

Lyon’s book is a unique and comprehensive resource for electronic musicians, providing a step-by-step approach for translating audio signal processing concepts into working implementations. According to the author, the book is designed for self-study, and is predicated on the notion (put forth by Lyon’s former teacher Gareth Loy) that programming is an “oral tradition.” New programmers need a wayshower in their process of grappling with unknown territories. Lyon is guide, companion, and mentor throughout the pages and provides within the covers of his book what amounts to private lessons with an expert. While the author suggests that the book is designed for self-study, and the reader will want to dwell on sections and revisit them, the format does have some features that would enrich the context of an advanced undergraduate or graduate level course in DSP for music. There is every reason to believe that this would be a successful text in university level courses and a few weeks of dedicated study will bring the instructor up to speed quickly. Chapters include supplemental exercises as well as suggestions for further study. This is a book that is badly needed by those electronic musicians with considerable skills but who may suffer from a fear of coding for DSP. Likewise, this is a brilliant text for the fearless programmer who is eager to jump into the fray and begin to code audio objects. Lyon fills a niche quite neatly here, with a well-turned book full of useful and illuminating projects that are supported by highly readable and carefully developed discussions. There are welcome surprises and interesting projects in this book that have real musical utility. Overall, Designing Audio Objects is rich in detail and will reward your time spent with it. It is fun to work with, and for many, this will be a book you wish you had when first beginning to delve into DSP. Lyon’s considerable teaching experience and expert programming skills, combine to create a truly useful and enlightening book.