Hello.
I’m starting with processing and I’ve been putting together examples to create my own.
In this one I would like to add some sound when moving the mouse (and the square drawing).
How to add a sample or a noise wave, white noise or any sound wile i move the mouse and drawing?
Tks for help.
here is my code:
/**
- Blur Filter
- Change the default shader to apply a simple, custom blur filter.
- Press the mouse to switch between the custom and default shader.
/
import ddf.minim.; //n
Minim minim; //n
AudioSample radar;//n
AudioSample pulse;
AudioSample hit;
AudioSample lucid;
int x = 900; //n
int y = 700;//n
int dx = 85; //n
int dy = 85; //n
PShader blur;
float r = 0;
void setup() {
background(0);
size(800, 800, P2D);
stroke(98, 250, 8);
rectMode(CENTER);
smooth();
blur = loadShader(“blur.glsl”);
minim = new Minim(this); //novo
radar = minim.loadSample(“radar.wav”, 2048); // novo
pulse = minim.loadSample(“pulse.wav”, 2034);
hit = minim.loadSample(“hit.wav”, 2035);
lucid = minim.loadSample(“lucid.wav”, 143);
}
void draw() {
if (mousePressed){
x += dx/2;
y += dy/2;
//superior esquerdo
int m = millis();
//stroke(155);
fill(m % 105);
rect(50, 50, 50, 50, 5);
textSize(15);
fill(150);
text(“Techno”, 27, 60);
// inferior direito
int m3 = millis();
//stroke(155);
fill(m3 % 105);
rect(750, 750, 50, 50, 5);
textSize(15);
fill(150);
text(“Techno”,728, 760);
//superior direito
int m4 = millis();
//stroke(155);
fill(m4 % 105);
rect(750, 50, 50, 50, 5);
textSize(15);
fill(150);
text(“Techno”, 727, 60);
int m5 = millis();
//stroke(155);
fill(m5 % 105);
rect(50, 750, 50, 50, 5);
textSize(15);
fill(150);
text(“Techno”, 27, 760);
int m2 = millis();
//stroke(155);
fill(m2 % 205);
filter(blur);
translate(mouseX, mouseY);
rotate(r);
rect(mouseX/8, mouseY/8, 150, 150);
ellipse(mouseX/8, mouseY/8, 100, 100);
r = r + 0.05;
textSize(50);
fill(255);
text(“VrtX”, 5,35);
textSize(50);
fill(255);
text(“ArT”, 10, 75);
}
}
void stop(){
radar.close();
minim.stop();
super.stop();
}
// saveFrame(“frame-####.jpg”);