Does TheMidibus Library work in Processing 4?

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.

1 Like

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() {
  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.

1 Like

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 –>

	at themidibus.MidiBus.toString(Unknown Source)
	at java.base/java.lang.String.valueOf(
	at processing.core.PApplet.registerNoArgs(
	at processing.core.PApplet.registerMethod(
	at themidibus.MidiBus.registerParent(Unknown Source)
	at themidibus.MidiBus.init(Unknown Source)
	at themidibus.MidiBus.<init>(Unknown Source)
	at Act_00_xyGridPhaser.setup(
	at processing.core.PApplet.handleDraw(
	at processing.opengl.PSurfaceJOGL$DrawListener.display(
	at jogamp.opengl.GLDrawableHelper.displayImpl(
	at jogamp.opengl.GLDrawableHelper.display(
	at jogamp.opengl.GLAutoDrawableBase$
	at jogamp.opengl.GLDrawableHelper.invokeGLImpl(
	at jogamp.opengl.GLDrawableHelper.invokeGL(
	at com.jogamp.newt.opengl.GLWindow.display(
	at com.jogamp.opengl.util.AWTAnimatorImpl.display(
	at com.jogamp.opengl.util.AnimatorBase.display(
	at com.jogamp.opengl.util.FPSAnimator$
	at java.base/java.util.TimerThread.mainLoop(
	at java.base/

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(
at processing.core.PApplet.handleMethods(
at processing.core.PApplet.dispose(
at processing.core.PSurfaceNone$

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.


Manually disposing the midibus object seems to fix the NullPointerException:

void dispose(){

Hi - I had the same error and .dispose() did not work for me, but clearAll() did.

void keyPressed()
  if (key == ESC)
  if (key == 0)

I don’t know if the delay is necessary but yeah.