musikinformatik / SuperDirt

Tidal Audio Engine
GNU General Public License v2.0
520 stars 74 forks source link

MIDI not working #180

Closed yaxu closed 4 years ago

yaxu commented 4 years ago

The problem seems to be introduced here: https://github.com/musikinformatik/SuperDirt/commit/90866bbf473bf9fdaa24ba46d6d73489873cfa6d

Running a simple once $ n 0 # s "midi" gives:

ERROR: Message 'asInteger' not understood.
RECEIVER:
   nil
ARGS:
CALL STACK:
    DoesNotUnderstandError:reportError
        arg this = <instance of DoesNotUnderstandError>
    Nil:handleError
        arg this = nil
        arg error = <instance of DoesNotUnderstandError>
    Thread:handleError
        arg this = <instance of Thread>
        arg error = <instance of DoesNotUnderstandError>
    Object:throw
        arg this = <instance of DoesNotUnderstandError>
    Object:doesNotUnderstand
        arg this = nil
        arg selector = 'asInteger'
        arg args = [*0]
    MIDIOut:noteOn
        arg this = <instance of MIDIOut>
        arg chan = nil
        arg note = 60
        arg veloc = 64
    Function:awake
        arg this = <instance of Function>
        arg beats = 45.184081564692
        arg seconds = 45.184081564692
        arg clock = <instance of Meta_SystemClock>
        var time = 45.184081564692
^^ The preceding error dump is for ERROR: Message 'asInteger' not understood.
RECEIVER: nil

ERROR: Selector not a Symbol :
ERROR: Primitive '_ObjectPerformList' failed.
Wrong type.
RECEIVER:
Instance of MIDIOut {    (0x56171cc067d8, gc=1C, fmt=00, flg=00, set=02)
  instance variables [3]
    port : Integer 0
    uid : Integer 917504
    latency : Integer 0
}
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>
    Object:primitiveFailed
        arg this = <instance of MIDIOut>
    Function:awake
        arg this = <instance of Function>
        arg beats = 45.184081564692
        arg seconds = 45.184081564692
        arg clock = <instance of Meta_SystemClock>
        var time = 45.184081564692
^^ The preceding error dump is for ERROR: Primitive '_ObjectPerformList' failed.
Wrong type.
RECEIVER: a MIDIOut

ERROR: Message 'asInteger' not understood.
RECEIVER:
   nil
ARGS:
CALL STACK:
    DoesNotUnderstandError:reportError
        arg this = <instance of DoesNotUnderstandError>
    Nil:handleError
        arg this = nil
        arg error = <instance of DoesNotUnderstandError>
    Thread:handleError
        arg this = <instance of Thread>
        arg error = <instance of DoesNotUnderstandError>
    Object:throw
        arg this = <instance of DoesNotUnderstandError>
    Object:doesNotUnderstand
        arg this = nil
        arg selector = 'asInteger'
        arg args = [*0]
    MIDIOut:noteOff
        arg this = <instance of MIDIOut>
        arg chan = nil
        arg note = 60
        arg veloc = 64
    Function:awake
        arg this = <instance of Function>
        arg beats = 46.294192728785
        arg seconds = 46.294192728785
        arg clock = <instance of Meta_SystemClock>
        var time = 46.294192728785
^^ The preceding error dump is for ERROR: Message 'asInteger' not understood.
RECEIVER: nil
telephon commented 4 years ago

In the first error, the ~midichan seems to be nil, but I have no clue who this can be. You can set the receiveAction to post the received value:

~dirt.receiveAction = { |x| x.postcs }; // postcs will post the full compile string

In the second error, midicmd seems to be not a symbol as it should, but probably nil or 0. Also this should feature in the message sent from tidal ...

Maybe some time we should make the API clearer and check for it.

yaxu commented 4 years ago

Thanks, here's what is received:

( 'n': 0.0, 's': 'midi', 'cycle': 0.0, 'cps': 0.89999997615814, 
  'delta': 1.111111164093, 'latency': 0.18455786288996 )

midichan should default to 0: https://github.com/musikinformatik/SuperDirt/blob/90866bbf473bf9fdaa24ba46d6d73489873cfa6d/classes/DirtEventTypes.sc#L55

midicmd should in common cases be inferred by the message. But in the case of notes it isn't used at all. Instead

For completeness here's the error again but using the head of the develop branch, although it looks much the same to me.

ERROR: Message 'asInteger' not understood.
RECEIVER:
   nil
ARGS:
CALL STACK:
    DoesNotUnderstandError:reportError
        arg this = <instance of DoesNotUnderstandError>
    Nil:handleError
        arg this = nil
        arg error = <instance of DoesNotUnderstandError>
    Thread:handleError
        arg this = <instance of Thread>
        arg error = <instance of DoesNotUnderstandError>
    Object:throw
        arg this = <instance of DoesNotUnderstandError>
    Object:doesNotUnderstand
        arg this = nil
        arg selector = 'asInteger'
        arg args = [*0]
    MIDIOut:noteOn
        arg this = <instance of MIDIOut>
        arg chan = nil
        arg note = 60
        arg veloc = 64
    Function:awake
        arg this = <instance of Function>
        arg beats = 8241.2761779299
        arg seconds = 8241.2761779299
        arg clock = <instance of Meta_SystemClock>
        var time = 8241.2761779299
^^ The preceding error dump is for ERROR: Message 'asInteger' not understood.
RECEIVER: nil

ERROR: Selector not a Symbol :
ERROR: Primitive '_ObjectPerformList' failed.
Wrong type.
RECEIVER:
Instance of MIDIOut {    (0x56171ce10148, gc=64, fmt=00, flg=00, set=02)
  instance variables [3]
    port : Integer 0
    uid : Integer 917504
    latency : Integer 0
}
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>
    Object:primitiveFailed
        arg this = <instance of MIDIOut>
    Function:awake
        arg this = <instance of Function>
        arg beats = 8241.2761779299
        arg seconds = 8241.2761779299
        arg clock = <instance of Meta_SystemClock>
        var time = 8241.2761779299
^^ The preceding error dump is for ERROR: Primitive '_ObjectPerformList' failed.
Wrong type.
RECEIVER: a MIDIOut

ERROR: Message 'asInteger' not understood.
RECEIVER:
   nil
ARGS:
CALL STACK:
    DoesNotUnderstandError:reportError
        arg this = <instance of DoesNotUnderstandError>
    Nil:handleError
        arg this = nil
        arg error = <instance of DoesNotUnderstandError>
    Thread:handleError
        arg this = <instance of Thread>
        arg error = <instance of DoesNotUnderstandError>
    Object:throw
        arg this = <instance of DoesNotUnderstandError>
    Object:doesNotUnderstand
        arg this = nil
        arg selector = 'asInteger'
        arg args = [*0]
    MIDIOut:noteOff
        arg this = <instance of MIDIOut>
        arg chan = nil
        arg note = 60
        arg veloc = 64
    Function:awake
        arg this = <instance of Function>
        arg beats = 8242.386289094
        arg seconds = 8242.386289094
        arg clock = <instance of Meta_SystemClock>
        var time = 8242.386289094
^^ The preceding error dump is for ERROR: Message 'asInteger' not understood.
RECEIVER: nil
yaxu commented 4 years ago

I think I found it, just an initialisation problem