Teensy MIDI ports

damo1976

Well-known member
Is it possible to limit the usb midi ports to only 2 instead of 4 when choosing Midi x 4?

Can the library be modified simply?

TIA
 
lol. I just meant I hope its not too complicated. I'm used to modifying library files but cant seem to find the one that relates to the midi ports.

TIA
 
Sorry I don't do MIDI stuff, but places to start looking: Assuming a Teensy 4.x?

In the cores\teensy4 directory I would look at:

usb_desc.h :

In the section:
Code:
#elif defined(USB_MIDI4)
  #define VENDOR_ID		0x16C0

Probably with the: #define: MIDI_NUM_CABLES 4

Then look in usb_desc.c and maybe it is covered?

Code:
#if MIDI_NUM_CABLES >= 2
	#define MIDI_INTERFACE_JACK_PAIR(a, b, c, d) \
		6, 0x24, 0x02, 0x01, (a), 0, \
		6, 0x24, 0x02, 0x02, (b), 0, \
		9, 0x24, 0x03, 0x01, (c), 1, (b), 1, 0, \
		9, 0x24, 0x03, 0x02, (d), 1, (a), 1, 0,
	MIDI_INTERFACE_JACK_PAIR(5, 6, 7, 8)
  #endif
  #if MIDI_NUM_CABLES >= 3
	MIDI_INTERFACE_JACK_PAIR(9, 10, 11, 12)
  #endif
  #if MIDI_NUM_CABLES >= 4
	MIDI_INTERFACE_JACK_PAIR(13, 14, 15, 16)
  #endif
...

Then in usb_midi.h
Which also looks like it may handle some of it already..
Like:
Code:
        void sendSysEx(uint32_t length, const uint8_t *data, bool hasTerm=false, uint8_t cable=0) __attribute__((always_inline)) {
		if (cable >= MIDI_NUM_CABLES) return;
		if (hasTerm) {

So you might try editing the first .h file mentioned change 4 to 2 and see what happens...
Probably change the product name as well...
#define PRODUCT_NAME {'T','e','e','n','s','y',' ','M','I','D','I','x','4'}

But again I don't do midi!
 
I was wondering if it was possible to override values from usb_dec.h without editing this file (to allow for easy compilation by third parties). I've tried tu use flags for that (-UMIDI_NUM_CABLES -DMIDI_NUM_CABLES=2), but without success.
I've also tried to have my own separate copy of usb_dec.h to override the one in the core, but it did not work either. Any pointers?
 
Back
Top