MIDI vs usbMidi?

Status
Not open for further replies.

TMJR

New member
Hi - Very interested in Teensy for stand-alone midi controllers and looking to understand the difference between midi and usbmidi functionality. I have a few 3.2 boards and have successfully breadboarded a switch, a pot (mostly working) and basic led flashing but struggling to understand when to use MIDI vs usbMIDI.

Just using a simple "trigger a pushbutton and it sends a midi code" I've gotten that to work using MIDI when the board is in Serial mode. I've also gotten it to work usbMidi when the board is in MIDI mode. Can't do both. Can they work together? When do you use one over the other..is the original MIDI functionality still recommended these days?

All the libraries I've seen that make creating controllers with pots, buttons, faders, etc 'easier' use usbMidi to control some software. My goal is to create a custom controller of faders, buttons, leds to control a synth that takes midi din. I assume if I just had the standalone teensy midi controller-->synth I could use regular MIDI, but what if I wanted to send PC usb midi in (like a DAW sequencer)-->Teensy controller-->synth...that seems like it would combine usbMidi with regular MIDI and that's where I'm confused.

Lots of questions, I know. I did do a search, and of course read the official midi page and the usbmidi pages but not a lot of info is given on where/what to use which. Thank you for any resources you could point me to!
 
usbMIDI and MIDI libraries have diverged slightly over time... perhaps the biggest difference is that MIDI uses an internal event-type system that is based on the upper nibble (most significant four bits) as an offset value so it is bit shifted four bits from Paul's usbMIDI values which use the original 0-7 type system....

https://github.com/PaulStoffregen/cores/blob/master/teensy3/usb_midi.h -- see comment line 40

The offset method allows code to add the channel and type values together to build the status byte.

It should be possible to use both usbMIDI and MIDI libraries together and, for things other than sysex and realtime messages, you really don't need to worry about values returned by getType().

I don't use DIN-plug MIDI for anything right now so and I've just done a few breadboard experiments with DIN connections so I'm not really expert on using the MIDI library (and I don't have the hardware readily available to test).

You can also send MIDI messages to the Tx pin directly without a MIDI library with serial.print() and many older Ardiuno code examples will show code like this:

Code:
void noteOff(byte statusbyte,byte pitch){
  Serial.print(statusbyte);
  Serial.print(pitch);
  Serial.print(0);
}

I would avoid these personally but I didn't come to Teensy from the Arduino world so this seems foreign to me.

I've gotten that to work using MIDI when the board is in Serial mode.
Sounds like you have one of these... I don't know if these cannot be used with a MIDI + serial option but make sure you don't try to send the same channel byte as the status byte.

Frankly usbMIDI() needs some updating and simultaneous usb and DIN MIDI controllers and MIDI-out/thru connections that mirror USB midi are not as simple as they should be.

But if you only want a controller that sends both it should be fairly trival to have separate MIDI send messages if you have include MIDI.h and select MIDI as the USB type.

As I say I don't have hardware set up but I think this modification of Paul's MIDI test code should work.

Code:
#include <MIDI.h>

const int channel = 1;

void setup() {
  MIDI.begin();
}

void loop() {
  int note;
  for (note=10; note <= 127; note++) {
    MIDI.sendNoteOn(note, 100, channel);
    usbMIDI.sendNoteOn(note, 100, channel)
    delay(200);
    MIDI.sendNoteOff(note, 100, channel);
    usbMIDI.sendNoteOff(note, 100, channel)
  }
  delay(2000);
}
 
Thanks for you reply! I'll give your example code a shot and see if that works for me, and I'll keep plugging away at it. I may just end up using 2 teensies (teensys?), one for usb to pc and one from pc to Din.
 
I may just end up using 2 teensies (teensys?), one for usb to pc and one from pc to Din.
You shouldn't need to do this... while I can't test DIN MIDI at the moment I and others have had it working. I don't know if the serial.print() method is compatible with usbMIDI (it should be if you select a USB type with MIDI and Serial) but I'm certain the MIDI library and usbMIDI are compatible.

You just need to include the MIDI.h and double up all your send messages with one of each.

Have you dealt with taming your analog signals and debouncing your buttons?

These issues are much trickier than adding a second send command.

Once you get the test code working you'll know you can add DIN-send later.

Hardware issues are far more complex but it sounds like you have yours sorted in that you were able to send via serial.print()

The complex stuff only comes if you are trying to do an efficient MIDI thru from one type to the other or are dealing with SysEx messaging between types.
 
Last edited:
Frankly usbMIDI() needs some updating and simultaneous usb and DIN MIDI controllers and MIDI-out/thru connections that mirror USB midi are not as simple as they should be.

Let's discuss this on a new thread in the Suggestions & Bug Reports section.

I've been planning to update it for 1.39, at the very least to make the API more similar to the new MIDI lib versions. Please understand I'm not a musician or DJ. I rarely use MIDI myself, so I'm depending on feedback for how to improve MIDI support...
 
Status
Not open for further replies.
Back
Top