import ddf.minim.*; Minim minim; AudioInput in; float lemin, lemax; boolean cliqued = false; float[] X = new float[1024]; void setup(){ size(800, 600); minim = new Minim(this); in = minim.getLineIn(Minim.MONO, 1024, 44100); smooth(); textFont(createFont("Arial", 12)); frameRate(4); } void draw() { background(15,50,20); fill(255); text("Phonautographe du pr. Pierre "+frameCount, 10,height-12); stroke(200,0,0); line(0,height/2,width,height/2); stroke(255); if (!cliqued) { X = in.left.toArray(); for(int i = 0; i < X.length-1; i++) { float h1 = map(X[i],-1,+1,height,0); float h2 = map(X[i+1],-1,+1,height,0); line(i, h1, i+1, h2); //line(i,height/2,i,h1); } } else { lemax = max(X); lemin = min(X); for(int i = 0; i < X.length-1; i++) { float h1 = map(X[i],lemin,lemax,height,0); float h2 = map(X[i+1],lemin,lemax,height,0); line(i, h1, i+1, h2); } } } void keyPressed(){ cliqued = !cliqued; if (cliqued) noLoop(); else loop(); //save("scope"+frameCount+".png"); } void stop() { in.close(); minim.stop(); super.stop(); }