Has anyone any suggestions as to why I could be getting an error from MIDIClient.init, whilst MIDIClient.sources works fine? MIDIClient.init was working fine earlier, and then it just stopped. I’ve restarted SC, the external synth, and a few other things like checked the USB connections (but as you see MIDIClient.sources sees the synth fine).

MIDIClient.sources -> [ MIDIEndPoint("Rev2", "Rev2") ]


MIDIClient.init gives:

Could not create MIDI port in0
. error -50
ERROR: Primitive '_InitMIDI' failed.
class MIDIClient (0x11be8a300) {
  instance variables [19]
    name : Symbol 'MIDIClient'
    nextclass : instance of Meta_MIDIClockOut (0x11bfd6740, size=19, set=5)
    superclass : Symbol 'Object'
    subclasses : nil
    methods : nil
    instVarNames : nil
    classVarNames : instance of SymbolArray (0x11be8a480, size=5, set=2)
    iprototype : nil
    cprototype : instance of Array (0x11be8a540, size=5, set=3)
    constNames : nil
    constValues : nil
    instanceFormat : Integer 0
    instanceFlags : Integer 0
    classIndex : Integer 107
    classFlags : Integer 0
    maxSubclassIndex : Integer 107
    filenameSymbol : Symbol '/private/var/folders/66/ygfzz9lj65ngztv9l_hwp5sw0000gn/T/AppTranslocation/8CC31C2F-125F-47F4-917E-48E842B0691A/d/SuperCollider.app/Contents/Resources/SCClassLibrary/Common/Control/MIDIOut.sc'
    charPos : Integer 212
    classVarIndex : Integer 548
PATH: /Users/admin/Desktop/recordBuf.scd
		arg this = <instance of PrimitiveFailedError>
		arg this = nil
		arg error = <instance of PrimitiveFailedError>
		arg this = <instance of Thread>
		arg error = <instance of PrimitiveFailedError>
		arg this = <instance of PrimitiveFailedError>
		arg this = <instance of Meta_MIDIClient>
		arg this = <instance of Meta_MIDIClient>
		arg inports = 1
		arg outports = 1
		arg verbose = true
		arg this = <instance of Interpreter>
		var res = nil
		var func = <instance of Function>
		var code = "MIDIClient.init;"
		var doc = nil
		var ideClass = <instance of Meta_ScIDE>
		arg this = <instance of Main>
^^ The preceding error dump is for ERROR: Primitive '_InitMIDI' failed.

Thanks in advance - joesh

I’m a bit out of my area because this is Mac.

(By the way, for MIDI issues, it’s very helpful to mention the OS because the MIDI backend is different for the three OSes: macOS = SC_CoreMIDI.cpp, Linux = SC_AlsaMIDI.cpp, Windows = SC_PortMIDI.cpp.)

In any case, I believe the problem is something external to SC. SC is calling the CoreMIDI function MIDIInputPortCreate() and getting an error code. So, for some reason, you were not getting the error code before, and now you are.

Does Audio MIDI Setup have some command to reset the MIDI subsystem? Or maybe reboot? Clear something from OS user preferences (maybe some bad data are cached in a plist somewhere)?

Sorry I don’t have a specific idea…

As for sources being OK (or, not empty) – the primitive, before returning its own failed error code, sets the number of inputs that have been successfully initialized. So it’s possible for some MIDI sources to succeed before the error, and AFAICS those will be preserved in the sources array.