hints on sound interactions
in
Core Library Questions
•
3 months ago
Hi all, I'm a beginner. I'm trying to do some interaction with sounds. As u can see in the code below, I've loaded 2 different sounds and they play when hitting respectively 'a' or 'b' key. Now, at this point they only play one time. After that (after they end), if I keep pressing the keys only the figures (rect) will be shown, no sounds. What should I add to change this?
Second thing. For what I saw, while there's a sound playing (let's say the one within 'a' key), if the 'a' key gets pressed nothing happens. then, once a sound begin, the keyPressed func. for 'a' (then only for the related key) will be disabled, until the related sound will end. Am I right on this?
thanks :)
Second thing. For what I saw, while there's a sound playing (let's say the one within 'a' key), if the 'a' key gets pressed nothing happens. then, once a sound begin, the keyPressed func. for 'a' (then only for the related key) will be disabled, until the related sound will end. Am I right on this?
thanks :)
- import ddf.minim.*;
Minim minim;
AudioPlayer player1;
AudioPlayer player2;
void setup(){
size(300,300);
minim = new Minim(this);
player1 = minim.loadFile("click1.wav");
player2 = minim.loadFile("wind.wav");
}
void draw(){
background(0);
}
void keyPressed(){
if (key=='a'){
fill(255,0,0);
rect(100,100,120,120);
player1.play();
}else if (key=='b'){
fill(0,255,0);
rect(100,100,120,120);
player2.play();
}else {
fill(0,0,255);
rect(100,100,120,120);
}
}
1