I have a program I'm working on that uses the Beads library to sample songs and change the rate at which they're played (this is done using a potentiometer—I'm sending data in from an Arduino to control the rate).
In this program, the sound clip is established in the void setup() function.
However, I would like to be able to change the song sample dynamically, in void draw(), depending on what data the program is receiving. I have five different songs, and I want the Processing program to play a different song, depending on whether the values it's receiving are between 1-100, 101-200, 201-300, 301-400, or 401-500.
Here is my code so far:
import processing.serial.*;
Serial port;
float derp = 0;
// Sampling_03.pde
// this is a more complex sampler
// clicking somewhere on the window initiates sample playback
// moving the mouse controls the playback rate
import beads.*;
AudioContext ac;
SamplePlayer sp1;
// we can run both SamplePlayers through the same Gain
Gain sampleGain;
Glide gainValue;
Glide rateValue;
void setup()
{
size(800, 600);
port = new Serial(this, "/dev/tty.usbmodem411", 9600);
port.bufferUntil('\n');
ac = new AudioContext(); // create our AudioContext
// whenever we load a file, we need to enclose the code in a Try/Catch block
// Try/Catch blocks will inform us if the file can't be found
try {
// initialize the SamplePlayer
sp1 = new SamplePlayer(ac, new Sample(sketchPath("") + "prelude_no_8.mp3"));
}
catch(Exception e)
{
// if there is an error, show an error message (at the bottom of the processing window)
println("Exception while attempting to load sample!");
e.printStackTrace(); // then print a technical description of the error
exit(); // and exit the program
}
// note that we want to play the sample multiple times
Hello, I'm trying to run this example sketch from
http://www.tree-axis.com/Ess/ and for some reason, whenever I try to compile the code, I always get an error that reads: "The constructor Amplify(float) is undefined." How can I fix this? Thanks. :)
Hi, I have my arduino connected to two sensors that are controlling the graphics in a Processing program. However, the graphics are SUPER slow. I have no idea what could be causing this problem. Please help! My project is due in a couple of hours.
I copied this code straight from a Processing book, and yet whenever I try to compile, I keep receiving a message stating: ArrayIndexOutOfBoundsException = 0. Anybody know why?
float[] sineWave = new float[width];
void setup() {
}
void draw() {
for (int i=0; i < width; i++) {
float r = map(i, 0, width, 0, TWO_PI);
sineWave[i] = abs(sin(r));
}
for(int i=0; i<sineWave.length; i++) {
//Set the stroke values to numbers read from the array
I'm trying to export my Processing sketch to an HTML page. However, when I try to open it in Chrome, I receive the following message: "
This browser does not have a Java Plug-in. Get the latest Java Plug-in here." I run Mac OS X 10.6, so I went to Software Update and installed all the updates I needed. It STILL doesn't work. Please help??