PortMidi / portmidi

portmidi is a cross-platform MIDI input/output library
Other
129 stars 34 forks source link

Note-On events with a velocity of zero are converted into note-off events with a velocity of 40? #35

Closed iluvcapra closed 2 years ago

iluvcapra commented 2 years ago

On an Output port I'm sending:

In [14]: output.write([[[0x90,0x00,0x00], pygame.midi.time()]])

On an Input port I'm receiving:

In [12]: while True:
    ...:     if input.poll():
    ...:         data = input.read(64)[0]
    ...:         print("%x: %x: %x" % (data[0][0], data[0][1], data[0][2]))
    ...:

80: 0: 40

(Both ends are connecting through a CoreMIDI IAC buss)

This has been noticed in other software, particularly

and there seems to be some dispute as to wether they should be transformed or not. For my particular application I need to be able to see these events how they're sent ideally, I'm writing an MIDI control surface emulator that uses them.

rbdannenberg commented 2 years ago

There's nothing in PortMidi that does that, so it must be CoreMIDI. If CoreMIDI changes the data, there's no reasonable way that PortMidi can recover the original bytes. If Apple does this, maybe the only "safe" way to use MIDI is to assume the transmission channel is allowed to transform NOTE-ON with velocity zero. I would bet that NOTE-OFF is never transformed because that would lose velocity information (rather than insert it). So maybe the best way to get out what you put in is to always send NOTE-OFF messages to turn notes off.

iluvcapra commented 2 years ago

Yeah I don't doubt it's CoreMidi's doing, I don't really have a choice as to how these messages can be formatted, the protocol is the protocol.

rbdannenberg commented 2 years ago

Yes, I think it's really a mistake in CoreMIDI -- it seems to me that general systems experience and wisdom argues against wiring semantics into a low-level transport.