I'm still very much a newbie at Processing––taking my first beginner class, and I'm doing this guitar tuner project using minim sounds.
I get this particular Null Pointer error if I rapidly play sounds in my sketch, but only if I click out of the sketch. The error doesn't stop my program from working, but the moment I x out of it, the error pops up in the main Processing window.
Here's the error:
java.lang.NullPointerException at processing.mode.java.runner.Runner.findException(Runner.java:707) at processing.mode.java.runner.Runner.reportException(Runner.java:652) at processing.mode.java.runner.Runner.exception(Runner.java:595) at processing.mode.java.runner.EventThread.exceptionEvent(EventThread.java:367) at processing.mode.java.runner.EventThread.handleEvent(EventThread.java:255) at processing.mode.java.runner.EventThread.run(EventThread.java:89) Exception in thread "Thread-5" java.lang.NullPointerException at ddf.minim.javasound.JSBaseAudioRecordingStream.readBytes(Unknown Source) at ddf.minim.javasound.JSBaseAudioRecordingStream.mRead(Unknown Source) at ddf.minim.javasound.JSBaseAudioRecordingStream.read(Unknown Source) at ddf.minim.javasound.JSAudioOutput.readStream(Unknown Source) at ddf.minim.javasound.JSAudioOutput.run(Unknown Source) java.lang.NullPointerException at processing.mode.java.runner.Runner.findException(Runner.java:707) at processing.mode.java.runner.Runner.reportException(Runner.java:652) at processing.mode.java.runner.Runner.exception(Runner.java:595) at processing.mode.java.runner.EventThread.exceptionEvent(EventThread.java:367) at processing.mode.java.runner.EventThread.handleEvent(EventThread.java:255) at processing.mode.java.runner.EventThread.run(EventThread.java:89) Exception in thread "Thread-6" java.lang.NullPointerException at ddf.minim.javasound.JSBaseAudioRecordingStream.readBytes(Unknown Source) at ddf.minim.javasound.JSBaseAudioRecordingStream.mRead(Unknown Source) at ddf.minim.javasound.JSBaseAudioRecordingStream.read(Unknown Source) at ddf.minim.javasound.JSAudioOutput.readStream(Unknown Source) at ddf.minim.javasound.JSAudioOutput.run(Unknown Source)
And below is my main program code. I apologize for the length! I know an expert programmer could write this much more efficiently, so I apologize for my newbish-ness :-p.
Ellipses[] shadows = new Ellipses[2]; //Black ellipses that forms "shadow" of guitar. Quads[] qshadow = new Quads[1]; //Black quad that forms "shadow" of guitar neck. Ellipses[] body = new Ellipses[2]; //Guitar Body Parts. Ellipses[] sh = new Ellipses[1]; //Sound Hole. Quads[] gneck = new Quads[1]; //Guitar Neck. Quads[] gbridge = new Quads[1]; //Guitar Bridge. Points[] bpoints = new Points[4]; //Bridge Points. Lines[] bline = new Lines[1]; //Bridge Line. Lines[] gstrings = new Lines[6]; //Guitar Strings. Triangles[] tuners = new Triangles[4]; //Guitar Tuners. Ellipses[] soundbuttons = new Ellipses[4]; //Sound Buttons.
void setup() { size(1000,700);
//FONT(S);
b = loadFont("ACaslonPro-Italic-48.vlw"); c = loadFont("ACaslonPro-Italic-20.vlw");
I'm a very new programmer at the end of my intro programming course. My project is creating a guitar tuner in Processing that uses a lot of objects in specific places. I've posted an excerpt that includes the ellipse class and all the object stuff to give you an idea of what I'm doing.
My professor suggested using arrays to shorten my overall code. I've used arrays before, and used one in my complete sketch to load sounds for minim.
Arrays seem to be really non-user friendly for someone not good at programming, haha, unless you are a mathematician and use complex multiplication and division in a for loop!
Still, I'm dedicated to at least attempting to shorten my code if I can. Below is an example of some of my code and I'm really curious to see how I can make it more efficient!
//Guitar Body Variables:
Ellipses BigGuitarCircle; //Big Guitar Circle
Ellipses SmallGuitarCircle; //Small Guitar Circle
Ellipses SoundHole; //Guitar Sound Hole
void setup() {
size(1000,700);
//Guitar Body Setups:
BigGuitarCircle = new Ellipses(200,485,350,310); //Big guitar circle
SmallGuitarCircle = new Ellipses(400,390,280,280); //Small guitar circle
SoundHole = new Ellipses(320,430,170,170); // Guitar sound hole
}
void draw() {
smooth();
background(#9E9E9E);
//Guitar Body Draws:
BigGuitarCircle.bodyEllipses(); //Big Guitar Circle
SmallGuitarCircle.bodyEllipses(); //Small Guitar Circle
SoundHole.bodyEllipses(); // Guitar Sound Hole
}
//Ellipse Class:
class Ellipses {
int x;
int y;
int width;
int height;
Ellipses(int tempX,int tempY,int tempWidth, int tempHeight) {
x = tempX;
y = tempY;
width = tempWidth;
height = tempHeight;
}
Hey folks. I'm doing a rollover and when I click within my sketch, the line changes from black to red. However, I want my mousePressed command only to change the color of the line when I click the line itself. How do I do that. Do I use an "if" function?
I'm another one of those guys who is learning Processing for a class. I'm really enjoying my introduction to processing, and I created a basic sketch of a guitar for my very first assignment.
What I'd like to do for my second assignment is make the guitar a little more dynamic. If you're familiar with stringed instruments/guitars, you know that they have tuners to tune the strings.
What I'd like to do to make my guitar a little more lively is to have the tuners "spin" when either the mouse is clicked on the tuners or hovers over them.
The tuners were created with simple triangle shapes that connect to lines which I called "strings." I'd like the triangles to rotate on that point, but an unsure how to make them do that!
Can someone point me in the right direction? Thanks!