To mesure the delay, I’ve made something like that:
It gives me 17ms now constantly except sometimes gives me 1ms.
long last_click = 0;
long theorical_click = 0;
void draw(){
if(millis()-last_click > 500){
println("click audio");
println("Delay :" + (millis() - theorical_click) );
last_click = millis();
theorical_click = last_click + 500;
}
}
I’ve found that post, but it doesn’t work very well too.
That’s the last code I made after reading the post. Maybe problem is audio?
import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
import ddf.minim.signals.*;
import ddf.minim.spi.*;
import ddf.minim.ugens.*;
Minim min;
AudioPlayer down;
AudioPlayer up;
int cont = 0;
long last = 0;
long next = System.nanoTime() + 1000000000;
void setup(){
min = new Minim(this);
up = min.loadFile("C:/Users/Arnau/Desktop/sketch_180907a/MetronomeAM_v02/data/up2.wav");
down = min.loadFile("C:/Users/Arnau/Desktop/sketch_180907a/MetronomeAM_v02/data/down2.wav");
}
void draw(){
if(System.nanoTime() > next){
next = next + 500*1000000;
up.play(10);
cont++;
}
}