Forum Rule: Always post complete source code & details to reproduce any issue!
-
Why Setting the Wrong MIDI Baud Rate?
I'm running the following program on a Teensy LC, which based on examples should be sending "hairless midi" at 115200 baud out the default serial port. However my other device which I know can receive midi at 115200 baud fails to receive it. Looking at the the output on my scope and analyzing the timing of the bit transitions, I can see that the baud is almost exactly 31250 baud, so I assume that for some reason "MySettings" is not changing the baud rate from the default. What could the problem be? I'm running a recent version of the MIDI library installed through Visual Micro.
#include <MIDI.h>
#include <midi_Defs.h>
#include <midi_Message.h>
#include <midi_Namespace.h>
#include <midi_Settings.h>
struct MySettings : public midi :: DefaultSettings {
static const long BaudRate = 115200;
static const unsigned SysExMaxSize = 128;
};
MIDI_CREATE_CUSTOM_INSTANCE(HardwareSerial, Serial1, MIDI, MySettings)
void setup()
{
MIDI.begin();
}
void loop()
{
MIDI.sendNoteOn( 42, 85, 1);
delay(2);
MIDI.sendNoteOff(42, 85, 1);
delay(4);
}
-
This problem seems to be related to the Teensy. I tried running it on an Arduino UNO and it gives the correct baud rate of 115200.
-
Senior Member
I have no idea why the MIDI library isn't using the custom baud rate setting.
But I did a quick test here. This seems to make it work:
Code:
void setup()
{
MIDI.begin();
Serial1.begin(115200);
}

My best guess is this is very likely a bug in the MIDI library. Might be worth opening an issue on that library's issue tracker?
Also... you're aware Teensy LC can do real class-compliant USB MIDI, right? No need for hairless & extra hardware.
https://www.pjrc.com/teensy/td_midi.html
-
I have two versions of a MIDI library on my system. The one in the TeensyDuino distribution does not have BaudRate in the DefaultSettings struct (in midi_Settings.h) whereas the one I've installed in my libraries directory does. I don't know if that's significant but it might explain what you are seeing.
Pete
-
[QUOTE=PaulStoffregen;265530]I have no idea why the MIDI library isn't using the custom baud rate setting.
Thanks! Resetting the baud rate does fix the problem.
Code:
void setup()
{
MIDI.begin();
Serial1.begin(115200);
}
The reason for the TTL midi is that Teensy is acting as a peripheral to another custom board I developed, and that board has the USB midi port for the overall device.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules