-
Notifications
You must be signed in to change notification settings - Fork 21
Allow using an arbitrary number of ports #6
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
Allow using an arbitrary number of ports #6
Conversation
I've just tried out this change and it works fine :) 4 in + 4 out directly worked out of the box ... but there is one problem: No matter what cable I try to send data to, it is always sent on the first cable. let packet = UsbMidiEventPacket::from_midi(
CableNumber::Cable5,
packet.message,
);
defmt::info!("packet {:?}", defmt::Debug2Format(&packet));
let bytes: [u8;4] = packet.into();
defmt::info!("bytes {=[u8]:X}", bytes); the output is:
when using this, you can see the first byte is 0x0F and not I've tried to find the root cause and found this in the U4::combine implementation: let upper = upper.0.overflowing_shl(8).0; the upper nibble is shifted left by 8 bits and not 4. This surely is a problem, but changing it to 4 didn't fix the cable number problem.
Further edit: After more testing, it was the shift ... changing from 8 to 4 made it work. I just had some inconsistencies in my git checkouts. Starting from clean ones and only changing this part made it work like it should :) Aftermath: |
Hey, thanks for the debugging work. I thought i have tested that, tho; what platform are you on? I am actively using this driver so I'm willing to fork and maintain it. So feel free so file these PRs against my repo :) |
Yeah that was a strange error to find. As a device, I'm using a STM32F303CC, tested it on a Windows 10 host, will check on arch linux later. Nice to see someone take care, I'll hand in a PR later :) |
This is interesting. I'd have thought that it should behave more or less identical to the STM32F103. Yea, the old question in software development: how did that ever work?! :D edit: ah I can tell you how: It likely didn't I did not use that functionality; instead, I parsed the raw packets by hand. :D |
Hi all. I'm happy to give contributor access here. Apologies I didn't get notifications. One of the initial decisions about small in/outs was to make it easier to use in daw software. A bunch of never plugged up outs/ins are confusing. I always intended to provide a more dynamic intializer, allowing people to have there use case. |
Hi,
thanks for your great work!
I made adjustments to support an arbitrary, user-selectable number of input and output MIDI ports (I have tested this with up to 16; however, usb-device needs to be patched as in https://github.com/Windfisch/usb-device/tree/buffer-sizes to allow for a control buffer size large enough to hold the rather large descriptors.).
Also I corrected the ports in the descriptor: It seems that the right way[tm] is to have one external in/out jack per embedded out/in jack; Windows ignores embedded jacks that aren't connected to any external jack (or other element possibly), while Linux does just fine.
Only one in/out pair can be used with the default settings, though, but by using the
control-buffer-256
feature ofusb-device
, up to 5 in/out port pairs can be used. Using more ports require aforementioned patch to usb-device.Note: tdd.exe, a USB descriptor dumper and validator, still reports two errors (as with the original code): The in and out bulk endpoint descriptors are too short, because the MIDI audio class requires two more bytes. I've fixed this in https://github.com/Windfisch/usbd-midi (master), but this requires a patched version of usb-device.
I have changed the signature of the
new()
method; one might consider adding a differently-named function instead in order to retain compatibility.If you have any questions or requests, give me a shout :).