Learn creative coding writing simple programs

99. Add sounds to your programs

Update: The LoadSample example program is now called TriggerASample.
Update: The stop() function is no longer required in Minim for Processing 2.1.

Adding sound to your Processing programs is easy. To play sounds we need to use an external library, because by default Processing does not play sounds. But it's just a few lines of code.

One important thing we discover in this episode is the Examples menu. That's a huge collection of programs that come with Processing. There are lots of examples for almost every feature. You can quickly open and run programs that experiment and explain math concepts, arrays, animation, 2D, 3D and much more, including the Minim sound library. It's a good idea to browse those examples, run each program and study the source code to understand how it works. It's a good way to learn and find inspiration for your own projects.

Tags: audio, sound, mp3, wav, effects

Code editor

You can make changes to the code below. Then

Questions and comments

Try to stay close to the topic of this episode. Use the Processing forums for help with unrelated Processing projects (or hire me for help ;-)

To indicate that a word in your comment is code, use the `backtick`. Example
  Do `float` and `int` smell similar?
To highlight code blocks, use ```processing and ``` like this:
  void setup() {
    size(600, 600);