Programming Sound with Pure Data

programming_sound

Sound gives your native or web apps that extra dimension, and it’s essential for games. Rather than using canned samples from a sample library, learn how to build sounds from the ground up and produce them for web projects using the Pure Data programming language. Even better, you’ll be able to integrate dynamic sound environments into your native apps or games—sound that reacts to the app, instead of sounding the same every time. Start your journey as a sound designer, and get the power to craft the sound you put into your digital experiences.

---------------

Requirements:

You’ll need a computer with a sound card and some headphones, Pure Data or Pd-extended 0.43 or greater, your favorite code editor, and Eclipse and/or Xcode for the native projects.

Excerpt from PragProg

Preface from author Tony Hillerson:

I love sound. That may sound a little strange; a lot of people would say they
love music, but I love sound. Including music. I group them together, and I
find that the line between them is blurry. There are interesting rhythmic and
even melodic and harmonic elements in everyday sounds, if you listen for
them. On the other hand, elements of music when taken out of context can
lose their musicality and sound like natural events.


I hear little things all the time, which can be either good or bad. If something’s
rattling in the car it drives me crazy and I have to stop the car and make the
noise stop. That makes my wife crazy, but I can’t help myself. That’s why it’s
so important to me to have sound done well in digital experiences, where I
spend most of my time. When I say “digital experiences” I mean anything
happening on a computer: web pages, web applications, native applications,
mobile apps, kiosk apps, art installations, and of course games in any form.
Sound, and now I mean sound effects as distinct from music, is tricky to get
right in digital experiences. Sound is very rarely a necessity. Even in games,
where it’s expected as a part of the experience, it’s rare that the user needs
sound to play. There are usually controls somewhere to turn sound off, but
you’ll never find a control to turn off the screen, or mouse or touch interaction.


On the other hand, playing a game without sound takes away an important
dimension of the experience. It’s flat; boring; unconvincing. If there’s not a
little ding when you collect a coin it’s not satisfying. If you’re running through
the forest and you don’t hear forest sounds, it’s the opposite of immersive—it
feels like merely looking at someone running through the forest on a little
screen instead of being there.


Not only games can benefit from sound in this way, though. There are a few
apps that I’ve used that struck the right tone, if you’ll pardon the pun, with
some tasteful, and above all meaningful sounds as part of the experience.
This book is not able to teach you good taste, sadly. But, if you decide this
book is for you, you will learn how to gain understanding and control over

Who Is This Book For?
I make a few assumptions about you, the reader. First of all, I assume you’re
as interested in the audible experience as I am. You may be a programmer
or designer. You’re probably interested in what you can learn about the
technical details of getting sounds into a web or native app, but it’s ok if you’re
just interested in learning about some technical approaches to designing
sound.
I assume you’ve dabbled with sound design in the past. It was most likely by
digging around in a sample library for the right pre-made sound and maybe
editing that sound a bit to get what you wanted out of it. Maybe you’re
intrigued by the idea of doing some professional sound design in the game
or movie industry, or maybe not, but for now you want to know how to gain
more control over your ability to enhance digital experiences both native and
on the web.
You may also be a musician. As I mentioned, this book isn’t about music in
digital experiences, it’s geared towards sound effects. However all of the skills
you’ll learn here are easily applicable to musical experiences, musical apps,
or at the very least a better understanding of how to think about sound in
music.
In short, I assume you have little to no experience with anything but dabbling
with sound, but you’re interested and want to learn more. I would be
extremely happy if this book helps out those independent or small-shop
developers and designers who have to wear many hats during the day and
don’t have the budget for a dedicated sound team.


What This Book Covers
This book is a practical book for people interested in digital sound design for
the web and native apps. We’re going to focus on using one software application,
Pure Data. We’re going to go through the steps of creating two sets of
practical examples: sound effect scenes that can be controlled dynamically
or output to a file.
The first set will illustrate a few different sound synthesis methods, and the
second will show how to work with existing sounds, like you might get from
a professional sound effect library.


Preface •IV
After getting used to using Pure Data and creating these examples, we’re
going to look briefly at how to get the sounds we’ve made out of Pure Data
and into a usable format, and then quickly discuss some sound production
topics.
We’ll then take a brief interlude to discuss the user experience (UX) of sound
on the web and in native applications.
Finally, we’ll consider two pre-made projects, a web project and a native
application. We’ll design sound effects for both of these, taking into account
what the best UX for each is, what we’ve learned of sound design, and consider
the possibilities of dynamic sound in the native applications.
Before we finish we’ll wrap up by considering what we’ve learned so far and
a few possible directions you could take next in your journey to becoming a
sound designer.


What This Book Doesn’t Cover
Sound design is a deep and rich field. It grew up with the movie industry and
is an essential part of the game industry. There are also many different
approaches to designing sound within those areas. This book is an introduction
to sound design for digital experiences on the web and in native applications,
which could include games.
We’ve chosen a pragmatic approach to introducing this subject; one which
focuses on building practical examples using synthesis with a procedural
sound application which is only one of many possible ways to design sound.
Here are some other important topics that aren’t in scope for this book, but
are areas you may want to dig into next:
• This book will not cover capturing or recording sounds for analysis or
sound production. Audio engineering, field recording, and Foley studio
work are all good things to have under your belt as a sound designer, but
we won’t discuss them in any depth here.
• Analysis of recorded sound is also beyond the scope of this book. To
reproduce a convincing effect it’s very useful to know what’s going on in
a real world example instead of guessing. We’ll only have space to do a
very rudimentary, intuitive analysis of some sounds as we build our
examples, but as an area for later study, sound analysis would be very
beneficial.
• There is a lot of math behind describing and reproducing sound. Algebra.
Trigonometry for describing oscillators and geometric waves. Calculus
for, among other things, Fourier Analysis. That math is good to know,
but beyond the scope of this book.
• A deep understanding of the science of sound is extremely helpful to the
sound designer. In the field of physics: material physics, fluid dynamics,
acoustics and many others will help you understand from first principles
how sound is made and how to reproduce it. Understanding the math
used to express the physics in these areas will be helpful too. As mentioned
all of our practical examples will be intuitively designed, and we won’t
take the time to dig into the science of why the sound works the way it
does. A great next step would be to start to understand the underlying
causes of sound.
• Psychoacoustics, or the study of how humans process and perceive sound,
is important to understand as a sound designer. There are some surprising
things to learn from the field that can help you become a better and more
efficient sound designer, but we won’t have time to dig into it here.


Where Will You Be When You Finish This Book?
When you’ve read this book you’ll have had the experience of creating a set
of sound effects using Pure Data, ready for inclusion in a dynamic sound
application or for creating a static sound file. You’ll have a practical understanding
of sound synthesis techniques and general understanding of how
different fundamental components of sound can be used to produce sounds
anywhere from those we hear every day to sounds that we’d only hear in a
futuristic science fiction world.
You’ll be ready to take the next steps to understanding and growing as a
sound designer, whether that be practicing what you learn here, building
sounds for games and apps you’ll be making, or digging in deeper to the math,
physics, and other fundamentals of sound design.
Online Resources
On Pragmatic Bookshelf’s page for this book1 there are some important
resources. There are code downloads containing all the Pure Data patches
you’ll see in this book, as well as the source for the web, Android and iOS
projects. You’ll also find feedback tools such as a community forum and an
errata submission form where you can recommend changes to future releases
of the book.

Available on Sept 10th. Use Discount code: "GAsoundSep" and order HERE

-------

Tony Hillerson is a partner and mobile developer at Tack Mobile. He’s designed sound and composed music for Tack’s games and apps. Tony has also spoken at RailsConf, AnDevCon, 360|iDev, and has created popular Android screencasts. In his free time Tony plays the bass, Warr Guitar, and makes electronic music.