Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to create more than 1 MIDI PortIn or PortOut #9893

Open
probonopd opened this issue Dec 16, 2024 · 5 comments
Open

Ability to create more than 1 MIDI PortIn or PortOut #9893

probonopd opened this issue Dec 16, 2024 · 5 comments

Comments

@probonopd
Copy link

probonopd commented Dec 16, 2024

Thanks for this library which allowed me to prototype a MIDI controller rapidly.

Some MIDI controllers expose more than one MIDI interface, and I need to recreate that using Adafruit_CircuitPython_MIDI on a Raspberry Pi Pico.

However,

//| """You cannot create an instance of `usb_midi.PortOut`.
//|
//| PortOut objects are constructed for every corresponding entry in the USB
//| descriptor and added to the ``usb_midi.ports`` tuple."""

The same goes for usb_midi.PortIn.

It would be extremely useful if it was possible to create more than one MIDI interface per direction.

If that is not possible, then being able to choose the MIDI "cable number" would already be helpful.

References:

@dhalbert
Copy link
Collaborator

The current MIDI descriptor we use is here: https://github.com/adafruit/circuitpython/blob/main/shared-module/usb_midi/__init__.c

To construct this dynamically would be a lot of code, and would not fit on some smaller boards that currently provide MIDI. An alternative would be to let the user supply their own descriptor, or some part of it. We allow that for custom HID devices.

If you could record and supply the fancier USB MIDI descriptor from an Arturia device, that would be helpful. Having said that, this is the first time we've gotten a request for fancier MIDI, so this would be a long-term project. We would welcome a generalized PR if anyone is interested in working on this.

@probonopd
Copy link
Author

probonopd commented Dec 17, 2024

Thanks @dhalbert. All I am looking for is to have 2 MIDI PortIn and 2 PortOut instead of 1 each, on the Pi Pico.

Currently I have:

midi = adafruit_midi.MIDI(midi_in=usb_midi.ports[0], midi_out=usb_midi.ports[1], in_channel=0, out_channel=0, in_buf_size=512, debug=debugging_on)

I would like to add:

midi1 = adafruit_midi.MIDI(midi_in=usb_midi.ports[2], midi_out=usb_midi.ports[3], in_channel=0, out_channel=0, in_buf_size=512, debug=debugging_on)

In other words, I would like to also have usb_midi.ports[2] and midi_out=usb_midi.ports[3].

So are you saying that this would currently require rebuilding CircuitPython in C?

I don't have an Arturia device at hand.

@probonopd
Copy link
Author

probonopd commented Dec 18, 2024

If that is not possible, then being able to choose the MIDI "cable number" would already be helpful.

Looks like all I'd need is a way, from Python, to change the 0 to 1 there, and I would be sending on cable 1 rather than cable 0:

return tud_midi_stream_write(0, data, len);

Unfortunately, there is currently no way to do that from Python, is there?
How much of an effort would it be to make this changeable from the Python side?

@dhalbert
Copy link
Collaborator

The current USB MIDI descriptor is fixed, and describes one MIDI device with two ports, one In and one Out. Do you want one device with four ports, two In and two Out? Or do you want two independent MIDI devices?

@probonopd
Copy link
Author

I am looking for either

  • One device with dour ports, two In and two Out (I assume this makes the second set of ports use MIDI cable 1 rather than 0), or (if this is easier)
  • A way to send and receive on MIDI cable 1 rather than 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants