Thanks for awnsering !
I replaced the trigger() function with play () and tested the isPlaying variant.
Only one the first gesture is playing the sound.
I'm going to tried something else with the isPlaying variant tonight.
Meanwhile, I mad that:
Instead of capturing the hand position, I only capture the position of the fingers.
But some gestures are not taken in consideration,( I guess it's concerning my booleans values).
More over, I can play with only one fingers.
import de.voidplus.leapmotion.*;
import ddf.minim.*;
import ddf.minim.ugens.*;
import javax.swing.JFrame;
LeapMotion leap;
Minim minim;
AudioSample Kick1;
AudioSample Hat1;
AudioSample Clap1;
boolean PlayedOnce_Kick1;
boolean PlayedOnce_Hat1;
boolean PlayedOnce_Clap1;
boolean KickZone;
boolean HatZone;
boolean ClapZone;
void setup() {
//size(1680, 1050, P3D);
size(displayWidth, displayHeight,P3D);
// ...
leap = new LeapMotion(this).withGestures("key_tap");
minim = new Minim(this);
Kick1 = minim.loadSample("Kick1.wav");
Hat1 = minim.loadSample("Hat1.wav");
Clap1 = minim.loadSample("Clap1.wav");
}
void draw() {
for (Hand hand : leap.getHands()) {
hand.draw();
for(Finger finger : hand.getFingers()){
finger.draw();
PVector finger_position = finger.getPosition();
//println(finger_position);
//Kick----------------------------------------------------------------------------------------------------------------
if (finger_position.x>700 && finger_position.x<1100) {
if ( KickZone == false) {
KickZone = true;
}
else {
}
}
else {
KickZone = false;
}
//Hat-----------------------------------------------------------------------------------------------------------------
if (finger_position.x>1100) {
if ( HatZone == false) {
HatZone = true;
}
else {
}
}
else {
HatZone = false;
}
//Clap-----------------------------------------------------------------------------------------------------------------
if (finger_position.x<700){
if (ClapZone == false) {
ClapZone = true;
}
else {
}
}
else {
ClapZone = false;
}
}
}
}
void leapOnKeyTapGesture(KeyTapGesture g){
//Kick--------------------------------
if (KickZone == true){
if ( PlayedOnce_Kick1 == false ){
PlayedOnce_Kick1 = true;
Kick1.trigger();
PlayedOnce_Kick1 = false;
}
else{
}
}
else{
}
//Hat----------------------------------
if (HatZone == true){
if ( PlayedOnce_Hat1 == false){
PlayedOnce_Hat1 = true;
Hat1.trigger();
PlayedOnce_Hat1 = false;
}
else{
}
}
else{
}
//Clap--------------------------------
if (ClapZone == true){
if ( PlayedOnce_Clap1 == false){
PlayedOnce_Clap1 = true;
Clap1.trigger();
PlayedOnce_Clap1 = false;
}
else{
}
}
else{
}
}
Here is a video showing what it does :
As you can see, some key_tap gestures detected by the vizuliser are not taken in consideration.
I can record a video showing what it does when I use 2 fingers, but basically, I can't play 2 different sounds at the same time :/
Do you have any ideas how can improve that ? How can I use this programm with two hands/ fingers ?