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

Thread: Configurable usbMIDI Port Names

  1. #1
    Senior Member vjmuzik's Avatar
    Join Date
    Apr 2017
    Posts
    686

    Configurable usbMIDI Port Names

    For those interested I've added a way to configure the usbMIDI Port Names, these are changed in the same manner as the Manufacturer Name, Device Name, and Serial Number. So to change the names from the default "Port 1" - "Port 16" you add the following struct to the name.c in your project, one for each port number.


    Code:
    #define MIDI_PORT1_NAME {'T', 'e', 'e', 'n' ,'s' ,'y' ,' ' ,'1'}
    #define MIDI_PORT1_NAME_LEN 8
    
    struct usb_string_descriptor_struct usb_string_midi_port1 = {
            2 + MIDI_PORT1_NAME_LEN * 2,
            3,
            MIDI_PORT1_NAME
    };
    Click image for larger version. 

Name:	Teensy Port Names.png 
Views:	62 
Size:	55.7 KB 
ID:	13083
    Attached Files Attached Files

  2. #2
    Junior Member
    Join Date
    Feb 2018
    Posts
    4
    Great. Thank you! Funny, I was searching to forum to find the answer prior to posting the question, but missed that thread. I am going to try it out.

  3. #3
    Iím trying specify custom port names with Teensyduino 1.53, Teensy 4, and macOS Catalina.

    Serial + MIDIx16

    Product name, Manufacturer, and Serial are not a problem. I increment the serial number to load a fresh build.

    Not sure where Iím going wrong and could use some help.

    Hereís my name.c :

    Code:
    // To give your project a unique name, this code must be
    // placed into a .c file (its own tab).  It can not be in
    // a .cpp file or your main sketch (the .ino file).
    
    #include "usb_names.h"
    
    // Edit these lines to create your own name.  The length must
    // match the number of characters in your custom name.
    
    #define MIDI_NAME   {'M','y','H','u','b'}
    #define MIDI_NAME_LEN  5
    
    #define MIDI_MANUFACTURER_NAME   {'D','a','h'}
    #define MIDI_MANUFACTURER_NAME_LEN 3
    
    #define MIDI_SERIAL_NUMBER   {'1','6'}
    #define MIDI_SERIAL_NUMBER_LEN 2
    
    #define MIDI_PORT1_NAME   {'T', 'e', 'e', 'n' ,'s' ,'y' ,' ' ,'1'}
    #define MIDI_PORT1_NAME_LEN 8
    
    #define MIDI_PORT2_NAME   {'T', 'e', 'e', 'n' ,'s' ,'y' ,' ' ,'2'}
    #define MIDI_PORT2_NAME_LEN 8
    
    #define MIDI_PORT3_NAME   {'T', 'e', 'e', 'n' ,'s' ,'y' ,' ' ,'3'}
    #define MIDI_PORT3_NAME_LEN 8
    
    #define MIDI_PORT4_NAME   {'T', 'e', 'e', 'n' ,'s' ,'y' ,' ' ,'4'}
    #define MIDI_PORT4_NAME_LEN 8
    
    #define MIDI_PORT5_NAME   {'T', 'e', 'e', 'n' ,'s' ,'y' ,' ' ,'5'}
    #define MIDI_PORT5_NAME_LEN 8
    
    #define MIDI_PORT6_NAME   {'T', 'e', 'e', 'n' ,'s' ,'y' ,' ' ,'6'}
    #define MIDI_PORT6_NAME_LEN 8
    
    #define MIDI_PORT7_NAME   {'T', 'e', 'e', 'n' ,'s' ,'y' ,' ' ,'7'}
    #define MIDI_PORT7_NAME_LEN 8
    
    #define MIDI_PORT8_NAME   {'T', 'e', 'e', 'n' ,'s' ,'y' ,' ' ,'8'}
    #define MIDI_PORT8_NAME_LEN 8
    
    #define MIDI_PORT9_NAME   {'T', 'e', 'e', 'n' ,'s' ,'y' ,' ' ,'9'}
    #define MIDI_PORT9_NAME_LEN 8
    
    #define MIDI_PORT10_NAME  {'T', 'e', 'e', 'n' ,'s' ,'y' ,' ' ,'1', '0'}
    #define MIDI_PORT10_NAME_LEN 9
    
    #define MIDI_PORT11_NAME  {'T', 'e', 'e', 'n' ,'s' ,'y' ,' ' ,'1', '1'}
    #define MIDI_PORT11_NAME_LEN 9
    
    #define MIDI_PORT12_NAME  {'T', 'e', 'e', 'n' ,'s' ,'y' ,' ' ,'1', '2'}
    #define MIDI_PORT12_NAME_LEN 9
    
    #define MIDI_PORT13_NAME  {'T', 'e', 'e', 'n' ,'s' ,'y' ,' ' ,'1', '3'}
    #define MIDI_PORT13_NAME_LEN 9
    
    #define MIDI_PORT14_NAME  {'T', 'e', 'e', 'n' ,'s' ,'y' ,' ' ,'1', '4'}
    #define MIDI_PORT14_NAME_LEN 9
    
    #define MIDI_PORT15_NAME  {'T', 'e', 'e', 'n' ,'s' ,'y' ,' ' ,'1', '5'}
    #define MIDI_PORT15_NAME_LEN 9
    
    #define MIDI_PORT16_NAME  {'T', 'e', 'e', 'n' ,'s' ,'y' ,' ' ,'1', '6'}
    #define MIDI_PORT16_NAME_LEN 9
    
    
    
    // ****************************************
    
    // Do not change this part.  This exact format is required by USB.
    
    // ****************************************
    
    struct usb_string_descriptor_struct usb_string_product_name = {
            2 + MIDI_NAME_LEN * 2,
            3,
            MIDI_NAME
    };
    
    
    struct usb_string_descriptor_struct usb_string_manufacturer_name = {
            2 + MIDI_MANUFACTURER_NAME_LEN * 2,
            3,
            MIDI_MANUFACTURER_NAME
    };
    
    
    struct usb_string_descriptor_struct usb_string_serial_number = {
            2 + MIDI_SERIAL_NUMBER_LEN * 2,
            3,
            MIDI_SERIAL_NUMBER
    };
    
    // ****************************************
    struct usb_string_descriptor_struct usb_string_midi_port1 = {
            2 + MIDI_PORT1_NAME_LEN * 2,
            3,
            MIDI_PORT1_NAME
    };
    
    
    struct usb_string_descriptor_struct usb_string_midi_port2 = {
            2 + MIDI_PORT2_NAME_LEN * 2,
            3,
            MIDI_PORT2_NAME
    };
    
    
    struct usb_string_descriptor_struct usb_string_midi_port3 = {
            2 + MIDI_PORT3_NAME_LEN * 2,
            3,
            MIDI_PORT3_NAME
    };
    
    
    
    struct usb_string_descriptor_struct usb_string_midi_port4 = {
            2 + MIDI_PORT4_NAME_LEN * 2,
            3,
            MIDI_PORT4_NAME
    };
    
    
    
    struct usb_string_descriptor_struct usb_string_midi_port5 = {
            2 + MIDI_PORT5_NAME_LEN * 2,
            3,
            MIDI_PORT5_NAME
    };
    
    
    
    struct usb_string_descriptor_struct usb_string_midi_port6 = {
            2 + MIDI_PORT6_NAME_LEN * 2,
            3,
            MIDI_PORT6_NAME
    };
    
    
    struct usb_string_descriptor_struct usb_string_midi_port7 = {
            2 + MIDI_PORT7_NAME_LEN * 2,
            3,
            MIDI_PORT7_NAME
    };
    
    
    struct usb_string_descriptor_struct usb_string_midi_port8 = {
            2 + MIDI_PORT8_NAME_LEN * 2,
            3,
            MIDI_PORT8_NAME
    };
    
    
    struct usb_string_descriptor_struct usb_string_midi_port9 = {
            2 + MIDI_PORT9_NAME_LEN * 2,
            3,
            MIDI_PORT9_NAME
    };
    
    
    struct usb_string_descriptor_struct usb_string_midi_port10 = {
            2 + MIDI_PORT10_NAME_LEN * 2,
            3,
            MIDI_PORT10_NAME
    };
    
    
    struct usb_string_descriptor_struct usb_string_midi_port11 = {
            2 + MIDI_PORT11_NAME_LEN * 2,
            3,
            MIDI_PORT11_NAME
    };
    
    struct usb_string_descriptor_struct usb_string_midi_port12 = {
            2 + MIDI_PORT12_NAME_LEN * 2,
            3,
            MIDI_PORT12_NAME
    };
    
    
    struct usb_string_descriptor_struct usb_string_midi_port13 = {
            2 + MIDI_PORT13_NAME_LEN * 2,
            3,
            MIDI_PORT13_NAME
    };
    
    
    struct usb_string_descriptor_struct usb_string_midi_port14 = {
            2 + MIDI_PORT14_NAME_LEN * 2,
            3,
            MIDI_PORT14_NAME
    };
    
    struct usb_string_descriptor_struct usb_string_midi_port15 = {
            2 + MIDI_PORT15_NAME_LEN * 2,
            3,
            MIDI_PORT15_NAME
    };
    
    
    struct usb_string_descriptor_struct usb_string_midi_port16 = {
            2 + MIDI_PORT16_NAME_LEN * 2,
            3,
            MIDI_PORT16_NAME
    };

    and here are my edits to usb_names.h in the Teensyduino package. Iím only editing the files for teensy 4.0.

    Code:
    #include <stdint.h>
    
    #ifdef __cplusplus
    extern "C" {
    #endif
    
    struct usb_string_descriptor_struct {
    	uint8_t bLength;
    	uint8_t bDescriptorType;
    	uint16_t wString[];
    };
    
    extern struct usb_string_descriptor_struct usb_string_manufacturer_name;
    extern struct usb_string_descriptor_struct usb_string_product_name;
    extern struct usb_string_descriptor_struct usb_string_serial_number;
    extern struct usb_string_descriptor_struct usb_string_midi_port1;
    extern struct usb_string_descriptor_struct usb_string_midi_port2;
    extern struct usb_string_descriptor_struct usb_string_midi_port3;
    extern struct usb_string_descriptor_struct usb_string_midi_port4;
    extern struct usb_string_descriptor_struct usb_string_midi_port5;
    extern struct usb_string_descriptor_struct usb_string_midi_port6;
    extern struct usb_string_descriptor_struct usb_string_midi_port7;
    extern struct usb_string_descriptor_struct usb_string_midi_port8;
    extern struct usb_string_descriptor_struct usb_string_midi_port9;
    extern struct usb_string_descriptor_struct usb_string_midi_port10;
    extern struct usb_string_descriptor_struct usb_string_midi_port11;
    extern struct usb_string_descriptor_struct usb_string_midi_port12;
    extern struct usb_string_descriptor_struct usb_string_midi_port13;
    extern struct usb_string_descriptor_struct usb_string_midi_port14;
    extern struct usb_string_descriptor_struct usb_string_midi_port15;
    extern struct usb_string_descriptor_struct usb_string_midi_port16;
    
    
    #ifdef __cplusplus
    }
    #endif
    
    #endif
    and usb_desc.c. Search on JJM to quick find the three blocks of code that I added.

    usb_desc.c

  4. #4
    Senior Member vjmuzik's Avatar
    Join Date
    Apr 2017
    Posts
    686
    The other part that needs changed in usb_desc.c is this which appears twice for the T4.x:
    Code:
    #if MIDI_NUM_CABLES >= 2
    	#define MIDI_INTERFACE_JACK_PAIR(a, b, c, d, e) \
    		6, 0x24, 0x02, 0x01, (a), (e), \
    		6, 0x24, 0x02, 0x02, (b), (e), \
    		9, 0x24, 0x03, 0x01, (c), 1, (b), 1, (e), \
    		9, 0x24, 0x03, 0x02, (d), 1, (a), 1, (e),
    	MIDI_INTERFACE_JACK_PAIR(5, 6, 7, 8, 0x06)
      #endif
      #if MIDI_NUM_CABLES >= 3
    	MIDI_INTERFACE_JACK_PAIR(9, 10, 11, 12, 0x07)
      #endif
      #if MIDI_NUM_CABLES >= 4
    	MIDI_INTERFACE_JACK_PAIR(13, 14, 15, 16, 0x08)
      #endif
      #if MIDI_NUM_CABLES >= 5
    	MIDI_INTERFACE_JACK_PAIR(17, 18, 19, 20, 0x09)
      #endif
      #if MIDI_NUM_CABLES >= 6
    	MIDI_INTERFACE_JACK_PAIR(21, 22, 23, 24, 0x0A)
      #endif
      #if MIDI_NUM_CABLES >= 7
    	MIDI_INTERFACE_JACK_PAIR(25, 26, 27, 28, 0x0B)
      #endif
      #if MIDI_NUM_CABLES >= 8
    	MIDI_INTERFACE_JACK_PAIR(29, 30, 31, 32, 0x0C)
      #endif
      #if MIDI_NUM_CABLES >= 9
    	MIDI_INTERFACE_JACK_PAIR(33, 34, 35, 36, 0x0D)
      #endif
      #if MIDI_NUM_CABLES >= 10
    	MIDI_INTERFACE_JACK_PAIR(37, 38, 39, 40, 0x0E)
      #endif
      #if MIDI_NUM_CABLES >= 11
    	MIDI_INTERFACE_JACK_PAIR(41, 42, 43, 44, 0x0F)
      #endif
      #if MIDI_NUM_CABLES >= 12
    	MIDI_INTERFACE_JACK_PAIR(45, 46, 47, 48, 0x10)
      #endif
      #if MIDI_NUM_CABLES >= 13
    	MIDI_INTERFACE_JACK_PAIR(49, 50, 51, 52, 0x11)
      #endif
      #if MIDI_NUM_CABLES >= 14
    	MIDI_INTERFACE_JACK_PAIR(53, 54, 55, 56, 0x12)
      #endif
      #if MIDI_NUM_CABLES >= 15
    	MIDI_INTERFACE_JACK_PAIR(57, 58, 59, 60, 0x13)
      #endif
      #if MIDI_NUM_CABLES >= 16
    	MIDI_INTERFACE_JACK_PAIR(61, 62, 63, 64, 0x14)
      #endif
    This is what maps each port to the changes in the array at JJM Start 3.

  5. #5
    Yes! That’s it! Thanks!

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    23,001
    I've added a link to this thread in the Teensy > USB_MIDI > MIDI_names example. Hopefully it will help people find this info.

    https://github.com/PaulStoffregen/Te...0c7389aa94dad9

Posting Permissions

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