alsa-project / alsa-lib

The Advanced Linux Sound Architecture (ALSA) - library
GNU Lesser General Public License v2.1
344 stars 173 forks source link

MIDI 2.0 Universal MIDI Packet format (UMP) #24

Closed symdeb closed 4 years ago

symdeb commented 4 years ago

Since MIDI 2.0 only support USB and not over DIN (for now), will MIDI 2.0 need a new or updated OS class driver for the 32/64 bit universal packet interface and device descriptor for devices ? Page 16 of the USB MIDI class driver spec defines support for 1,2 or 3 bytes transfers only, How will this have to be implemented by MIDI USB device manufacturers and well as on the Linux OSes side ? How will this impact Linux ALSA ? Would the first byte of the message with b7=0 not confuse the driver of running status ? Link universal packet format https://www.midi.org/articles-old/details-about-midi-2-0-midi-ci-profiles-and-property-exchange) Link first MIDI 2.0 Ready product: Roland A-88MKII https://www.midi.org/articles-old/roland-announces

tiwai commented 4 years ago

USB MIDI 2.0 protocol isn't defined yet, so it's hard to judge. But, yes, we'll need to extend the USB MIDI driver code accordingly. And no, we can't do anything right now unless the USB MIDI 2.0 spec is published.

ALSA rawmidi is nothing but the dumb byte stream, so at most we might need the alignment per 32bit packet size. A bigger change would be ALSA sequencer, and this would need a new event type for MIDI 2.0 packet. But the existing ALSA sequencer event has already 96 bits at least (128 bits on 64bit arch), so it should fit within the current scheme.

Meanwhile, the support of MIDI 2.0 CI is a totally different question. It's still unclear to me how the whole MIDI-CI things can be implemented in details, so it's a bit difficult to judge right now.

symdeb commented 4 years ago

Hi Takashi-san,

USB MIDI 2.0 was approved on NAMM 2020. The specs are on MIDI.ORG (not a PDF, just a webpage). Not sure if that is the whole spec. Not sure if they are going to publish a formal spec publicly soon. The CI spec is published in more detailed already. AFAIK CI is 1.0 SYSEX but does list a command sequence to negotiate devices to switch from 1.0 to 2.0. I would assume that 2.0 mode is moving to UMP mode. It is shown n the presentation as well.

BTW MIDI,org just replied: MIDI 2.0 uses a Universal MIDI Packet (UMP) format for MIDI 1.0 Protocol messages and MIDI 2.0 Protocol messages. There is a Version 2 of the USB Device Class definition for MIDI Devices in development to support the UMP format. It will require new class drivers. All of the major OS vendors are aware of the progress. I think the ALSA team is also aware.

P.S: For using JACK2 using MIDI ports , JACK need the ALSA "seq" mode. W ould assume JACK also needs those changes then ? It's not all that backwards compatible as it seems. Not sure why they chose UMP instead of just an SYSEX extension At high speed interfaces (USB) a byte more or less does not matter that much.

tiwai commented 4 years ago

Thanks, it's an interesting information. Unfortunately we have neither contact nor information about MIDI 2.0 at all, so the support on ALSA (Linux kernel / user-space) isn't expected right now. Could you ask them for helping the implementation on Linux? It might be that Google or other vendor have worked on it, but still we need to know who is doing what for now.

symdeb commented 4 years ago

Thanks, How should MIDI reach out to the ALSA developer community or key contact to provide information ? at alsa-lib@noreply.github.com ? Not sure MIDI.org will providing code or changes for a updated or new ALSA driver. :-) I am not sure if UMP needs different device descriptor but it looks like that. The USB MIDI Gadgets driver for embedded devices is probably thus also impacted. If a new descriptor is defined then the Roland A-88.mk2 must have support this such new descriptor then. https://www.roland.com/us/products/a-88mk2/

tiwai commented 4 years ago

The easiest would be to just get me (Takashi Iwai tiwai@suse.de) in the loop, then I'll delegate to other parties. Of course we don't expect that they develop or submit changes by themselves :) It's only about the specs and the details.

Also another question is whether other groups have already started working on Linux (e.g. Android or ChromeOS) enablement. If yes, we'd better to build up a working group.

symdeb commented 4 years ago

BTW statement about OS support here @36:00 https://www.youtube.com/watch?v=zXnHaoN2Cig&list=PLe2skUvADfhvu_pyet1veIIEAH0LA4iFK&index=15&t=0s

Interestingly, MIDI 2.0 was wrapped up in standard SYSEX and then send to a Cubase receiver that unpacked the Sysex and then send to a VST. If UMP would had been just be a Sysex extension as done in the demo, then all the device driver and OS changes could have been avoided perhaps. The DAW/software developers would then have to check on the type of Sysex to trigger sequencer data., but perhaps that is were the OS complexity is and the reason for defining a new package format. Who knows there will be a MIDI 1.0, UMP sysex extension someday :-). P.s Sent a message to MIDI.ORG to contact you.

cladisch commented 4 years ago

I was contacted two years ago, but it was not possible to get an NDA in place for various reasons.

So far, the information available is:

There is a Version 2 of the USB Device Class Definition for MIDI Devices in development to support the UMP format. It will require new class drivers.

tiwai commented 4 years ago

I was contacted two years ago, but it was not possible to get an NDA in place for various reasons.

Oh that's interesting. Let me know if you get further contact.

symdeb commented 4 years ago

I wish i could help on the driver/kernel.. Just started to work on customizing embedded ARM SoC based Linux kernels for USB hosts and devices, Assume when ALSA for x64/86 is updated for 2.0, embedded Linux can automatically benefit from that work. I could well help with testing though.

saji8k commented 4 years ago

The USB MIDI 2.0 Specification has now been released: https://www.usb.org/sites/default/files/USB%20MIDI%20v2_0.pdf

The MIDI 2.0 specs can be found here (You will have to create a free account first to view): https://www.midi.org/midi2

symdeb commented 4 years ago

Good news ! Now need USB MIDI 2.0 Gadget support for embedded devices :-) Really looking forward for ALSA to support it, probably more devices will be released to the market soon.

symdeb commented 3 years ago

The USB MIDI 2.0 spec has been released a few weeks ago now. MIDI 2.0 uses an alternate setting for the interface. This means that the device can support Legacy MIDI 1.0 and 2.0 but not both a the same time. (MIDI 1.0 as in legacy MIDI USB, not the UMP MIDI 1 mode) How will this work for ALSA Will the ALSA driver send a request to the device to switch back and forth. Would a user (or program) be able to (force) switch the interface back to MIDI 1 ? How would that work for the device to know which mode to work in ? Working on A MIDI 2.0 device (FS), but it will need ALSA code to debug/play with. Would ALSA raw be first candidate to develop ?

symdeb commented 3 years ago

Have a device now with the descriptors to support MIDI 2.0. Now need driver software to test it against with Any idea when work on this will commence ? Is there a possibility for a MIDI 2.0 branch ?

This doesn't help, but no one knows what is happening behind the scenes. https://www.midi.org/forum/5891-midi-2-0-usb-class-drivers

DocSunset commented 3 years ago

Just curious if there has been any progress on ALSA support for MIDI 2.0? This issue was closed before the specs were available, so I suppose the fact that it remains closed doesn't imply that the feature is supported. I also don't see any commits or pull requests that mention MIDI.

How are things progressing now that the core MIDI 2.0 specs and the USB MIDI 2.0 spec are publicly accessible?

symdeb commented 2 years ago

https://www.youtube.com/watch?v=69hzeBFOPfo 11:09 Windows Driver and API will be open source.

Android: Android 13 Beta 1 MIDI 2.0 support https://midi.org/forum/14214-android-13-developer-preview-2-support-for-midi-2-0 https://android-developers.googleblog.com/2022/04/android-13-beta-1-blog.html https://www.t3.com/news/the-7-biggest-android-13-upgrades-for-google-pixel-users-to-try-now

IOS: IOS 14+ UMP API https://developer.apple.com/documentation/coremidi/midieventpacket https://musichackspace.org/events/build-a-midi-2-0-program-using-the-apple-ump-api-workshop-2-december-6th/

Hardware: Board with UMP support https://forum.audiob.us/discussion/50436/protozoa-1st-midi-2-0-board-with-midi-ci Raspberry Pico code: https://github.com/hathach/tinyusb

Any updates for ALSA ?

tiwai commented 1 year ago

Does anyone have a real or a virtual MIDI 2.0 device? I'm interested in how the USB descriptor looks like, as a starter.

symdeb commented 1 year ago

The descriptor examples are in the USB spec. Appendix A/B https://www.usb.org/sites/default/files/USB%20MIDI%20v2_0.pdf Attached is the descriptor for Alternate function 1 device. lsusb just report a wrong name for the 2 fields after the subdescriptor type. This is not a big deal. P.s: The author of libusb has fixed this today (Aug 26)

MIDIStreaming Endpoint Descriptor: bLength 5 bDescriptorType 37 bDescriptorSubtype 2 (Invalid) bNumEmbMIDIJack 1 baAssocJackID( 0) 1 Endpoint Descriptor:

Referference: USB MIDI 2,0 spec: B.7.2

Note that this does not include the Terminal block descriptors of the class specific command. (p.31 of USB MIDI spec). it seem that those are interface descriptors (0x81) that probably the device driver need to issue (please confirm ?)

Alternate function 0 is for MIDI 1.0 so have not posted it. If needed can provide that as well.

There is a MIDI 2.0 devkit here: MIDI 2.0 devkit: https://amenote.com/?page_id=74 (available for devs in 4Q22) Right now only available to MIDI assocation member (costs: US$600/year) For high-speed and super-speed not sure there are cheap MCUs (The retail channel to buy MCU's is totally empty right now). For superspeed the only option seems to be the EZ-USB FX3.

Realy would like to help with this and learn along the way, Please let me know how. The controller I have is based on MIDI 1.0 code and not sure how much of a challenge it is to migrate it to UMP. Hopefully it just limited to handling longer data packets

symdeb commented 1 year ago

Correction. The descriptor was missing alternate setting 0. This update containts inerface 1 with alternate setting 0 (MIDI 1.0) and 1 (MIDI 2.0) . This is (should) be the same as in the USB MIDI specification. According to the spec, both interrupt and Bulk are supported, though this sample strictly follows the example in the USB spec.. In general , probably both should be bulk.

A pull request for lsusb was made to update it for MIDI 2.0

descriptor_rev_1.txt

Pull request is pending but here is the same decriptor with the changes made for USB 2.0. So this reflect sthe same descritpor as in the MIDI USB 2,0 specification.

descriptor_rev_1_fixed_lsusb.txt

Was all of this useful ?

Made an attempt to retreive the terminal describtor using a control request, but there is somewhere a problem in either libusb or the device firmware. Question: Should an control request to retrieve an interface descriptor (bmRequestType 0x81) only be issued before the USB device configure phase or this should work even when a device is configured ? According to the USB spec it should work.