Thursday, September 28, 2006

Using sound in Processing

1. Download and install the sonia sound library
2. Install the Jsyn plugin
3. Paste the included example code into processing and save it.
4. Copy the sound files Whale.aif and Underwater.aif into a data-folder
5. Run the code and switch between the two sound with a simple mouse-click
6. Add the code to your own code. Remeber to include the "import" statement as the first line.


Click here to go to the Sonia website
Click here to install the Jsyn plugin
Download the two soundfiles from box.net


import pitaru.sonia_v2_9.*;

Sample lyd1, lyd2;

void setup() {
Sonia.start(this,22000);

lyd1 = new Sample("Whale.aif");
lyd1.setSpeed(1);
lyd1.setVolume(1);
lyd1.play();

lyd2 = new Sample("Underwater.aif");
}

void draw() {
}

void mouseReleased() {
lyd1.stop();
lyd2.play();
}

0 Comments:

Post a Comment

<< Home