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

1 Like

same here on the 4.0 beta1,
also tested again on 3.5.4 and everything still works there

2 Likes

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

3 Likes

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.