Multiple midi devices

Status
Not open for further replies.

mark.winger

Active member
I am trying to use 2 teensy 3.5 as midi controllers on the same windows 10 machine. I change the midi_names in the 2 devices but when both are plugged in they are always the same name. I assume this is due to caching. Paul mentioned a while back to bump the bcdDevice in the usb_desc.c file. I changed this file but don't know to build it. Can someone point me to instructions on doing this?

Thanks Mark.
 
The quick workaround is to compile one as MIDI and one as MIDI + Serial.

It stems from having the same device ID when compiled wherever you have the same device/USB-type combinations.

Edit- technically I believe the problem is the same combination of Vender-ID (VID) and Product-ID (ID).

If your boards are not the same type and/or they are not compiled for the same USB functions then Windows will be able to resolve the device names correctly.
 
Last edited:
Worked

The quick workaround is to compile one as MIDI and one as MIDI + Serial.

It stems from having the same device ID when compiled wherever you have the same device/USB-type combinations.

Edit- technically I believe the problem is the same combination of Vender-ID (VID) and Product-ID (ID).

If your boards are not the same type and/or they are not compiled for the same USB functions then Windows will be able to resolve the device names correctly.

Ok, that works. That leaves a limit of 3 (midi, midi+serial, midi+serial+audio). I more were needed, the vendor id/product id/version would have to change. How do I change them?
 
It's not as simple as it seems. When you modify the VID and PID, the automatic upload via Teensy loader will not longer work flawlessly. Is it really needed to have multiple Teensys for that, now that one single Teensy can show up as up to 16 midi devices?
 
... bump the bcdDevice in the usb_desc.c file. I changed this file but don't know to build it.

Just upload from Arduino. It's that easy!

The Arduino IDE will automatically recompile this file if you've made any changes. If you're in doubt, or unsure if you've got the right copy, just add any syntax error and try uploading. You should see the error in the Arduino IDE.
 
That leaves a limit of 3 (midi, midi+serial, midi+serial+audio).

Your question originally asked specifically for 2 boards.

I more were needed, the vendor id/product id/version would have to change. How do I change them?

Just edit usb_desc.h.

Yes, the auto-reboot feature will not work from Arduino, but you can simply press the button on your Teensy to work around this inconvenience. You can still upload new programs, just not automatically by clicking Upload in Arduino.
 
Your question originally asked specifically for 2 boards.



Just edit usb_desc.h.

Yes, the auto-reboot feature will not work from Arduino, but you can simply press the button on your Teensy to work around this inconvenience. You can still upload new programs, just not automatically by clicking Upload in Arduino.
Thanks. I will try this.

I did ask for 2 boards. But when I saw the work around I realized the limitation so I asked to understand in case I ever want to use more than 3 midi devices.
 
OK, I tried changing the bcddevice and that did not work. (I did intentionally add a syntax error to see if the usb_desc.c file compiled). It also still uploaded automatically after the change. Do I need to change something else like product id or vendor id?
 
I tried changing the PRODUCT_ID in the usb_desc.h file and that did not work either. I have 3 teensy's and I can run them with 3 different names using midi, midi-serial, and midi-serial-audio, but I have not been able to get them to work simultaneously with bcddevice or produce_id change.
 
I don't know if this is related to what you're getting but be adviced that windows caches device data rather than reload every time you plug it... make sure you reboot your Windows box before plugging in to see a 'new' name.
 
I don't know if this is related to what you're getting but be adviced that windows caches device data rather than reload every time you plug it... make sure you reboot your Windows box before plugging in to see a 'new' name.
I did reboot but that did not change anything. I still show 2 devices with the same name.
 
I had similar issues on Win 10 64bit and have not found a clear pattern yet as to when the device names are refreshed.

What helped me in most cases is to actively delete the existing devices from the Windows Device Manager first and start from a non MIDI device type (e.g. USB serial only) afresh on each Teensy BEFORE flashing with the new MIDI device type:

  • plug in one Teensy at a time and flash each back to a to basic USB serial device type using a different PRODUCT_ID, PRODUCT_NAME, PRODUCT_NAME_LEN in usb_desc.h for each (i.e. don't have all Teensys connected at the same time when flashing)
  • open device manager with all Teensys plugged in
  • delete all Teensy devices
  • unplug all Teensys
  • reboot your PC
  • plug in one Teensy at a time and flash each to your desired MIDI device type (making sure to have different PRODUCT_ID, PRODUCT_NAME, PRODUCT_NAME_LEN in usb_desc.h for each - you could also create separate new USB device type profiles so you don't have to edit the file each time when flashing)
 
For Teensy 3.x, to add one or several new USB type profiles, you basically follow the instructions found at the top of the usb_desc.h and then add a few lines in the \arduino\hardware\teensy\avr\boards.txt referencing the new profile(s) you have created (so they show up as selectable options in your IDE).

For example, in boards.txt in the Teensy 3.5 section, these are the lines for the default USB_MIDI profile:
Code:
teensy35.menu.usb.midi=MIDI
teensy35.menu.usb.midi.build.usbtype=USB_MIDI
teensy35.menu.usb.midi.fake_serial=teensy_gateway

So copy and paste that and change the values corresponding to your new profile in usb_desc.h. If you are using a Teensy 3.6, your lines go into the 3.6 section etc.

In your case, as you want to reuse an existing MIDI profile you simply copy and paste on existing definition in usb_desc.h and change the PRODUCT_ID, PRODUCT_NAME, PRODUCT_NAME_LEN values. Choose a PRODUCT_ID that is not yet used by any of the other profiles defined in usb_desc.h. You also need to use a unique #if defined(YOUR_UNIQUE_PROFILE_ID) line for each profile.

If you want multiple USB profiles, simply copy and past multiple times, choose unique PRODUCT_ID, PRODUCT_NAME, PRODUCT_NAME_LEN values and add the lines to boards.txt for each.
 
For Teensy 3.x, to add one or several new USB type profiles, you basically follow the instructions found at the top of the usb_desc.h and then add a few lines in the \arduino\hardware\teensy\avr\boards.txt referencing the new profile(s) you have created (so they show up as selectable options in your IDE).

For example, in boards.txt in the Teensy 3.5 section, these are the lines for the default USB_MIDI profile:
Code:
teensy35.menu.usb.midi=MIDI
teensy35.menu.usb.midi.build.usbtype=USB_MIDI
teensy35.menu.usb.midi.fake_serial=teensy_gateway

So copy and paste that and change the values corresponding to your new profile in usb_desc.h. If you are using a Teensy 3.6, your lines go into the 3.6 section etc.

In your case, as you want to reuse an existing MIDI profile you simply copy and paste on existing definition in usb_desc.h and change the PRODUCT_ID, PRODUCT_NAME, PRODUCT_NAME_LEN values. Choose a PRODUCT_ID that is not yet used by any of the other profiles defined in usb_desc.h. You also need to use a unique #if defined(YOUR_UNIQUE_PROFILE_ID) line for each profile.

If you want multiple USB profiles, simply copy and past multiple times, choose unique PRODUCT_ID, PRODUCT_NAME, PRODUCT_NAME_LEN values and add the lines to boards.txt for each.

This worked. I created 3 new types, all are MIDI + SERIAL. Loaded up 3 teensys and the midi devices came up with the correct names. However, in the ide menu I get "MIDI + SERIAL" for all the original and the 3 new ones, but it works to select the different ones since each has a different device id. How does the name in the selection box get enumerated, How do I change the text so I can identify which is which?
 
You need a separate entry for each profile in boards.txt using a different name.

So for example (assuming that your USB profiles referenced in #if defined(YOUR_UNIQUE_PROFILE_ID) in usb_desc.h are USB_MIDI1, USB_MIDI2 and USB_MIDI3:

Code:
teensy35.menu.usb.midi=USBMIDI1
teensy35.menu.usb.midi.build.usbtype=USB_MIDI1
teensy35.menu.usb.midi.fake_serial=teensy_gateway

teensy35.menu.usb.midi=USBMIDI2
teensy35.menu.usb.midi.build.usbtype=USB_MIDI2
teensy35.menu.usb.midi.fake_serial=teensy_gateway

teensy35.menu.usb.midi=USBMIDI3
teensy35.menu.usb.midi.build.usbtype=USB_MIDI3
teensy35.menu.usb.midi.fake_serial=teensy_gateway

So the first line determines the entry in the drop-down box.

That should then give you three entries in the IDE.
 
Was out of town a few days but had a little time yesterday. I go to work, thanks for the helf. I am using teensy to handle different functions. Currently, 1 teensy controls 16 motor fader, the second 17 motor faders, and the third controls 68 rotary enodes with push buttons and 102 led push buttons. (Large midi control surface) . The cool thing about using 3 profiles is i can use a single project and conditionally build the code for each teensy by simply choosing the profile. Not complete yet but getting close.
 
Another option would be to have your 3 teensys in a master-slave configuration so you only need to expose one midi device to your DAW. Please post some pictures of your project, would love to see it!
 
Or instead of having to add a configuration profile for every Teensy, you can do the smart move and just change the serial number of each Teensy in the name.c file under the device name so that each will show as their individual product. I know for a fact this works with windows and there is zero editing of the Teensy files.
 
Another option would be to have your 3 teensys in a master-slave configuration so you only need to expose one midi device to your DAW. Please post some pictures of your project, would love to see it!

Yes, I had thought is using i2c as com betweem them. But I am already using the i2c bus to control pwm for the motor faders and since this is my first use of i2c I was not sure how much problem I would have using it for both.

I will post pics soon.
 
Or instead of having to add a configuration profile for every Teensy, you can do the smart move and just change the serial number of each Teensy in the name.c file under the device name so that each will show as their individual product. I know for a fact this works with windows and there is zero editing of the Teensy files.

Thanks, I did think of that once but never got around to trying it and no one mentioned it so I wasn't sure it would work.
 
Thanks, I did think of that once but never got around to trying it and no one mentioned it so I wasn't sure it would work.

It definitely works, when I rebuilt the Open Labs Neko I have I used 3 Teensy 3.6s each with their own product name, same manufacturer name, and a unique serial number between the three and they have no problems coexisting on the same computer.
 
It definitely works, when I rebuilt the Open Labs Neko I have I used 3 Teensy 3.6s each with their own product name, same manufacturer name, and a unique serial number between the three and they have no problems coexisting on the same computer.

Unfortunately, some Windows apps will not display each teensy with the name defined in name.c if using multiple teensys even if using different serials. Windows is not very consistent in this respect but it’s trial and error. Some DAWs do. Some apps don’t. I have not figured out what the pattern is. Some people have said that it has something todo with the Windows cache.
 
OK, I have this working but I had some problems that maybe someone can help me explain. I am working with the motorized fader part of this and each teensy is driving 16 motor faders. If I run just one teensy it work perfectly. But if I run 2 simultaneously I get some flakey issues.

The setup is 2 teensy connected to a PC with my "home brew mixer". I send snapshots from the pc to the teensies. Each gets the same data and each ignores midi controllers it does not recognize. The snap shots include about 200 control messages of which each controller ignores all except if 16 fader controllers.

When only one is connected I can send snap shots all day long with no problem, one responding to 1-16 and the other 17-32. But when running simultaneously I get really strange occurrences. It appears I get some messages that confuse things. (I have been unable to sort out the reason).

To get around the problem, I modified the mixer code to send only the controllers that each teensy needs (one port I send 1-15 the other 17-32) and with this change it works flawlessly.

With only one connected the data is sent only once, with 2 connected the pc sends the data twice (once to each port). I am suspicious that I am getting some sort of buffer overflow. Is the midi device driver shared between the midi devices? 200 controllers 3 bytes each is 600 bytes or 1200 bytes for 2 ports. Could I be overrunning the device driver?

As side note. I have used this software with 3 Behringer bcf2000 with no problem. A little different in that the total transfer would be about 900 bytes due to the smaller configuration.

Just hoping someone may have run into a problem like this and recognize it. Paul, does this ring any bells with you?
 
OK, I have this working but I had some problems that maybe someone can help me explain. I am working with the motorized fader part of this and each teensy is driving 16 motor faders. If I run just one teensy it work perfectly. But if I run 2 simultaneously I get some flakey issues.

The setup is 2 teensy connected to a PC with my "home brew mixer". I send snapshots from the pc to the teensies. Each gets the same data and each ignores midi controllers it does not recognize. The snap shots include about 200 control messages of which each controller ignores all except if 16 fader controllers.

When only one is connected I can send snap shots all day long with no problem, one responding to 1-16 and the other 17-32. But when running simultaneously I get really strange occurrences. It appears I get some messages that confuse things. (I have been unable to sort out the reason).

To get around the problem, I modified the mixer code to send only the controllers that each teensy needs (one port I send 1-15 the other 17-32) and with this change it works flawlessly.

With only one connected the data is sent only once, with 2 connected the pc sends the data twice (once to each port). I am suspicious that I am getting some sort of buffer overflow. Is the midi device driver shared between the midi devices? 200 controllers 3 bytes each is 600 bytes or 1200 bytes for 2 ports. Could I be overrunning the device driver?

As side note. I have used this software with 3 Behringer bcf2000 with no problem. A little different in that the total transfer would be about 900 bytes due to the smaller configuration.

Just hoping someone may have run into a problem like this and recognize it. Paul, does this ring any bells with you?

Are you able to post the source code for this?
 
Status
Not open for further replies.
Back
Top