Limit MIDI to just two ports?

Status
Not open for further replies.

Ando_Shy

Member
Good day,

I am working on a project that uses midi and requires 2 ports. Everything is tested and functional using the MIDIx4 profile for teensy. However, in this particular case the additional two ports are not used and may lead to confusion by the end user. Is there a straight forward way to limit the teensy to just two ports? Or do I need start digging through the library code for a workaround?
Just to clarify this is being used as a USB MIDI device and I would like only two ports to be available when teensy shows up in the operating system.

Thank you in advance,
-Andrew
 
Last edited:
Easiest way to do it without changing a bunch of things is to edit usb_desc.h, but if you ever needed to change it again you would have to edit that again. A while ago for my personal use I added an additional dropdown menu for selecting the number of midi ports I wanted, but I haven't updated it for the new Teensyduino and it requires changing a few files to support it.

Here's an example of changing the number of ports for the MIDIx4 profile, the relevant line is highlighted in red, simply change that number from 1 to 16. Your operating system most likely won't register the change by itself since it will have already been cached for 4 ports, but if you change the serial number at the same time it will get registered as a new device and you will see the change take effect.

Code:
#elif defined(USB_MIDI4)
  #define VENDOR_ID		0x16C0
  #define PRODUCT_ID		0x0485
  #define BCD_DEVICE		0x0211
  #define MANUFACTURER_NAME	{'T','e','e','n','s','y','d','u','i','n','o'}
  #define MANUFACTURER_NAME_LEN	11
  #define PRODUCT_NAME		{'T','e','e','n','s','y',' ','M','I','D','I','x','4'}
  #define PRODUCT_NAME_LEN	13
  #define EP0_SIZE		64
  #define NUM_ENDPOINTS         4
  #define NUM_USB_BUFFERS	16
  #define NUM_INTERFACE		2
  #define SEREMU_INTERFACE      1	// Serial emulation
  #define SEREMU_TX_ENDPOINT    1
  #define SEREMU_TX_SIZE        64
  #define SEREMU_TX_INTERVAL    1
  #define SEREMU_RX_ENDPOINT    2
  #define SEREMU_RX_SIZE        32
  #define SEREMU_RX_INTERVAL    2
  #define MIDI_INTERFACE        0	// MIDI
[COLOR="#FF0000"]  #define MIDI_NUM_CABLES       4[/COLOR]
  #define MIDI_TX_ENDPOINT      3
  #define MIDI_TX_SIZE          64
  #define MIDI_RX_ENDPOINT      4
  #define MIDI_RX_SIZE          64
  #define ENDPOINT1_CONFIG	ENDPOINT_TRANSIMIT_ONLY
  #define ENDPOINT2_CONFIG	ENDPOINT_RECEIVE_ONLY
  #define ENDPOINT3_CONFIG	ENDPOINT_TRANSIMIT_ONLY
  #define ENDPOINT4_CONFIG	ENDPOINT_RECEIVE_ONLY
 
Status
Not open for further replies.
Back
Top