Thank you, both of you.
I especially took a look at Cedric's solution and it makes totally sense.
But when it comes to my program, I don't really know where to put in the reference to my audio samples.
Is there another possibility to record the order of my sounds?
Perhaps with LineOut or something? (I tried this before but it didn't work).
Thanks again for your commitment, but I guess I'm just too less experienced in processing, and I don't have a book or something at the moment.
Code:
import ddf.minim.*;
import ddf.minim.signals.*;
Minim minim;
AudioInput in;
AudioRecorder recorder1;
AudioRecorder recorder2;
AudioSample sound1;
AudioSample sound2;
int pad = 0;
void setup() {
background(0);
size(600, 400);
// Get Line In
minim = new Minim(this);
in = minim.getLineIn(Minim.STEREO, 2048);
recorder1 = minim.createRecorder(in, "sound1.wav", true);
recorder2 = minim.createRecorder(in, "sound2.wav", true);
// Pad colours
noStroke();
fill(255, 85, 0);
rect(0, 0, 200, 200);
fill(255, 128, 66);
rect(200, 0, 200, 200);
fill(254, 170, 128);
rect(400, 0, 200, 200);
fill(255, 150, 0);
rect(0, 200, 200, 200);
fill(254, 180, 73);
rect(200, 200, 200, 200);
fill(254, 203, 128);
rect(400, 200, 200, 200);
}
void draw() {
float ms = millis() % 10000;
// Which pad?
if (mouseX > 0 && mouseX < 200 && mouseY > 0 && mouseY < 200) {
pad = 1;
}
if (mouseX > 200 && mouseX < 400 && mouseY > 0 && mouseY < 200) {
pad = 2;
}
}
// Recording
void keyReleased() {
// Checken, if cursor is over Pad1
if (pad == 1) {
if (key == 'r') {
// Start/stop recording
if (recorder1.isRecording()) {
recorder1.endRecord();
}
else {
recorder1.beginRecord();
}
}
// Save recording
if (key == 's') {
recorder1.save();
println("Pad1 has a sound.");
}
}
// Play Pad1
if ( key == '1' ) {
sound1 = minim.loadSample("sound1.wav", 2048);
sound1.trigger();
}
if (pad == 2) {
if (key == 'r') {
if (recorder2.isRecording()) {
recorder2.endRecord();
}
else {
recorder2.beginRecord();
}
}
if (key == 's') {
recorder2.save();
println("Pad2 has sound.");
}
}
if ( key == '2' ) {
sound2 = minim.loadSample("sound2.wav", 2048);
sound2.trigger();
}
}
// Stop tone with quitting program
void stop()
{
in.close();
minim.stop();
super.stop();
}