Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 5 of 5

Thread: Teensy 4.0 USB-MIDI host issue

  1. #1
    Junior Member
    Join Date
    Mar 2015
    Posts
    9

    Teensy 4.0 USB-MIDI host issue

    I've been using a Teensy 4.0 as a USB-Midi "hub" (broadcasting MIDI messages to all connected devices over USB) for a few months, and it's been working great.

    However, I purchased a new synth recently, and for some reason the teensy crashes/freezes when this synth is connected.

    This new synth (Behringer Crave) has a small integrated keyboard, and can send messages just fine.
    As soon as another device (Arturia Keystep for example) sends a couple of messages, the teensy hangs.

    Attached are a stripped-down version of the sketch I cobbled together, as well as 2 serial traces (with USBHost_t36 debug activated).
    On the short trace, I just played a couple of notes from the keystep, and teensy hanged shortly after.
    On the long trace, I first hit a few notes on the crave (no issue), then hit notes from the keystep. Teensy kept logging very slowly for some time (10-20 secondes for the whole trace, maybe ?), then froze.

    The Crave is supposed to be usb-midi class compliant, and works fine when plugged in my computer.

    Any help appreciated
    Attached Files Attached Files

  2. #2
    Senior Member oddson's Avatar
    Join Date
    Feb 2013
    Location
    Isle in the Salish Sea
    Posts
    1,372
    did you handle incoming events to clear the queue? That's the most common hang where Teensy's buffer fills with unhandled messages.
    Quote Originally Posted by USB MIDI page
    // MIDI Controllers should discard incoming MIDI messages.
    while (usbMIDI.read()) {
    // read & ignore incoming messages
    }
    https://www.pjrc.com/teensy/td_midi.html

  3. #3
    Junior Member
    Join Date
    Mar 2015
    Posts
    9
    Thank you for you help.

    In my case, Teensy is only a USB MIDI Host (using its second USB port through a breakout shield). Its first port (micro USB) is just a serial port.
    Using USBHost_t36, I read all events from the connected MIDIDevices on the host port.

    It's still highly possible there's something wrong with my sketch (although it's been working fine with a keyboard, a sequencer/sampler and a previous synth at the same time).
    Or there's something funky going on with this new synth (although it's working fine when plugged into a compiter...).

    I'll try experimenting a bit at lunch time, see if handling or discarding incoming messages faster solves the issues (and see if its a buffer filling up).

  4. #4
    Junior Member
    Join Date
    Mar 2015
    Posts
    9
    After fiddling around, I found out that sending exactly 3 MIDI messages (simple NoteOn) to this synth is enough for the sketch to hang up.
    As long as I don't send anything to it, it continues to work fine.

    After I send MIDI messages to this problematic device, teensy sometimes keeps on receving packets ("queue another receive packet") until the queue fills up ("wait to receive more packets").

    If I run on a loop :
    Code:
      Serial.println("sending");
      problematic_midi_device->sendNoteOn(40, 200, 1);
      Serial.println("sent!");
    I get :
    Code:
    sending
    sent!
    sending
    sent!
    sending
    and then it stops there, but I never get a "MIDIDevice transmit complete" message from USBHost_t36...

  5. #5
    Junior Member
    Join Date
    Mar 2015
    Posts
    9
    So, I've worked around the issue for the moment, using a USB to MIDI cable (as the DIN input of the Crave is working fine), but I have run out of DIN MIDI plugs, so I would prefer to use the Crave over USB...

    If someone has any idea, I'd appreciate it.
    Would it be worthwhile to look at the USB packets, in order to compare a PC host (working) to the Teensy host (not working) ?

Posting Permissions

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