Teensy & USB MIDI


#1

Is it possible to programme Teensy to show up in a host as two(2) separate MIDI ports and sending over different “virtual MIDI cables”?
Eg. is it possible for Teensy to show up in MaxMSP and Reaper as ‘Teensy Midi Port 1’ and 'Teensy MIDI Port 2’?

The USB Device Class Definition for MIDI Devices says on page 16:

“MIDI data is transferred over USB using 32-bit USB-MIDI Event Packets. These packets provide an efficient method to transfer multiple MIDI streams with fixed length messages. The 32-bit USB-MIDI Event Packet allows multiple “virtual MIDI cables” routed over the same USB endpoint. This approach minimizes the number of required endpoints. It also makes parsing MIDI events easier by packetizing the separate bytes of a MIDI event into one parsed USB-MIDI event. The first byte in each 32-bit USB-MIDI Event Packet is a Packet Header contains a Cable Number (4 bits) followed by a Code Index Number (4 bits). The remaining three bytes contain the actual MIDI event.”

I need to design a hardware controller with 24 faders, each having at least 10bit resolution. It will be used as a sound diffusion controller in a multi-speaker setup. Which requires some data resolution / transmission rate. Going the Teensy & USB MIDI way (and avoiding OSC), one possible solution would be to divide the faders in 2 groups of 12 - similar to the physical appearance of the hardware device. Each group is sending in a separate MIDI Cable (0 & 1) and each fader as Pitch Bend in a separate MIDI Channel (0-11).

So, is it possible/efficient to programme Teensy to show up in MaxMSP and Reaper as 2 separate MIDI ports? Is it better to go the Teensy/OSC way. Or is it much simpler to built two separate hardware devises (even putting 2 Teensys in the case)?


#2

hold on, I don’t think you need to make two separate ports to send on separate MIDI channels from the same device. I’m pretty sure the MIDI event includes the channel number as part of the three bytes?

I’m not totally sure if I’m misunderstanding the question though


#3

It seems the OP wants to use one MIDI channel per potentiometer.
As the maximum MIDI channel number is 16, two universes MIDI ports are needed.


#4

ahhhh thank you for clarifying.

Perhaps this could be solved by using a message other than pitch-bend for the high byte?


#5

According to the MIDI specification, it’s possible to get way more than one (pitch bend) 14-bit controller per channel:

Controller numbers 0 through 31 are for controllers that obtain information from pedals, levers, wheels, etc. Controller numbers 32 through 63 are reserved for optional use as the LSB (Least Significant Byte) when higher resolution is required and correspond to 0 through 31 respectively. For example, controller number 7 (Volume) can represent 128 steps or increments of some controller’s position. If controller number 39, the corresponding LSB number to controller number 7, is also used, 14-bit resolution is obtained. This provides for resolution of 16,384 steps instead of 128.

If 128 steps of resolution is sufficient the second byte (LSB) of the data value can be omitted. If both the MSB and LSB are sent initially, a subsequent fine adjustment only requires the sending of the LSB. The MSB does not have to be retransmitted. If a subsequent major adjustment is necessary the MSB must be transmitted again. When an MSB is received, the receiver should set its concept of the LSB to zero.

Whether this is well supported in DAWs and MIDI host environments is another question entirely…


#6

Yes, as @thom correctly suggests, I want to send the value of each separate fader as a Pitch bend on a separate MIDI channel. This requires 24 different channels which is beyond the limit of MIDI specification. However, USB MIDI Device Definition permits the transmission of MIDI Event Packets on “virual MIDI cables”. This operation is quoted in the first post.

To say it in other words, to make Teensy operate as if a USB HUB or a USB MIDI Interface is sending the data received from 2 separate MIDI devices on 2 ports. Somehow I would like to “cheat” the USB MIDI specification and make one single device cepable sending over the limit of 16 standard MIDI channels by appearing in the host as 2 separate devices.

Yes, @alanza, one solution would be to send a 14-bit value as two Control Change messages (one for the LSB and the other for the MSB data). However there are two reasons I want to avoid this:

  • to reduce the amount of transmitted data (since diffusion practice requires continuous movements on many faders).
  • to transmit in a way that Reaper (and other DAW) understand, as @barnaby mentions. Actually I want to replicate the Mackie Control MIDI Mapping, which is somehow a standard that fader controllers are recognized by DAWs.

So the question remains, are you aware if somebody ever programmed Teensy so it appears to transmit as 2 different devices? And how easy is it?


#7

I am aware of attempts to do so in 2016 and 2017 (made a quick Google search a few hours ago), but saw no definitive solution… Might be interesting to ask this on Teensy-oriented forums ?


#8

This is doable and super easy. :slight_smile:

If you have Teensyduino installed - open the Adruino application and look for File->Examples->Teensy->USB_MIDI->Interface_3x3 and you’re pretty much in business.

NOTE the instructions in the sketch - you have to setup the Teensy as MIDIx4 in the Arduino Tools menu

I just loaded that sketch and here’s what I see in Live’s MIDI setup

55%20AM


#9

@okyeron great!
I wasn’t aware of that. I’ll check it when back to the studio…