3.6.1. Downloading Libraries
Many Processing libraries are available for download at www.processing.org/reference/libraries/index.html. The libraries here include libraries used for working with 3D libraries, libraries that communicate with Bluetooth-enabled devices, and simple gesture recognition libraries for recognizing the movements made by a user with a mouse or Wii remote controller.
For this example, you'll download the ControlP5 library, install it to the Processing directory, and write a quick test to ensure that it works properly. First, locate the ControlP5 library on the Libraries page of the Processing site under the Reference heading. Clicking ControlP5 on the Libraries page brings you to the ControlP5 page at http://www.sojamo.de...ies/controlP5/. Once you've downloaded the folder, unzipping the .zip file will create the controlP5 folder. Inside this is a library folder that contains all the .jar files that the Processing application will access.
Now that you've downloaded the library, the libraries folder of your Processing sketchbook. The Processing sketchbook is a folder on your computer where all of your applications and libraries are stored. To change the sketchbook location, you can open the Preferences window from the Processing application and set value in the "Sketchbook location" field. You'll need to copy the contributed library's folder into the "libraries" folder at this location. To go to the sketchbook, you hit Ctrl-K (-K on Mac OS X). If this is the first library you've added, then you need to create the "libraries" folder. For instance, on my computer the Processing sketchbook is installed at /Users/base/processing, so I place the controlP5 folder at /Users/base/processing/libraries/. Your setup may vary depending on where you've installed Processing and your system type. Once the library is in the correct location, restart the Processing IDE, and type the following code in the IDE window:
import controlP5.*;
Then, run the application. If a message appears at the bottom of the IDE saying this:
You need to modify your classpath, sourcepath,
bootclasspath, and/or extdirs setup. Jikes could not find package
"controlP5" in the code folder or in any libraries.
then the ControlP5 library has not been created properly. Double check that the folder is in the correct location. If you don't get this message, you've successfully set up ControlP5. We'll talk about it in greater depth in Chapter 7. For now, we'll talk about some of the more common libraries for Processing and what they do:
Minim by Damien Di Fede
This uses the JavaSound API to provide an easy-to-use audio library. This is a simple API that provides a reasonable amount of flexibility for more advanced users but is highly recommended for beginners. It's clear and well documented.
OCD by Kristian Linn Damkjer
The Obsessive Camera Direction (OCD) library allows intuitive control and creation of Processing 3D camera views.
surfaceLib by Andreas Köberle and Christian Riekoff
This offers an easy way to create different 3D surfaces. It contains a library of surfaces and a class to extend.
Physics by Jeffrey Traer Bernstein
This is a nice and simple particle system physics engine that helps you get started using particles, springs, gravity, and drag.
AI Libraries by Aaron Steed
These are a great set of libraries to assist with artificial programming tasks such as genetic algorithms and the AStar pathfinding algorithm. We'll discuss this in greater detail in Chapter 18.
bluetoothDesktop by Patrick Meister
This library lets you send and receive data via Bluetooth wireless networks.
proMidi by Christian Riekoff
This library lets Processing send and receive MIDI information.
oscP5 by Andreas Schlegel
This library is an OpenSound Control (OSC) implementation for Processing. OSC is a protocol for communication among computers, sound synthesizers, and other multimedia devices.
Almost all of these will be discussed in later chapters when demonstrating how to extend Processing to help you work with physical interactions, other programming languages like Arduino, and other devices like GPS devices and physical controls.
Make cool stuff. If you're a designer or artist without a lot of programming experience, this book will teach you to work with 2D and 3D graphics, sound, physical interaction, and electronic circuitry to create all sorts of interesting and compelling experiences -- online and off. Programming Interactivity explains programming and electrical engineering basics, and introduces three freely available tools created specifically for artists and designers: Processing, Arduino, and OpenFrameworks.




Help






