MIDIClient.init() fails on Ubuntu 23.04

On a fresh install of Ubuntu 23.04 desktop, running SuperCollider 3.13.0, I get an error when running the line MIDIClient.init();, see below.

Is anyone else experiencing the same thing, or could you reproduce the error? Probably something has gone missing in the move to PipeWire that was there before, e.g. some ALSA MIDI component? puredata on the same machine can use MIDI fine if I switch from ALSA to OSS MIDI.

Cheers,
Ludvig

ERROR: A primitive was not bound. 0 854
Instance of Method {    (0x555dad77e340, gc=01, fmt=00, flg=11, set=04)
  instance variables [15]
    raw1 : Float 0.000000   00000000 0060000C
    raw2 : Float 0.000000   00000100 01000001
    code : instance of Int8Array (0x555dad77e4c0, size=4, set=2)
    selectors : nil
    constants : nil
    prototypeFrame : instance of Array (0x555dab2497c0, size=1, set=2)
    context : nil
    argNames : instance of SymbolArray (0x555dab249880, size=1, set=2)
    varNames : nil
    sourceCode : nil
    ownerClass : class Meta_MIDIClient (0x555dad77aa00)
    name : Symbol 'prInitClient'
    primitiveName : Symbol '_InitMIDIClient'
    filenameSymbol : Symbol '/usr/local/share/SuperCollider/SCClassLibrary/Common/Control/MIDIOut.sc'
    charPos : Integer 1973
}
ERROR: Primitive '__none' failed.
Failed.
RECEIVER:
   nil
PATH: test.scd

PROTECTED CALL STACK:
	Meta_MethodError:new	0x555dac9ec500
		arg this = PrimitiveFailedError
		arg what = Failed.
		arg receiver = nil
	Meta_PrimitiveFailedError:new	0x555dac9f4440
		arg this = PrimitiveFailedError
		arg receiver = nil
	Object:primitiveFailed	0x555dac1a1f40
		arg this = nil
	Meta_MIDIClient:init	0x555dad77bbc0
		arg this = MIDIClient
		arg inports = nil
		arg outports = nil
		arg verbose = true
	a FunctionDef	0x555dac8fa9c0
		sourceCode = "<an open Function>"
	Function:prTry	0x555dacc78840
		arg this = a Function
		var result = nil
		var thread = a Thread
		var next = nil
		var wasInProtectedFunc = false
	
CALL STACK:
	MethodError:reportError
		arg this = <instance of PrimitiveFailedError>
	Nil:handleError
		arg this = nil
		arg error = <instance of PrimitiveFailedError>
	Thread:handleError
		arg this = <instance of Thread>
		arg error = <instance of PrimitiveFailedError>
	Object:throw
		arg this = <instance of PrimitiveFailedError>
	Function:protect
		arg this = <instance of Function>
		arg handler = <instance of Function>
		var result = <instance of PrimitiveFailedError>
	Interpreter:executeFile
		arg this = <instance of Interpreter>
		arg pathName = "test.scd"
		arg args = [*0]
		var result = nil
		var saveExecutingPath = nil
	Process:interpretCmdLine
		arg this = <instance of Main>
^^ The preceding error dump is for ERROR: Primitive '__none' failed.
Failed.
RECEIVER: nil

Have you installed pipewire-alsa?

The pipewire-alsa package is installed on the system, but I am not clear on how to enable and or configure it in PipeWire. I will keep searching for more information on the MIDI side of ALSA.

I was mostly interested if this is expected behavior and some action is needed from the user to make MIDI work or if there was some particular issues with my machine and/or installation.

A rather crucial question here is: how did you install SC 3.13.0?

I’m not on Ubuntu 23, but rather Ubuntu Studio 22.04. SuperCollider is packaged at 3.11, not 3.13.

If you built it yourself, then you’d need to satisfy the build dependencies, one of which is “libasound2-dev” for the ALSA dev libraries.

Sclang does use ALSA for MIDI. Even if you aren’t using ALSA for audio, you do need it for MIDI.

hjh

I did build it myself, following the instructions from the Wiki I also installed the dependencies, and I had no complaints from the build process. The MIDI issue is the only issue I have, besides that everything runs well.

I am mostly wondering if this is expected behavior on 23.04 or if something is faulty on my particular install, and it is sounding like I indeed need to configure the ALSA-MIDI plugin for PipeWire to make MIDI work in SuperCollider.

I compiled the development version and I can reproduce the error. I also didn’t do any special with ALSA configuration.

Then I think MIDI out of the box on regular Ubuntu is not working. I will try to setup the ALSA-MIDI plugin for PipeWire and report back with the necessary steps if it resolves the issue.

Ok… What’s your cmake … -L output, from inside your build directory?

hjh

Aha, good catch! Indeed, I see:
-- Could NOT find ALSA (missing: ALSA_LIBRARY ALSA_INCLUDE_DIR)

So I would also need to install something before compiling then, possibly in addition to setting up the ALSA-MIDI-plugin for PipeWire.

It “should” be libasound2-dev but possibly the packaging has changed in Ubuntu 23. I haven’t investigated that.

hjh

Indeed, this solved the problem. Thank you for your help.