MIDI input from sequencer (help) Teensy 4.0

Status
Not open for further replies.

Hayden_

New member
Hi,
I'm attempting to make a FM synth on the teensy 4.0 with the audio board. I want to receive notes from a sequencer so I can start playing around with generating some synth noises.

For now I am just trying to receive MIDI notes from an Arturia Beatstep via the 3.5mm midi out on the device.

I have used the code from the MIDI library section https://www.pjrc.com/teensy/td_libs_MIDI.html and used the circuit from this tutorial with a 3.5mm input to the teensy instead of a 5-DIN cable https://www.notesandvolts.com/2018/11/teensy-synth-part-9-midi-input.html . I have used the code from the MIDI Library section above to monitor the messages received by the teensy.

Code:
#include <MIDI.h>

MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI);

void setup() {
  MIDI.begin(MIDI_CHANNEL_OMNI);
  Serial.begin(57600);
  Serial.println("MIDI Input Test");
}

unsigned long t=0;

void loop() {
  int type, note, velocity, channel, d1, d2;
  if (MIDI.read()) {                    // Is there a MIDI message incoming ?
    byte type = MIDI.getType();
    switch (type) {
      case midi::NoteOn:
        note = MIDI.getData1();
        velocity = MIDI.getData2();
        channel = MIDI.getChannel();
        if (velocity > 0) {
          Serial.println(String("Note On:  ch=") + channel + ", note=" + note + ", velocity=" + velocity);
        } else {
          Serial.println(String("Note Off: ch=") + channel + ", note=" + note);
        }
        break;
      case midi::NoteOff:
        note = MIDI.getData1();
        velocity = MIDI.getData2();
        channel = MIDI.getChannel();
        Serial.println(String("Note Off: ch=") + channel + ", note=" + note + ", velocity=" + velocity);
        break;
      default:
        d1 = MIDI.getData1();
        d2 = MIDI.getData2();
        Serial.println(String("Message, type=") + type + ", data = " + d1 + " " + d2);
    }
    t = millis();
  }
  if (millis() - t > 10000) {
    t += 10000;
    Serial.println("(inactivity)");
  }
}

When I monitor the midi messages coming in to the teensy it is only displaying these two messages on the serial monitor. "Note Off: ch=1, note=0, velocity=128" and
"Note Off: ch=1, note=0, velocity=0". The Beatstep is on sequencer mode and should be playing middle C every 16th note. I have tried different notes and patterns ect. but the serial monitor just alternates between the above two messages.

I am pretty new to this any help would be greatly appreciated.
 
Hi,
For now I am just trying to receive MIDI notes from an Arturia Beatstep via the 3.5mm midi out on the device.

When I monitor the midi messages coming in to the teensy it is only displaying these two messages on the serial monitor. "Note Off: ch=1, note=0, velocity=128" and
"Note Off: ch=1, note=0, velocity=0". The Beatstep is on sequencer mode and should be playing middle C every 16th note. I have tried different notes and patterns ect. but the serial monitor just alternates between the above two messages.

I am pretty new to this any help would be greatly appreciated.

@Hayden_:

I don't have any specific experience with the Arturia Beatstep, but if you have it setup to send a middle C every 16th note, I would expect that you'd get a NoteOn/NoteOff pair at that rate. Looking at what you reported above, is the "Note Off: ch=1, note=0, velocity=128" a typo . . . is that actually a "Note On" message with a note number other than "0" ??

I don't see any obvious errors in the code that you have posted. The examples that I followed in the early startup days of my <TeensyMIDIPolySynth> project all used "MIDI_CREATE_DEFAULT_INSTANCE();" without any parameters, but I don't know that that would make any difference here.

I've not processed MIDI messages using the "MIDI.getXXX" functions, but I do successfully process the full variety of MIDI messages in my <TeensyMIDIPolySynth> project using the method given in the "Examples > MIDI Library > Callbacks" example.

Good luck & have fun !!

Mark J Culross
KD5RXT
 
...The Beatstep is on sequencer mode and should be playing middle C every 16th note. I have tried different notes and patterns ect. but the serial monitor just alternates between the above two messages. ...
Those two messages are only different from what you're expecting by the note values... are you sure it pulses middle-C (note=60)?

edit... I didn't notice they both say 'off'
 
EDIT: Check your wiring, I had some MIDI wired wrong on my first project and was receiving my highs/lows backwards. Which resulting in midi messages, just not the ones I wanted. After typing the stuff below here someone pointed out that an optocoupler shouldn't work if you wire the LED side wrong like I was saying, and thinking about it they're right. But having wiring that would reverse your highs/lows or an inverting opto could cause the same thing, so I would check that.

My original message for posterity, even though it's probably not accurate since TRS A vs TRS B should cause a lack of signals completely:

So, you might already know this, but just in case, I'll lay it all out. There are two different TRS MIDI (3.5mm jack) standards floating around, TRS A and TRS B. The Tip/Sleeve on them are opposite for source and sink if I remember right. TRS A was officially adopted to be the MIDI standard but the two different standards were floating around long enough before that so that lots of companies adopted one or the other. Korg uses TRS A, but some others like Arturia and Novation use TRS B I believe. Here is a website that seems to show a lot of standards by device.

If you have it wired backwards, you may burn out your optocoupler, and you will receive the wrong messages to your device in the meantime. Messages will still get through, but aren't quite right. At least that's the experience I had when my optocoupler was wired backwards. I would make sure your wiring is the correct TRS, because this issue sounds really familiar to me from a similar project lol. Personally, I wire all my gear to be TRS A, and plan for adapters for anything that uses B.
 
Last edited:
...er… how can an optocoupler work if reversed? Is that possible?

Good point! It was my first project so the details are a little fuzzy, but thinking about it I see what you mean. Either I wasn't using an opto and had it directly wired reversed, or the wiring issue was on the photoresistor side of the opto. It was between a Minty Synth and VS1053, and it may have been before I started using optos. I just remember having my high/lows received backwards and I would still get midi messages but it would be the wrong notes/etc, until the wiring was corrected.

EDIT: I just looked at items in question, and I think what I had done was instead of using 5v for source and the midi control pin for sink, I had used the midi control pin for source, and the gnd for sink. That's how my messages ended up inverted. So that's a little more wrong than TRS A vs TRS B, lol.
 
Last edited:
Status
Not open for further replies.
Back
Top