Teensy 3.2: usage of Midi-USB and Midi DIN together

Status
Not open for further replies.

loganjon

Member
Hi, I am new in the world of Teensy.
I would like to give a Piano the Midi ability and use therefore a Teensy.
I have 3 questions.

1: The Piano should have two MIDI-Out jacks: One as a normal Midi-Din jack and one as a USB-Midi jack.
Is it possible to do this, if yes, how do I have to do it?

2: Is it possible to do Midi and audio process with the same Teensy and in the same sketch?
That means, I would like to scan the Piano keys, produce Midi data, send it out and simultaneously I would like to read a wave file (e.g. a drum pattern) from SDD card and send it as an audio data. If that works fine, do I need a seperate thread? I would like to write the source code with arduino studio, not in C or C++.

3: Which power supply do you recommend for Teensy and wich pins do I have to use therefore, if I should use the USB for Midi out and not for power supply.

Thank you.
 
loganjon,

1) don't know, but i guess it is possible (i have never used MIDI)
2) should be possible (currently, there is a bug with USB -Audio, i think Paul Stoffregen will fix it in a few days.) There are other options too, like I2S, or S/PDIF, (or, of course, analog)
3) If you use USB, you don't need a power-supply. If not, you can use GND and VIN. But make sure to open the jumper on the bottom of the board.

I guess, some "MIDI-Experts" read your question , in a few days..
 
Last edited:
1) don't know, but i guess it is possible (i have never used MIDI)
...
I guess, some "MIDI-Experts" read your question , in a few days..
Well I don't qualify as an expert but AFAIK there's no reason you cannot combine a DIN out via Tx/MIDI and usbMIDI messages together.

If you have serial active on Tx pin you should be able to send via Tx with the device configured as usbMIDI if with have two sends; one for each message type.

Code:
if (sendNoteOnBoolean[i]){
     usbMIDI.sendNoteOn(note, velocity, channel);
     MIDI.sendNoteOn(note, velocity, channel);
}
 
Last edited:
Thanks a lot.
Is it possible for you to help me to understand it better ?

1: What do you mean with "If you have serial active on Tx" ? Do I have to do it, or is it by default?

2: Would you explain me this array "sendNoteOnBoolean"
 
Thanks a lot.
Is it possible for you to help me to understand it better ?
Sorry... this isn't supposed to be finished code... it's only to say the two commands need to be sent together one after the other.


1: What do you mean with "If you have serial active on Tx" ? Do I have to do it, or is it by default?
Actually I didn't get that quite right... you have to initialize the MIDI library's use of the UART with this in your setup:


#include <MIDI.h>
...
void setup() {
MIDI.begin();
...​
}


Here is the reference: https://www.pjrc.com/teensy/td_libs_MIDI.html
Paul notes explicitly that usbMIDI and MIDI libraries may be used together!

2: Would you explain me this array "sendNoteOnBoolean"

I don't expect you would necessarily make an array of Booleans; whatever logic you wish to use to decide when to send your message...

If you had it in a for-loop with an 'i' indicator variable then this would be one way to do it; if you were setting a message flag for each button in some other part of the code... but you could just as easily use the bounce result here.

You would likely want an array to target the note or CC you want to send for a given button... so an array for note values might mean your send commands look something like this:

usbMIDI.sendNoteOn(notes(i), 127, MIDI_CHANNEL);
MIDI.sendNoteOn(notes(i), 127, MIDI_CHANNEL);


Assuming you define the midi-channel constant first.

Basically design for usbMIDI first (because it's easier to test usually) and then just add the MIDI calls after you get it working.
 
Last edited:
Status
Not open for further replies.
Back
Top