Has anyone gotten the midibus library to work with the new Processing 4.0 release? Any of my old code with that library recognizes available midi devices but then throws a NullPointer Exception every time. Works fine in the older version. Would really appreciate it if someone can confirm the error or give me tips on rectifying it. Thanks.
Hi @justin_lincoln – what is the specific error you are getting, on what kind of line? Can you give a very simple example sketch? That would really help narrow things down if someone wanted to start investigating your problem.
Hey y’all! Can confirm that I’m replicating the error @justin_lincoln reports. Doesn’t require anything fancy to run into the issue, just a simple attempt to initialize a new MidiBus throws the NullPointerException:
import themidibus.*;
MidiBus NK2;
void setup() {
fullScreen();
NK2 = new MidiBus(this, "SLIDER/KNOB", 2);
}
Attempting to run this will flag line 7 (NK2 = …) and throw 5 "NullPointerException"s in the dialog box.
I have several projects that would run just fine with this syntax in Processing 3 that are displaying this behavior now in Processing 4.
same here on the 4.0 beta1,
also tested again on 3.5.4 and everything still works there
Hey there – ran into this soon after the P4 launch.
Version 4.0b2 does not seam to address this issue.
here is what i get in the console –>
java.lang.NullPointerException
at themidibus.MidiBus.toString(Unknown Source)
at java.base/java.lang.String.valueOf(String.java:2951)
at processing.core.PApplet.registerNoArgs(PApplet.java:1499)
at processing.core.PApplet.registerMethod(PApplet.java:1479)
at themidibus.MidiBus.registerParent(Unknown Source)
at themidibus.MidiBus.init(Unknown Source)
at themidibus.MidiBus.<init>(Unknown Source)
at Act_00_xyGridPhaser.setup(Act_00_xyGridPhaser.java:56)
at processing.core.PApplet.handleDraw(PApplet.java:2151)
at processing.opengl.PSurfaceJOGL$DrawListener.display(PSurfaceJOGL.java:894)
at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:692)
at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:674)
at jogamp.opengl.GLAutoDrawableBase$2.run(GLAutoDrawableBase.java:443)
at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1293)
at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1147)
at com.jogamp.newt.opengl.GLWindow.display(GLWindow.java:782)
at com.jogamp.opengl.util.AWTAnimatorImpl.display(AWTAnimatorImpl.java:81)
at com.jogamp.opengl.util.AnimatorBase.display(AnimatorBase.java:453)
at com.jogamp.opengl.util.FPSAnimator$MainTask.run(FPSAnimator.java:178)
at java.base/java.util.TimerThread.mainLoop(Timer.java:556)
at java.base/java.util.TimerThread.run(Timer.java:506)
noob here but my guess is as good as any so: the parent does not get initialised properly…
PS: running it from the console (processing-java installed via version 4)
i get the same NullPointerExeption
running it with the processing-java installed via Version 3 it works as expected
The October version still doesn’t recognize themidiBus . It shows options but doesn’t seem to initialize.
@onebus @kaos @garretconour @justin_lincoln
Try using the .jar from here
Brilliant! That.jar did the trick. Thank you so much!
Rad. That did it. Thanks!
Hi forum,
Can anyone help with this NPE error?
java.lang.NullPointerException: Cannot invoke “java.lang.reflect.Method.invoke(Object, Object[])” because the return value of “java.util.Map.get(Object)” is null
at processing.core.PApplet$RegisteredMethods.handle(PApplet.java:1361)
at processing.core.PApplet.handleMethods(PApplet.java:1515)
at processing.core.PApplet.dispose(PApplet.java:3548)
at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:403)
I’m using this framework along with midibus: GitHub - thomascastleman/midi-visualizer-framework: A generalized framework that can be used to easily create visualizations of MIDI input using Processing and the Midibus library
I have gotten it to work fine while executing a sketch but I get the NPE when exiting/quiting the sketch. Does anyone know what could be causing it? I I tried using the fix provided here and changed my midibus library .jar file. But that didn’t fix the quit NPE. The sketch build just hangs until I force quit it.
Thanks for the help.
Hi,
Manually disposing the midibus object seems to fix the NullPointerException:
void dispose(){
println("stopping...");
myBus.dispose();
println("bye");
}
Hi - I had the same error and .dispose() did not work for me, but clearAll() did.
void keyPressed()
{
if (key == ESC)
key=0;
if (key == 0)
{
myBus.clearAll();
delay(1000);
exit();
}
}
I don’t know if the delay is necessary but yeah.
The .jar is not working on M1 Pro. Is there a solution for Apple Silicon computers?
Well TheMidibus works on my iMac that has an M1 processor in it.
Not sure about that Jar, I am running it in Processing 4 and I don’t seem to have a problem with it.
Although I am not running the absolute latest version of Processing. I am using Processing 4.2.
Ohhh I fgured it out, the .jar goes in /libraries/themidibus/library I thought it had to be installed to the system aha.
Couldn’t get themidibus to work on M1 or Windows without doing that. Phew. Perhaps if you have an older version of java it would work without it? Dunno, but glad its working now.
this might be useful too:
Thanks a lot for your code.
I’m also trying to switch to Java MIDI in processing after having too much trouble with MidiBus on Mac, and I managed to find MIDI devices receivers and transmitters, but I have no idea how to detect MIDI events coming from a transmitter, (to be able to display data when a key is pressed on a MIDI keyboard, for instance) like MidiBus’ noteOn, noteOff, or midiMessage functions do.
I don’t understand Java very well, and so far, I couldn’t find a way to understand how to do that from all the research I’ve done on the subject. Does anyone around here know how to do that ?
What sort of MIDI keyboard to you have? That is, is it connected by 5 Pin DIN connectors or by USB connection?
This will change the code and maybe the hardware, you need to do this.
Oh thanks for replying so soon.
I have a MIDI keyboard connected via USB, so Java Midi can detect it quite easily as a midi device and register it as a transmitter, with its name and everything (I also have USB-connected synths and I know how to register them and get their receivers as well).
So far, I understood what to do.
I’m just totally confused about how I can receive data when it comes from the MIDI keyboard (note sent or controller change, etc) so I can (for instance) println() this data, the way I would have done that with the noteOn, noteOff or midiMessage functions if I used the MidiBus.
I guess it requires to create a “listener” attached to that transmitter, but as I’m really not familiar with Java syntax and I don’t understand well how to integrate that in Processing code, I’m really lost…
So why do you not use it?
This issue has been fixed in Processing 4.2 and onward, so there is no need to apply a java fix anymore. Just use the MidiBus.