Sound library does not work in Processing 4 - Python Mode

Hi, I just updated to Processing 4 and found the sound library stopped working with Python Mode. The Java mode worked fine. Any help is much appreciated.

add_library("sound")

sf = None
def setup():
    global sf
    sf = SoundFile(this, "boxiddngbell.mp3")
    sf.play()

Processing showed a ClassCastException as follows:

java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader ‘bootstrap’)
at jycessing.LibraryImporter.addJarToClassLoader(LibraryImporter.java:315)
at jycessing.LibraryImporter.recursivelyAddJarsToClasspath(LibraryImporter.java:164)
at jycessing.LibraryImporter.addLibrary(LibraryImporter.java:140)
at jycessing.LibraryImporter$1.call(LibraryImporter.java:82)
at org.python.core.PyObject.call(PyObject.java:480)
at org.python.core.PyObject.call(PyObject.java:484)
at org.python.pycode._pyx141.f$0(sketch_230215b.pyde:4)
at org.python.pycode._pyx141.call_function(sketch_230215b.pyde)
at org.python.core.PyTableCode.call(PyTableCode.java:171)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1614)
at org.python.core.Py.exec(Py.java:1658)
at org.python.pycode._pyx140.f$0(/Users/rguo/Documents/Processing/sketch_230215b/sketch_230215b.pyde:96)
at org.python.pycode._pyx140.call_function(/Users/rguo/Documents/Processing/sketch_230215b/sketch_230215b.pyde)
at org.python.core.PyTableCode.call(PyTableCode.java:171)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1614)
at org.python.core.Py.exec(Py.java:1658)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:276)
at jycessing.PAppletJythonDriver.processSketch(PAppletJythonDriver.java:233)
at jycessing.PAppletJythonDriver.findSketchMethods(PAppletJythonDriver.java:613)
at jycessing.Runner.runSketchBlocking(Runner.java:399)
at jycessing.mode.run.SketchRunner.lambda$2(SketchRunner.java:112)
at java.base/java.lang.Thread.run(Thread.java:833)

Hmm. Can’t load native code to bring window to front using the absolute path: /Users/rguo/Documents/Processing/modes/PythonMode/mode/libjniosx.dylib.
Hmm. Can’t load native code to bring window to front.

1 Like

Cheers, @guojian.ryan !

I’m afraid Python mode is mostly not working in Processing 4. You can try getting the Processing 3.5.4 IDE and see if the Sound library still works there.

I think I have tried it last year but I’m unsure. Some libraries like Serial stopped working on Python mode in certain platforms even on Processing 3 for some time now. It is unfortunate the Python mode project is looking for a new maintainer.for quite a while now.

I wish @GoToLoop could become the new Processing Python Mode maintainer :slight_smile:.