Having trouble with arduino and minim librarys
in
Contributed Library Questions
•
11 months ago
Hello,
I am working on using minim sound detection and my arduino to control my christmas lights this year, and I found an instructable that used the mimim library to control leds hooked up to the arduino. However, whenever I try to run it I get a bunch of errors.
Here is my code(not mine, from instructable)
- import ddf.minim.*;
- import ddf.minim.analysis.*;
- import processing.serial.*;
- import cc.arduino.*;
- Arduino arduino;
- //3-blue, 5-blue, 6-blue, 9-blue, 10-green, 11-white, 12-red, 13-orange
- //Set these in the order of frequency - 0th pin is the lowest frequency,
- //while the final pin is the highest frequency
- int[] ledPins = {3,5,6,9,10,11,12,13};
- int[] lastFired = new int[ledPins.length];
- //Change these to mess with the flashing rates
- //Sensitivity is the shortest possible interval between beats
- //minTimeOn is the minimum time an LED can be on
- int sensitivity = 100;
- int minTimeOn = 100;
- String mode;
- String source;
- Minim minim;
- AudioInput in;
- AudioPlayer song;
- BeatDetect beat;
- //Used to stop flashing if the only signal on the line is random noise
- boolean hasInput = false;
- float tol = 0.005;
- void setup(){
- //Uncomment the mode/source pair for the desired input
- //Shoutcast radio stream
- //mode = "radio";
- //source = "http://scfire-ntc-aa05.stream.aol.com:80/stream/1018";
- //mode = "file";
- //source = "/path/to/mp3";
- mode = "mic";
- source = "";
- size(512, 200, P2D);
- minim = new Minim(this);
- arduino = new Arduino(this, Arduino.list()[0]);
- for (int i = 0; i < ledPins.length; i++){
- arduino.pinMode(ledPins[i], Arduino.OUTPUT);
- }
- minim = new Minim(this);
- if (mode == "file" || mode == "radio"){
- song = minim.loadFile(source, 2048);
- song.play();
- beat = new BeatDetect(song.bufferSize(), song.sampleRate());
- beat.setSensitivity(sensitivity);
- } else if (mode == "mic"){
- in = minim.getLineIn(Minim.STEREO, 2048);
- beat = new BeatDetect(in.bufferSize(), in.sampleRate());
- beat.setSensitivity(sensitivity);
- }
- }
- void draw(){
- if (mode == "file" || mode == "radio"){
- beat.detect(song.mix);
- drawWaveForm((AudioSource)song);
- } else if (mode == "mic"){
- beat.detect(in.mix);
- drawWaveForm((AudioSource)in);
- }
- if (hasInput){ //hasInput is set within drawWaveForm
- for (int i=0; i<ledPins.length; i++){
- if ( beat.isRange( i+1, i+1, 1) ){
- arduino.digitalWrite(ledPins[i], Arduino.HIGH);
- lastFired[i] = millis();
- } else {
- if ((millis() - lastFired[i]) > minTimeOn){
- arduino.digitalWrite(ledPins[i], Arduino.LOW);
- }
- }
- }
- }
- } //End draw method
- //Display the input waveform
- //This method sets 'hasInput' - if any sample in the signal has a value
- //larger than 'tol,' there is a signal and the lights should flash.
- //Otherwise, only noise is present and the lights should stay off.
- void drawWaveForm(AudioSource src){
- background(0);
- stroke(255);
- hasInput = false;
- for(int i = 0; i < src.bufferSize() - 1; i++)
- {
- line(i, 50 + src.left.get(i)*50, i+1, 50 + src.left.get(i+1)*50);
- line(i, 150 + src.right.get(i)*50, i+1, 150 + src.right.get(i+1)*50);
- if (!hasInput && (abs(src.left.get(i)) > tol || abs(src.right.get(i)) > tol)){
- hasInput = true;
- }
- }
- }
- void resetPins(){
- for (int i=0; i<ledPins.length; i++){
- arduino.digitalWrite(ledPins[i], Arduino.LOW);
- }
- }
- void stop(){
- resetPins();
- if (mode == "mic"){
- in.close();
- }
- minim.stop();
- super.stop();
- }
And here are the errors I get,
- Stable Library
- =========================================
- Native lib Version = RXTX-2.1-7
- Java lib Version = RXTX-2.1-7
- Exception in thread "Animation Thread" java.lang.RuntimeException: java.lang.IllegalAccessError: tried to access class processing.core.PApplet$RegisteredMethods from class cc.arduino.Arduino$SerialProxy
- at processing.opengl.PGL.requestDraw(PGL.java:1021)
- at processing.opengl.PGraphicsOpenGL.requestDraw(PGraphicsOpenGL.java:1526)
- at processing.core.PApplet.run(PApplet.java:2006)
- at java.lang.Thread.run(Thread.java:662)
- Caused by: java.lang.IllegalAccessError: tried to access class processing.core.PApplet$RegisteredMethods from class cc.arduino.Arduino$SerialProxy
- at cc.arduino.Arduino$SerialProxy.<init>(Arduino.java:119)
- at cc.arduino.Arduino.<init>(Arduino.java:168)
- at cc.arduino.Arduino.<init>(Arduino.java:152)
- at sketch_121118a.setup(sketch_121118a.java:73)
- at processing.core.PApplet.handleDraw(PApplet.java:2103)
- at processing.opengl.PGL$PGLListener.display(PGL.java:2595)
- at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:189)
- at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:177)
- at javax.media.opengl.awt.GLCanvas$DisplayAction.run(GLCanvas.java:928)
- at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:425)
- at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:364)
- at javax.media.opengl.awt.GLCanvas$DisplayOnEventDispatchThreadAction.run(GLCanvas.java:945)
- at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
- at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:646)
- at java.awt.EventQueue.access$000(EventQueue.java:84)
- at java.awt.EventQueue$1.run(EventQueue.java:607)
- at java.awt.EventQueue$1.run(EventQueue.java:605)
- at java.security.AccessController.doPrivileged(Native Method)
- at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
- at java.awt.EventQueue.dispatchEvent(EventQueue.java:616)
- at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
- at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
- at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
- at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
- at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
- at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
- Already called beginDraw().
- Exception in thread "AWT-EventQueue-0" java.lang.IllegalAccessError: processing/core/PApplet$RegisteredMethods
- at cc.arduino.Arduino$SerialProxy.<init>(Arduino.java:119)
- at cc.arduino.Arduino.<init>(Arduino.java:168)
- at cc.arduino.Arduino.<init>(Arduino.java:152)
- at sketch_121118a.setup(sketch_121118a.java:73)
- at processing.core.PApplet.handleDraw(PApplet.java:2103)
- at processing.opengl.PGL$PGLListener.display(PGL.java:2595)
- at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:189)
- at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:177)
- at javax.media.opengl.awt.GLCanvas$DisplayAction.run(GLCanvas.java:928)
- at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:425)
- at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:364)
- at javax.media.opengl.awt.GLCanvas.maybeDoSingleThreadedWorkaround(GLCanvas.java:827)
- at javax.media.opengl.awt.GLCanvas.display(GLCanvas.java:415)
- at javax.media.opengl.awt.GLCanvas.paint(GLCanvas.java:515)
- at sun.awt.RepaintArea.paintComponent(RepaintArea.java:248)
- at sun.awt.RepaintArea.paint(RepaintArea.java:224)
- at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:308)
- at java.awt.Component.dispatchEventImpl(Component.java:4729)
- at java.awt.Component.dispatchEvent(Component.java:4481)
- at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:648)
- at java.awt.EventQueue.access$000(EventQueue.java:84)
- at java.awt.EventQueue$1.run(EventQueue.java:607)
- at java.awt.EventQueue$1.run(EventQueue.java:605)
- at java.security.AccessController.doPrivileged(Native Method)
- at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
- at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
- at java.awt.EventQueue$2.run(EventQueue.java:621)
- at java.awt.EventQueue$2.run(EventQueue.java:619)
- at java.security.AccessController.doPrivileged(Native Method)
- at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
- at java.awt.EventQueue.dispatchEvent(EventQueue.java:618)
- at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
- at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
- at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
- at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
- at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
- at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
1