We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello!
I have a problem. I am a newbie with processing and I'm trying to make a sound meter similar to one that you would see on a lie detecter test/or a Joy Division album cover. I've only been using processing for a month now, and the problem I'm running into is that every time I make a sound my image jumps and looks like squares instead of curved lines.
Hoping I could get some help....
-Clinton
import processing.sound.*; AudioIn in; Amplitude amp; float x=50; float y=10; float c; void setup() { frameRate (300); size (1500, 500); amp=new Amplitude(this); in=new AudioIn(this, 0); in.start(); amp.input(in); background(255); }
void draw() { c=amp.analyze()*50; beginShape(); stroke(25);
line(x, y, x, y-c); line(x, y, x, y+c); x++; if (x>width) { y=y+10; x=0; } }
Answers
Please format your code. Edit your post (gear on top right side of any of your posts), select your code and hit ctrl+o. Leave an empty line above and below your block of code. Details here: https://forum.processing.org/two/discussion/15473/readme-how-to-format-code-and-text
Demo below.
Kf
P.S. The code for the line() function above could be replace with:
Hey KF,
Thanks for this, extremely helpful. The only problem that I'm running into with your code is that when the meter goes to the next line, it keeps running (connecting the line to the next with a massive diagonal line through the screen) . Wondering if it's possible to get it to skip to the next line in the Y axis. Let me know if this doesn't make sense, and thanks again!
Right, it is a bug in my code. Here is a revised version of the relevant section. You need to change one line. I edited my code above.
Kf
Thanks for this!
For those not familiar with this: