ModalityTeam/Modality-toolkit

Index out of range when using MKtl.find

kisielk opened this issue · 6 comments

Just installed the modality quark on SC 3.8. Stepping through the tutorial and upon running MKtl.find I get the following error in the console:

HID: found 5 devices.
MIDI Sources:
	MIDIEndPoint("16A", "LTC Sync", -1350521786)
	MIDIEndPoint("FaderPort", "FaderPort", -1744234616)
	MIDIEndPoint("mio10", "DIN 1", -846562422)
	MIDIEndPoint("mio10", "DIN 2", -1543287909)
	MIDIEndPoint("mio10", "DIN 3", 1382450164)
	MIDIEndPoint("mio10", "DIN 4", 1739041593)
	MIDIEndPoint("mio10", "DIN 5", 184938043)
	MIDIEndPoint("mio10", "DIN 6", -2044030891)
	MIDIEndPoint("mio10", "DIN 7", -937346613)
	MIDIEndPoint("mio10", "DIN 8", 374286964)
	MIDIEndPoint("mio10", "DIN 9", -1036816190)
	MIDIEndPoint("mio10", "DIN 10", 1150784474)
	MIDIEndPoint("mio10", "HST 1", 1499504737)
	MIDIEndPoint("mio10", "HST 2", -604032301)
	MIDIEndPoint("mio10", "HST 3", -1885865213)
	MIDIEndPoint("mio10", "HST 4-10", 730710501)
	MIDIEndPoint("mio10", "ETH 1-4", -506382473)
	MIDIEndPoint("mio10", "USB 2", 1183143406)
MIDI Destinations:
	MIDIEndPoint("FaderPort", "FaderPort", -1653003416)
	MIDIEndPoint("mio10", "DIN 1", -1116144245)
	MIDIEndPoint("mio10", "DIN 2", 185365741)
	MIDIEndPoint("mio10", "DIN 3", 2072244728)
	MIDIEndPoint("mio10", "DIN 4", 1557475687)
	MIDIEndPoint("mio10", "DIN 5", 1855480831)
	MIDIEndPoint("mio10", "DIN 6", -1651344616)
	MIDIEndPoint("mio10", "DIN 7", -172092456)
	MIDIEndPoint("mio10", "DIN 8", 323647511)
	MIDIEndPoint("mio10", "DIN 9", -1825066537)
	MIDIEndPoint("mio10", "DIN 10", 1413141011)
	MIDIEndPoint("mio10", "HST 1", 356405092)
	MIDIEndPoint("mio10", "HST 2", 1005760319)
	MIDIEndPoint("mio10", "HST 3", -242845081)
	MIDIEndPoint("mio10", "HST 4-10", -829524007)
	MIDIEndPoint("mio10", "ETH 1-4", 537248947)
	MIDIEndPoint("mio10", "USB 2", -267914625)
ERROR: Primitive '_ConnectMIDIIn' failed.
Index out of range.
RECEIVER:
class MIDIIn (0x11dc59a00) {
  instance variables [19]
    name : Symbol 'MIDIIn'
    nextclass : instance of Meta_MIDIMKtlDevice (0x11e73fe80, size=19, set=5)
    superclass : Symbol 'Object'
    subclasses : nil
    methods : nil
    instVarNames : instance of SymbolArray (0x11dc59b80, size=1, set=2)
    classVarNames : instance of SymbolArray (0x11dc59d00, size=21, set=4)
    iprototype : instance of Array (0x11dc59c40, size=1, set=2)
    cprototype : instance of Array (0x11dc59e80, size=21, set=5)
    constNames : nil
    constValues : nil
    instanceFormat : Integer 0
    instanceFlags : Integer 0
    classIndex : Integer 350
    classFlags : Integer 0
    maxSubclassIndex : Integer 350
    filenameSymbol : Symbol '/Applications/SuperCollider.app/Contents/Resources/SCClassLibrary/Common/Control/MIDIOut.sc'
    charPos : Integer 2982
    classVarIndex : Integer 236
}
CALL STACK:
	MethodError:reportError   0x11ee56e28
		arg this = <instance of PrimitiveFailedError>
	Nil:handleError   0x11ee7f008
		arg this = nil
		arg error = <instance of PrimitiveFailedError>
	Thread:handleError   0x11ee47858
		arg this = <instance of Thread>
		arg error = <instance of PrimitiveFailedError>
	Object:throw   0x11ee7ea88
		arg this = <instance of PrimitiveFailedError>
	Object:primitiveFailed   0x11cd76b58
		arg this = <instance of Meta_MIDIIn>
	Meta_MIDIIn:connect   0x11fbd6a98
		arg this = <instance of Meta_MIDIIn>
		arg inport = 16
		arg device = <instance of MIDIEndPoint>
		var uid = -506382473
		var source = nil
	ArrayedCollection:do   0x11ee53ca8
		arg this = [*18]
		arg function = <instance of Function>
		var i = 16
	Meta_MIDIIn:connectAll   0x11ee44fc8
		arg this = <instance of Meta_MIDIIn>
		arg verbose = true
	Meta_MIDIMKtlDevice:initDevices   0x11ea35e48
		arg this = <instance of Meta_MIDIMKtlDevice>
		arg force = true
	Meta_MIDIMKtlDevice:find   0x11cd76898
		arg this = <instance of Meta_MIDIMKtlDevice>
		arg post = false
	ArrayedCollection:do   0x123049848
		arg this = [*3]
		arg function = <instance of Function>
		var i = 1
	Meta_MKtlDevice:find   0x123049378
		arg this = <instance of Meta_MKtlDevice>
		arg protocols = nil
		arg post = false
	Meta_MKtl:find   0x123049fd8
		arg this = <instance of Meta_MKtl>
		arg protocols = nil
	Interpreter:interpretPrintCmdLine   0x11f2db928
		arg this = <instance of Interpreter>
		var res = nil
		var func = <instance of Function>
		var code = "MKtl.find"
		var doc = nil
		var ideClass = <instance of Meta_ScIDE>
	Process:interpretPrintCmdLine   0x12304ad98
		arg this = <instance of Main>
^^ The preceding error dump is for ERROR: Primitive '_ConnectMIDIIn' failed.
Index out of range.
RECEIVER: MIDIIn

hi @kisielk,
this is on linux, yes?

  • Is there a way to reduce the number of MIDI sources/destinations that the system sees before initializing MIDI? (I am guessing you are not using all of them)
  • Do you get the same error when you do this:
MIDIIn.connectAll; 

Oh sorry, forgot to mention. It's on OSX Yosemite.

I'm actually using around half of those MIDI ports (though not necessarily always in SC...). I'm not sure there's a way on the mio10 to disable some ports from being seen by the OS or not. I tried MIDIIin.connectAll and indeed it seems the problem is there.

Interesting thing is, when I use MIDIIn.connectAll there's still mention of MKtl in the stack trace:

MIDI Sources:
    MIDIEndPoint("16A", "LTC Sync", -1350521786)
    MIDIEndPoint("FaderPort", "FaderPort", -1744234616)
    MIDIEndPoint("mio10", "DIN 1", -846562422)
    MIDIEndPoint("mio10", "DIN 2", -1543287909)
    MIDIEndPoint("mio10", "DIN 3", 1382450164)
    MIDIEndPoint("mio10", "DIN 4", 1739041593)
    MIDIEndPoint("mio10", "DIN 5", 184938043)
    MIDIEndPoint("mio10", "DIN 6", -2044030891)
    MIDIEndPoint("mio10", "DIN 7", -937346613)
    MIDIEndPoint("mio10", "DIN 8", 374286964)
    MIDIEndPoint("mio10", "DIN 9", -1036816190)
    MIDIEndPoint("mio10", "DIN 10", 1150784474)
    MIDIEndPoint("mio10", "HST 1", 1499504737)
    MIDIEndPoint("mio10", "HST 2", -604032301)
    MIDIEndPoint("mio10", "HST 3", -1885865213)
    MIDIEndPoint("mio10", "HST 4-10", 730710501)
    MIDIEndPoint("mio10", "ETH 1-4", -506382473)
    MIDIEndPoint("mio10", "USB 2", 1183143406)
MIDI Destinations:
    MIDIEndPoint("FaderPort", "FaderPort", -1653003416)
    MIDIEndPoint("mio10", "DIN 1", -1116144245)
    MIDIEndPoint("mio10", "DIN 2", 185365741)
    MIDIEndPoint("mio10", "DIN 3", 2072244728)
    MIDIEndPoint("mio10", "DIN 4", 1557475687)
    MIDIEndPoint("mio10", "DIN 5", 1855480831)
    MIDIEndPoint("mio10", "DIN 6", -1651344616)
    MIDIEndPoint("mio10", "DIN 7", -172092456)
    MIDIEndPoint("mio10", "DIN 8", 323647511)
    MIDIEndPoint("mio10", "DIN 9", -1825066537)
    MIDIEndPoint("mio10", "DIN 10", 1413141011)
    MIDIEndPoint("mio10", "HST 1", 356405092)
    MIDIEndPoint("mio10", "HST 2", 1005760319)
    MIDIEndPoint("mio10", "HST 3", -242845081)
    MIDIEndPoint("mio10", "HST 4-10", -829524007)
    MIDIEndPoint("mio10", "ETH 1-4", 537248947)
    MIDIEndPoint("mio10", "USB 2", -267914625)
ERROR: Primitive '_ConnectMIDIIn' failed.
Index out of range.
RECEIVER:
class MIDIIn (0x113724a00) {
  instance variables [19]
    name : Symbol 'MIDIIn'
    nextclass : instance of Meta_MIDIMKtlDevice (0x11420ae80, size=19, set=5)
    superclass : Symbol 'Object'
    subclasses : nil
    methods : nil
    instVarNames : instance of SymbolArray (0x113724b80, size=1, set=2)
    classVarNames : instance of SymbolArray (0x113724d00, size=21, set=4)
    iprototype : instance of Array (0x113724c40, size=1, set=2)
    cprototype : instance of Array (0x113724e80, size=21, set=5)
    constNames : nil
    constValues : nil
    instanceFormat : Integer 0
    instanceFlags : Integer 0
    classIndex : Integer 350
    classFlags : Integer 0
    maxSubclassIndex : Integer 350
    filenameSymbol : Symbol '/Applications/SuperCollider.app/Contents/Resources/SCClassLibrary/Common/Control/MIDIOut.sc'
    charPos : Integer 2982
    classVarIndex : Integer 236
}
CALL STACK:
    MethodError:reportError   0x118175008
        arg this = <instance of PrimitiveFailedError>
    Nil:handleError   0x1181750b8
        arg this = nil
        arg error = <instance of PrimitiveFailedError>
    Thread:handleError   0x118174b38
        arg this = <instance of Thread>
        arg error = <instance of PrimitiveFailedError>
    Object:throw   0x118174df8
        arg this = <instance of PrimitiveFailedError>
    Object:primitiveFailed   0x118175218
        arg this = <instance of Meta_MIDIIn>
    Meta_MIDIIn:connect   0x1158daa68
        arg this = <instance of Meta_MIDIIn>
        arg inport = 16
        arg device = <instance of MIDIEndPoint>
        var uid = -506382473
        var source = nil
    ArrayedCollection:do   0x118175378
        arg this = [*18]
        arg function = <instance of Function>
        var i = 16
    Meta_MIDIIn:connectAll   0x1188404e8
        arg this = <instance of Meta_MIDIIn>
        arg verbose = true
    Interpreter:interpretPrintCmdLine   0x11591f588
        arg this = <instance of Interpreter>
        var res = nil
        var func = <instance of Function>
        var code = "MIDIIn.connectAll"
        var doc = nil
        var ideClass = <instance of Meta_ScIDE>
    Process:interpretPrintCmdLine   0x118840598
        arg this = <instance of Main>
^^ The preceding error dump is for ERROR: Primitive '_ConnectMIDIIn' failed.
Index out of range.
RECEIVER: MIDIIn

Ok, last one is a red herring.. I removed the quark and it still fails, so seems this is an SC bug.

yes, it seems the mention in MIDIIn class nextClass only comes from alphabetic order of all classes.

can you report it to supercollider/supercollider/issues? and crosslink here?
guesssing - the error happens after the 17th destination,
so maybe the destinations array is inited with size 16 and then fails.

We managed to track down the problem to there being a hardcoded limit of 16 MIDI devices, see supercollider/supercollider#2492