Forum Rule: Always post complete source code & details to reproduce any issue!
Page 1 of 3 1 2 3 LastLast
Results 1 to 25 of 73

Thread: Teensy 3.6 USB MIDI host development status

  1. #1
    Senior Member
    Join Date
    Dec 2013
    Posts
    131

    Teensy 3.6 USB MIDI host development status

    Hi Paul,

    I'm keen to make use your USB MIDI Host support on Teensy 3.6 as soon as I can! What's it's current state of development?

    If you need someone to do some testing, please let me know and I'll be happy to oblige.

    Thanks

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,340
    Look at File > Examples > USBHost_t36 > Test.

    Since releasing Teensyduino 1.36, I've been focusing on other stuff. Planning to work on USB host again in June.

  3. #3

    Usb midi

    I'm also very interested in this capability, so I hope you will keep it on the agenda. Thanks, Paul!

    Quote Originally Posted by PaulStoffregen View Post
    Look at File > Examples > USBHost_t36 > Test.

    Since releasing Teensyduino 1.36, I've been focusing on other stuff. Planning to work on USB host again in June.

  4. #4
    Senior Member
    Join Date
    Dec 2013
    Posts
    131
    Ok, thanks Paul

  5. #5
    Senior Member
    Join Date
    Dec 2013
    Posts
    131
    Quote Originally Posted by PaulStoffregen View Post
    Look at File > Examples > USBHost_t36 > Test.

    Since releasing Teensyduino 1.36, I've been focusing on other stuff. Planning to work on USB host again in June.

    Hey Paul,

    Just checking in on this - when do you plan to progress development on USB Host?

    I'm interested in MIDI host for multiple devices through a hub, and unfortunately UHS_30 and USB_HostShield_2.0 both have bugs which prevent this from working for me.

    Many thanks,

    Matt

  6. #6
    I'm really looking forward to this library!

  7. #7
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,340
    Quote Originally Posted by mattomatto View Post
    I'm interested in MIDI host for multiple devices through a hub, and unfortunately UHS_30 and USB_HostShield_2.0 both have bugs which prevent this from working for me.
    I tested 2 MIDI devices through a hub. It works, at least with the 2 devices I have... a cheap keyboard and a cheap drum pad thingie. So far the MIDI device driver only receives messages. I plan to add transmit, but so far I don't have any commercial devices (other than another Teensy) that receive USB MIDI messages.

  8. #8
    I've been away for a while and just found the USB host lib for the 3.6. I tested it with an Oxygen 25 controller and it works great! My next step is to link one of the color displays and audio boards to it and start monkeying with synth output. I haven't tried it through a hub, but will at some point. I could envision a 3.6 driving a 3.2 as a synth through usb midi, or as a standalone USB midi bridge to whatever. Very cool stuff, thanks for working on this Paul.

  9. #9
    I've been hoping the MIDI driver would get some work, specifically sending out MIDI Bytes, this would make all my projects a lot easier as at the moment i have to use a USB Host Shield which takes up extra pins.

    Hopefully Paul will be able to implement sending bytes to the connected MIDI device :-)

  10. #10
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,340
    Can you be more specific about "specifically sending out MIDI Bytes"?

    The MIDI protocol works in messages. With 31250 baud serial, these are usually 2 or 3 bytes. With USB, the MIDI messages are packed into 32 bit fields, even when only 2 or 3 bytes are meaningful.

  11. #11
    Hey Paul, yes I just have a bad habit of calling a midi message MIDI Bytes as midi data bytes are only 7-bits, sorry for the confusion, I just really want to be able to transmit midi messages like PC, CC and specially sysex, you had mentioned that you only have other teensys to transmit and test it with but if you implement it i could test it here as well using my guitar processors which have MIDI support.

  12. #12
    Junior Member
    Join Date
    Dec 2017
    Location
    Oregon, USA
    Posts
    7
    Hi Paul! I've been putting together an audio project and have incorporated your USB MIDI host, it's working (nearly) perfectly! I bought a Pyle PMIDIKPD50 which has keys, pads, and encoders. I'm using a "stacked" (4+4=7) hub and am able to receive messages without problem.
    I did see one issue though... When multiple MIDI commands are strung together in the same transfer, the 2nd/3rd commands "repeat" in all following single command transfers. Investigating further, I believe this is already on your TODO list...
    In midi.cpp, MIDIDevice::rx_data apparently doesn't know the receive length and processes the whole thing. When single commands are sent the remnant of the previous 2nd/3rd processes again. I see the TODO is "use actual received length", which of course id the correct fix. I looked at transfer->length, but it was always 64 (if it were that easy, you would have implemented it) so I hacked in something to zero it out after adding the message to the receive queue...
    Code:
    void MIDIDevice::rx_data(const Transfer_t *transfer)
    {
    	println("MIDIDevice Receive");
    	print("  MIDI Data: ");
    	print_hexbytes(transfer->buffer, rx_size);
    	uint32_t head = rx_head;
    	uint32_t tail = rx_tail;
    	uint32_t len = rx_size >> 2; // TODO: use actual received length
    	for (uint32_t i=0; i < len; i++) {
    		uint32_t msg = rx_buffer[i];
    		if (msg) {
    			if (++head >= RX_QUEUE_SIZE) head = 0;
    			rx_queue[head] = msg;
    			rx_buffer[i]=0; // <-----  unknown length work-around 12/3/17 TJS
    		}
    	}
    <snip>
    This fixes the problem with this version, sorry I wasn't able to dive deep enough to implement the correct length TODO.
    I have USBHOST_PRINT_DEBUG enabled captures if you like, but I'm sure you get the idea.
    Everything else seems to working perfectly, thank you for all your hard work Paul!

  13. #13
    Member
    Join Date
    Oct 2015
    Location
    Roma (IT, UE)
    Posts
    67
    Is this the right library to use (on Teensy3.6) to implement a USBMIDI-to-LegacyMIDI adapter?
    I'd like to build "something" which accepts a USB MIDI keyboard and just forwards everything to a DIN MIDI (serial/legacy) OUT port (using this circuit https://www.pjrc.com/teensy/td_libs_MIDI.html)
    This would allow me to control old MIDI synths from current USB keyboards (like M-Audio and the likes).

  14. #14
    Junior Member
    Join Date
    Dec 2017
    Location
    Oregon, USA
    Posts
    7
    Quote Originally Posted by XFer View Post
    Is this the right library to use (on Teensy3.6) to implement a USBMIDI-to-LegacyMIDI adapter?
    Yes, this is the one!

  15. #15
    I am also looking at USB HOST MIDI implementation and would love to build out *sending* MIDI (it currently only receives MIDI input).
    I couldn't find any of the USB HOST device drivers that send data out... to get an idea of how to actually send data back out using the USB host port.

    Is there a good resource to get started or someone who can kickstart the process with some basic code for sending USB output to through a host driver?

  16. #16
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,340
    Quote Originally Posted by TravisSmith View Post
    In midi.cpp, MIDIDevice::rx_data apparently doesn't know the receive length and processes the whole thing. When single commands are sent the remnant of the previous 2nd/3rd processes again. I see the TODO is "use actual received length", which of course id the correct fix.
    Fixed.
    https://github.com/PaulStoffregen/US...9ea54ea7a4e80e

    Hopefully this solves the problem?

  17. #17
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,340
    Quote Originally Posted by XFer View Post
    Is this the right library to use (on Teensy3.6) to implement a USBMIDI-to-LegacyMIDI adapter?
    I'd like to build "something" which accepts a USB MIDI keyboard and just forwards everything to a DIN MIDI (serial/legacy) OUT port (using this circuit https://www.pjrc.com/teensy/td_libs_MIDI.html)
    This would allow me to control old MIDI synths from current USB keyboards (like M-Audio and the likes).
    Yes, confirmed, Teensy 3.6 and USBHost_t36 would be the way to build this sort of converter. You would write a fairly simple program to receive the MIDI messages you're interested in forwarding, and then just use the normal MIDI library to transmit them.

    The Teensy 3.6 output is only 3.3V. Usually that can work if you use lower value resistors. Or you could add a 3 to 5V buffer chip, like 74AHCT125, to transmit a fully 5V signal with the usual 220 ohm resistors.

  18. #18
    Junior Member
    Join Date
    Dec 2017
    Location
    Oregon, USA
    Posts
    7
    Quote Originally Posted by PaulStoffregen View Post
    Fixed.
    https://github.com/PaulStoffregen/US...9ea54ea7a4e80e

    Hopefully this solves the problem?
    Wow, thanks for the quick response and sorry for my slow one. Confirmed, this fixes the issue. Thanks Paul!

  19. #19
    Member
    Join Date
    Oct 2015
    Location
    Roma (IT, UE)
    Posts
    67
    Quote Originally Posted by PaulStoffregen View Post
    Yes, confirmed, Teensy 3.6 and USBHost_t36 would be the way to build this sort of converter. You would write a fairly simple program to receive the MIDI messages you're interested in forwarding, and then just use the normal MIDI library to transmit them.

    The Teensy 3.6 output is only 3.3V. Usually that can work if you use lower value resistors. Or you could add a 3 to 5V buffer chip, like 74AHCT125, to transmit a fully 5V signal with the usual 220 ohm resistors.
    Thanks a lot Paul!
    Lots of good infos.

  20. #20
    Any change MIDI transmition will be added next? another addition that would be great would be being able to check the state of the usb port, specifically if there's a device attached

  21. #21
    MIDI transmission would be great. Most important use-case for me would be to light up the keys on the pad controller I plug in.

  22. #22
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,340
    I ordered a Novation Launchpad today.

    https://www.amazon.com/Novation-Laun.../dp/B00YR47GQQ

    It seems to be one of the few USB MIDI products with good documentation on the messages it can receive.

  23. #23
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,340
    Ok, I've made a first attempt to add MIDI transmit.

    https://github.com/PaulStoffregen/US...b23e601e40dafb

    This should work, but it's not as efficient as it could be. Only 1 message is sent in each packet, rather than packing up to 16 if you're sending rapidly. It should work, but limited to about the same speed as regular serial MIDI.

    Please let me know how this works for you? I don't own much MIDI gear and I'm not a musician, so I'm really depending on feedback for improving MIDI support.

  24. #24
    Senior Member
    Join Date
    Nov 2012
    Location
    Boston, MA, USA
    Posts
    1,103
    (I'm traveling and don't have access to electronics stuff or to MIDI stuff until the last week of January, unfortunately. Or I would test it.)

  25. #25
    Hi Paul, testing it today, i just wrote a couple of sketches to test between teensy's 3.2 as clients for the 3.6 and then i'll test it with all my midi gear, may I also suggest adding a getSysExArray() like the usbMIDI library? i'll post results in the upcoming hours, thank you for your work!!!!!!!!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •