PDA

View Full Version : Adjusting the Teensy MIDI device name



Pensive
01-19-2016, 11:37 AM
Hi all

i note in this thread it is possible to hack your teensyduino install with a new USB device type and code to rename your midi controller.

https://forum.pjrc.com/threads/23523-Change-device-name

it is functional but not elegant in the usual PJRC manner, and ongoing support is unlikely to be available using this method.

are there any better ways to achieve this from code in 2016?

thanks

jon

urbanspaceman
01-31-2016, 11:58 PM
follow with interest.

urbanspaceman
08-03-2016, 12:59 PM
No answer for this question?
Thanks

Pensive
08-03-2016, 01:48 PM
No answer for this question?
Thanks

No - there is no new approach unfortunately - you can do it - but you have to hack your Teensyduino install about, and if anyone has previously plugged in a teensy on a host windows computer, it will almost certainly pop up as a Teensy, ignoring your changes.

Right now, this is probably bubbling around at the very bottom of Paul's todo list if it is on it at all - so I wouldn't hold your breath.

urbanspaceman
08-03-2016, 01:51 PM
Thanks for your reply Pensive

PaulStoffregen
08-05-2016, 03:36 PM
Actually, there is some provision for this using weak linking you can override, but no friendly documentation on how to actually do it.

https://github.com/PaulStoffregen/cores/blob/master/teensy3/usb_names.h

dr_d_nice
09-18-2016, 05:49 PM
also following this one

oddson
10-07-2016, 08:19 PM
Actually, there is some provision for this using weak linking you can override, but no friendly documentation on how to actually do it.

https://github.com/PaulStoffregen/cores/blob/master/teensy3/usb_names.h
Any chance on some unfriendly documentation or even a hint or two?

I get that the weak attribute means these defines can be overridden so I assume the sketch would need to have some #define statements to take the place of the ones in usb_desc.h.

But I gather it's not a simple as adding the replacements in the setup section of the sketch:

#define PRODUCT_NAME {'M','y',' ','M','I','D','I'}
#define PRODUCT_NAME_LEN 7

So are there some broad strokes or general guidance on this as the question keeps coming up but there are still no details.

Pensive
10-08-2016, 02:31 PM
i've done some googling and in c++ you can punch in weak link overrides before runtime via DLL file, i maybe a million miles away but i think you might need to pull in a dll which defines these values in the correct structs which will be pulled into the compile chain before runtime.

Total guess, i'm sure there's an easier way, and it might not be arduino compatible - i've never seen a DLL in an arduino project before.

EDIT - I don't think this is right at all, I'm totally at sea here, missing out some core knowledge. :(

oddson
10-08-2016, 04:49 PM
DLLs use weak linking so they show up in searches on the topic but the idea is more general.

There's a hint in the other thread where Paul indicates why the fix isn't simple:


...The trouble with a weak symbol is the USB descriptor stuff depends on finding the string length as a compile-time constant. Obviously the compiler can't know the length of your string in the sketch while compiling the USB code (remember, restructuring the build process is not an option because compatibility with Arduino is a major design goal). So the USB descriptor sending code, inside that interrupt-based code, needs to be redesigned to handle data somewhat differently. That's the main reason this is still on my to-do list... there's no quick and easy way to do it. On AVR, there's also the issue of making sure the user's data is in the right memory space, but that's a lesser concern because people will probably just copy and edit an example.

So I gather we have to declare the structure(s) since that's what has the weak attribute, thereby overwriting the structure declarations at about line 1200 of usb_desc.c.

tni
10-08-2016, 05:49 PM
The weak symbol stuff is implemented and works. However, there appears to be no way to make it work directly from C++ (e.g. your .ino sketch). So go to your sketch folder and create a new C file "usb_desc.c":


#include <usb_names.h>

#define MANUFACTURER_NAME {'t','n','i'}
#define MANUFACTURER_NAME_LEN 3
#define PRODUCT_NAME {'t','i','n', 'y', ' ', 'd', 'e', 'v', 'i', 'c', 'e'}
#define PRODUCT_NAME_LEN 11

struct usb_string_descriptor_struct usb_string_manufacturer_name = {
2 + MANUFACTURER_NAME_LEN * 2,
3,
MANUFACTURER_NAME
};

struct usb_string_descriptor_struct usb_string_product_name = {
2 + PRODUCT_NAME_LEN * 2,
3,
PRODUCT_NAME
};


The weak symbols that get overwritten are "usb_string_manufacturer_name" and "usb_string_product_name".

Pensive
10-08-2016, 05:52 PM
well this is exciting, i've held off bothering because i need to re-do it all every time i update :)

chaosmoon
01-22-2018, 12:11 AM
The weak symbol stuff is implemented and works. However, there appears to be no way to make it work directly from C++ (e.g. your .ino sketch). So go to your sketch folder and create a new C file "usb_desc.c":


#include <usb_names.h>

#define MANUFACTURER_NAME {'t','n','i'}
#define MANUFACTURER_NAME_LEN 3
#define PRODUCT_NAME {'t','i','n', 'y', ' ', 'd', 'e', 'v', 'i', 'c', 'e'}
#define PRODUCT_NAME_LEN 11

struct usb_string_descriptor_struct usb_string_manufacturer_name = {
2 + MANUFACTURER_NAME_LEN * 2,
3,
MANUFACTURER_NAME
};

struct usb_string_descriptor_struct usb_string_product_name = {
2 + PRODUCT_NAME_LEN * 2,
3,
PRODUCT_NAME
};


The weak symbols that get overwritten are "usb_string_manufacturer_name" and "usb_string_product_name".


Hi there. Has anyone got this working? What is the definition of "your sketch folder" for placing the usb_desc.c file? The folder besides the .ino?

thanks

PaulStoffregen
01-22-2018, 12:39 AM
Has anyone got this working?

Yes, they have.

First, open the example code by clicking File > Examples > Teensy > USB_MIDI > MIDI_name.

Now, here's the trick. This "sketch" is actually 2 files. Arduino shows them in tabs. You need to click the "name.c" tab.

Here's a screenshot:

12686

This is where you will edit the name. But perhaps just try it as-is, where the name changes from "Teensy MIDI" to "My MIDI". Make sure Tools > USB Type is set to MIDI, and upload to your Teensy.

PaulStoffregen
01-22-2018, 12:42 AM
There's one more tricky step, which is getting your computer to "forget" the old name and show you the new name. Just today, these words were suggested (https://github.com/PaulStoffregen/Teensyduino_Examples/commit/4a819a57c8a4f0f53bebd00954fa5657bbc74f94#commitcom ment-27002045) for Macintosh:


Macintosh: Open “Audio Midi Setup”, unplug the Teensy device, delete it from the Midi Devices/Midi Studio Window, replug the Teensy device and your changes will show.

My guess is you would do something similar on Windows, perhaps involving uninstalling the "driver" from the Device Manager. This last part is still in need of specific instructions, maybe even with screenshots. If anyone can contribute specific advice for Windows users, please do?

chaosmoon
01-22-2018, 12:47 AM
Thanks for the swift reply, i'll check this out and report back. (i see im running a few versions behind on both Arduino and Teensyduino)

chaosmoon
01-22-2018, 01:16 AM
After updating Arduino and Teensyduino i can confirm that the methods described above are working under OSX 10.11.16, Arduino 1.8.5, Teensy 1.41

i saved the example as plain text in my sketch folder from notepad as "name.c"
re-opened the sketch
edited the filename characters in the example
adjusted the length
uploaded sketch
unplugged Teensy
deleted the old device in Audio Midi Setup

PaulStoffregen
01-22-2018, 01:59 AM
I've updated the website with instructions.

https://www.pjrc.com/teensy/td_midi.html

Still hoping someone can contribute instructions on Windows, ideally specific to each mouse click or other action taken. Screenshots wanted for both systems.

el_supremo
01-22-2018, 02:03 AM
FYI: I just tried my sketch which combines two keyboards and a couple of buttons into one USB stream from the T3.6. I added the name.c tab to it, recompiled and uploaded and it works immediately - Midi-Ox sees it as "My MIDI". I then recompiled the original version and uploaded that and it immediately shows up in Midi-Ox as "Teensy MIDI".
So, you don't have to delete drivers. Just compile, upload and go.
BTW, this was on a Win 10 Pro X64, Arduino 1.8.5 + TD 1.41

Pete

el_supremo
01-22-2018, 02:15 AM
Here's a screencap of MIDI-OX
12687

Pete

el_supremo
01-22-2018, 11:38 PM
@Paul:
Did you see #19? Windows users shouldn't need to delete the device.

Pete

Davidelvig
01-23-2018, 02:22 AM
Woo Hoo!
I added a new tab to my project in the Arduino IDE titled MIDI_Name.c... copied in the code, and Audacity on OSX now reports "My MIDI"
Very cool!

MickMad
01-24-2018, 12:32 PM
One thing I learned while doing the early USB Audio tests was that the device name and general USB properties are not automatically updated on an host for devices using the same name, VendorID and ProductID unless the bcdDevice field in the Device Descriptor is not updated too (usb_desc.c, line 90)

PaulStoffregen
01-24-2018, 01:05 PM
Did you see #19? Windows users shouldn't need to delete the device.


Thanks. I've updated the web page with a link to this thread.

Can anyone confirm whether Windows 7 automatically detects the MIDI name change?

chaosmoon
01-24-2018, 10:17 PM
I've updated the website with instructions.

https://www.pjrc.com/teensy/td_midi.html

Still hoping someone can contribute instructions on Windows, ideally specific to each mouse click or other action taken. Screenshots wanted for both systems.

Here's a screenshot of OSX Audio MIDI setup.

12728

PaulStoffregen
01-24-2018, 11:05 PM
Thanks. I've added the mac screenshot to the web page.

Davidelvig
01-25-2018, 03:56 AM
I just launched an old Arduino installed from last year on my Windows 7 VM (Arduino 1.6.6, Teensyduino 1.26 on VMWare 10.1.1. on my Mac - High Sierra) and connected a USB port (screenshot), and it recognized the USB port by my renamed value.
1272912729

Looks like Windows accepts the MIDI device name change as well ("DigiBrass MIDI").

Does that confirm what you were looking for, Paul?
I don't get the "Van Ooijen Technische" part... that's always been a prefix.

note the Audacity view of the MIDI port is just "DigiBrass MIDI"
12730

Interesting that "MIDI Monitor" a Mac app I sownbloaded from Snoise, shows the following
12731

and from the Mac program "Audio MIDI Setup"...
12732


p.s. Don't know why I got a double Windows screenshot image from VMWare, but heck, it's my dog, so it's OK.

qwazzerman
01-25-2018, 04:24 PM
Based on my understanding, the new device name has to be explicitly defined at compiling (since it uses #define)? Does the USB code require it to be declared that way, or can it somehow be declared as a variable that could be device-dependent?
Otherwise it seems that to have multiple Teensys connected with unique names, I'd have to change the name manually for each device before compiling.

oddson
01-25-2018, 04:38 PM
...until the official answer comes... I'd say 'yes' it has to be that was because it has to override a weak link definition elsewhere in the Teensyduino libraries (see post 6 (https://forum.pjrc.com/threads/32534-Adjusting-the-Teensy-MIDI-device-name?p=111430&viewfull=1#post111430) above)

...edit... wait... has to be a define statement but it can be in the code of the sketch... er... now I'm not so sure and I think I should have waited for a more informed answer. :confused: - now I miss the delete post feature.

HEADFULL
11-09-2018, 12:17 PM
Hi, I'm having an issue with multiple Teensy Midi devices that I need connected to the PC at the same time. I've renamed their device names as outlined in this thread, and they are showing correct names in windows device manager, but in all apps I've tested, I can see two devices with the same name, and not two unique devices. I've tested with Unity3d using nAudio plugin, Resolume Arena, and Midi-OX. They both work correctly if only one is plugged in at a time, but need to use both together. It seems pretty random which of the two devices is used twice, and if I plug into a different usb bus, sometimes I can get them both recognised as expected. But need them to always be recognised correctly. See screen grab of Midi-Ox displaying two duplicate names, and Windows device manager showing correct names (ConanSkate and ConanLanguage are the two renamed Teensys).
15123

I'm using Windows 10, Teensy 3.2, arduino 1.8.6
I've tried uninstalling the devices from the device manager, and restarting many times.
Was wondering if comment #23 might be useful, but wasn't sure how to implement that.
Any help greatly appreciated!

HEADFULL
11-11-2018, 12:25 PM
Hi, I'm having an issue with multiple Teensy Midi devices that I need connected to the PC at the same time. I've renamed their device names as outlined in this thread, and they are showing correct names in windows device manager, but in all apps I've tested, I can see two devices with the same name, and not two unique devices. I've tested with Unity3d using nAudio plugin, Resolume Arena, and Midi-OX. They both work correctly if only one is plugged in at a time, but need to use both together. It seems pretty random which of the two devices is used twice, and if I plug into a different usb bus, sometimes I can get them both recognised as expected. But need them to always be recognised correctly. See screen grab of Midi-Ox displaying two duplicate names, and Windows device manager showing correct names (ConanSkate and ConanLanguage are the two renamed Teensys).
15123

I'm using Windows 10, Teensy 3.2, arduino 1.8.6
I've tried uninstalling the devices from the device manager, and restarting many times.
Was wondering if comment #23 might be useful, but wasn't sure how to implement that.
Any help greatly appreciated!

So it seems there is a hacky but simple way around my issue of multiple teensy MIDI devices on the same PC. Set one to MIDI and the other to Serial-MIDI in the arduino IDE Tools > USB type before uploading. The reason I think this is working is that in usb_desc.h USB_MIDI and USB_MIDI_SERIAL have different PRODUCT_ID values. It seems that only changing PRODUCT_NAME and MANUFACTURER_NAME are not enough to force some applications in Windows to see unique MIDI devices.
The downside of this hacky solution is that only 2 Teensy devices will work this way (being only a choice of midi or serial-midi). I could change the PRODUCT_ID value in usb_desc.h manually before uploading to each device, but that doesn't seem very clean. Does anyone know if there is there a better way of doing this?

Theremingenieur
11-11-2018, 01:47 PM
The Teensy is so powerful that in the newer Teensyduino versions, it supports 4 or even 16 virtual midi devices on a single Teensy over one single USB connection. So, with some mindful programming, it should not longer be needed to have too many different Midi Teensys on one computer since one can do it all.

vjmuzik
11-12-2018, 02:29 AM
So it seems there is a hacky but simple way around my issue of multiple teensy MIDI devices on the same PC. Set one to MIDI and the other to Serial-MIDI in the arduino IDE Tools > USB type before uploading. The reason I think this is working is that in usb_desc.h USB_MIDI and USB_MIDI_SERIAL have different PRODUCT_ID values. It seems that only changing PRODUCT_NAME and MANUFACTURER_NAME are not enough to force some applications in Windows to see unique MIDI devices.
The downside of this hacky solution is that only 2 Teensy devices will work this way (being only a choice of midi or serial-midi). I could change the PRODUCT_ID value in usb_desc.h manually before uploading to each device, but that doesn't seem very clean. Does anyone know if there is there a better way of doing this?

It’s such a simple fix that I can’t figure out for the life of me why no one else ever suggests it when multiple people always run in to this same issue. All you have to do is change the serial number of your device so the OS recognizes it as a separate entity when they are all using USB_MIDI.