06.01.2013 Views

Learning Processing: A Beginner's Guide to Programming Images ...

Learning Processing: A Beginner's Guide to Programming Images ...

Learning Processing: A Beginner's Guide to Programming Images ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

20<br />

Sound<br />

“ Check. Check. Check 1. Sibilance. Sibilance. Check. Check. Check 2. Sibilance. Sibilance. ”<br />

—Barry the Roadie<br />

In this chapter:<br />

– Libraries for Sound.<br />

– Simple sound playback.<br />

– Playback with adjusting volume, pitch, and pan.<br />

– Microphone as sound sensor.<br />

Sound 381<br />

<strong>Processing</strong> does not have built-in support for sound. Not that there is anything wrong with sound. Not<br />

that <strong>Processing</strong> has a personal grudge against sound. Th ere is just no built-in sound. As we discussed<br />

in the introduction <strong>to</strong> this book, <strong>Processing</strong> is a programming language and development environment,<br />

rooted in Java, designed for learning <strong>to</strong> program in a visual context . So, if you want <strong>to</strong> develop large-scale<br />

interactive applications primarily focused on sound, you should really ask yourself: “ Is <strong>Processing</strong> the<br />

right programming environment for me? ” Th is chapter will help answer that question as we explore the<br />

possibilities and limitations of working with sound in <strong>Processing</strong> .<br />

Incorporating sound in<strong>to</strong> <strong>Processing</strong> sketches can be accomplished a number of diff erent ways. Because<br />

<strong>Processing</strong> does not support sound in its core library, many <strong>Processing</strong> developers choose <strong>to</strong> incorporate<br />

sound via a third party application geared <strong>to</strong>ward sound, such as PureData ( http://www.puredata.org/ )<br />

or Max/MSP ( http://www.cycling74.com/ ). <strong>Processing</strong> can communicate with these applications via OSC<br />

( “ open sound control ” ) a pro<strong>to</strong>col for network communication between computers and multimedia<br />

devices. Th is can be accomplished in <strong>Processing</strong> by using the network library (see the previous chapter) or<br />

with the oscP5 library, by Andreas Schlegel ( http://www.sojamo.de/libraries/oscP5 )<br />

Visiting the <strong>Processing</strong> web site will also reveal a list of contributed libraries for using sound directly in<br />

<strong>Processing</strong> : playing sound samples, analyzing sound input from a microphone, synthesizing sound, and<br />

sending and receiving midi information. Th is chapter will focus on two of these elements: sound playback<br />

and sound input . For playback of sound eff ects we will look at the Sonia library (by Amit Pitaru) and the<br />

Minim library (by Damien Di Fede). Sound input will be demonstrated with Sonia .<br />

Th ese sound libraries are available at the following URLs:<br />

Sonia: http://sonia.pitaru.com/<br />

Minim: http://code.compartmental.net/<strong>to</strong>ols/minim/<br />

For a review on how <strong>to</strong> install third party libraries, visit Chapter 12 . You will also want <strong>to</strong> visit<br />

http://www.learning processing.com <strong>to</strong> download the sample sound fi les used in these examples.<br />

20.1<br />

Really Simple Sound<br />

Before we look at the libraries, however, there is one simple (but extremely limited) way <strong>to</strong> play a sound<br />

fi le in a <strong>Processing</strong> sketch without installing a third party library. Th is is through the use of the Movie class<br />

which we learned in Chapter 16. Th e Movie class is designed <strong>to</strong> play QuickTime movies, but can also be

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!