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

Thread: Controlling two or more Midi-Devices with one teensy?

  1. #1
    Junior Member
    Join Date
    Nov 2019
    Posts
    7

    Controlling two or more Midi-Devices with one teensy?

    Hello, I'm building a small midi controller to switch the sounds of my guitar effects device (Line6 Helix). Since I'm thinking about buying another pedal soon, which can only be switched via USB-Midi, I'm wondering if you can control two USB-Midi capable devices with one Teensy and if so, how to distribute the signals (is a normal USB-Hub enough?). Does anyone have any experience? So I didn't find a solution for a fast search.
    It would be easier if I didn't have to add a classic Midiport for the Helix.

  2. #2
    Senior Member vjmuzik's Avatar
    Join Date
    Apr 2017
    Location
    Florida
    Posts
    420
    Yes you can communicate with multiple USB devices at once through the use of a USB hub, all you have to do is add more USB MIDI devices to your USB Host object. In fact there is an example for this already with USBHost_t36 under Serial, MIDI, Interface_16x16 which has enough object for 10 USB MIDI devices, you really aren't limited to the number of devices you want to connect at one time other than running out of memory.

    I'm not sure how USB devices are assigned at startup if they are always in the same order, after startup it's obviously assigned by the order devices are plugged in or powered on, but if your pedals support the Identity Request MIDI message then it's easy enough to keep track of.

  3. #3
    Junior Member
    Join Date
    Nov 2019
    Posts
    7
    Sounds great. So I'll give it a try :-). Thanks for the information.

  4. #4
    Senior Member vjmuzik's Avatar
    Join Date
    Apr 2017
    Location
    Florida
    Posts
    420
    Never mind that, you have access to a few commands you can use to identify what USB device is assigned to which object, the easiest to test against are the Vendor and Product IDs so once you figure out what those are for your pedals you can easily identify which one is connected to which object.

    Code:
    uint16_t
    idVendor();
    idProduct();
    
    Pointer to Null-terminated Strings
    manufacturer();
    product();
    serialNumber();
    Sticking to the Interface_16x16 example you can do something like:
    Code:
      uint8_t pedal1;  //Store pedal1 location
      uint8_t pedal2;  //Store pedal2 location
      for (uint8_t device = 0; device < 10; device++) {
        if((midilist[device]->idVendor() == PEDAL1_VENDOR) && (midilist[device]->idProduct() == PEDAL1_PRODUCT)){       //Find pedal1 location
          pedal1 = device;
        }
        else if((midilist[device]->idVendor() == PEDAL2_VENDOR) && (midilist[device]->idProduct() == PEDAL2_PRODUCT)){  //Find pedal2 location
          pedal2 = device;
        }
      }
    
      midilist[pedal1]->sendControlChange(7, 127, 1);  //Send to pedal1 location
      midilist[pedal2]->sendControlChange(7, 64, 1);   //Send to pedal2 location
    I haven't tested this, but this should give you an idea of how to find which pedal is where so you know you are sending and receiving MIDI from the correct device.

  5. #5
    Junior Member
    Join Date
    Nov 2019
    Posts
    7
    Awesome. That should make the implementation much easier for me. There's nothing better than running from a good starting point. Thanks a lot.

  6. #6
    Hello Olli, thanks for this thread. did you eventually work it out

  7. #7
    Junior Member
    Join Date
    Nov 2019
    Posts
    7
    Hello, unfortunately I didn't pursue this any further for several reasons. For the whole thing to work without a computer in between the Teensy must be USB host capable. But that's only 3.6. and the 4.0. Since I only have a 3.2 and don't want to buy another one there is the end of the road. Furthermore, I didn't get the power supply regulated correctly, because if I have to connect a device to the USB port to supply the power, it will supply the power. Since I have to go via a hub to connect several devices, this is only possible if there is an OTG adapter. And unfortunately they can only supply power to the host if they have a USB-C port. You could now build an alternative power outlet to the teensy. But this is too complex for me.
    I have now fallen back on the good, old 5-pin plug Midi connection. Was the simplest solution. Simply take the socket, solder three cables to it and connect two 47 Ohm resistors to the two outer ones. Done. How I connect the second device sometime I look, once I have it. :-)

    Just click here to see the current state of development :-).

Posting Permissions

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