We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello, I was wondering how to change the audio amp and the bars to be inside of the musical note image I added in the code. I am a beginner just need a little help for the solution. Also, I added a clear feature, but when I click "c" to clear it doesn't clear it and you have to take multiple button pressing c to see what I mean.
PImage img;
import processing.sound.*;
Amplitude amp;
AudioIn in;
float volume = 0;
int x = 0;
void setup() {
amp = new Amplitude(this);
in = new AudioIn(this, 0);
in.start();
amp.input(in);
frameRate(50);
background(0, 255, 255);
size(600, 800);
img= loadImage("Musical Note.png");
PFont font;
font = loadFont("UrbanClass-10.vlw");
textFont(font, 12);
text("Use microphone to change color of note and click to draw.", 10, 20);
}
void draw() {
image(img, 25, 80);
//Draw normal
if (mousePressed && (mouseButton == LEFT)) {
ellipse(mouseX, mouseY, 40, 40);
fill(random(255), random(255), random(255));
noStroke();
//draw coin like pattern
} else if (mousePressed && (mouseButton == RIGHT)) {
ellipse(mouseX, mouseY, 40, 40);
fill(0, 255, 255);
noStroke();
}
volume = amp.analyze(); // get volume level
println(volume);
float graph = map(volume, 0, 1, height, 0); //Scale 0-1 volume to height of canvas
fill(random(255), random(255), random(255));
rect(x, graph, 5, height);
x += 5; // increase x to draw rectangles of graph next to each other
if (x > width) {
x = 0;
if (keyPressed == true) {
if (key == 'c')
background(0, 255, 255);
text("Use microphone to change color of note and click to draw.", 10, 20);
}
}
}
Answers
Also, I have to change the images using for loop for pixel modification/filtering
You'll get a better response if you format your code. Here's how:
http://forum.processing.org/two/discussion/15473/how-to-format-code-and-text
[code deleted, original post formatted. paste code, highlight it, press ctrl-o]
Still need help if anyone can help?