Setting custom Baud Rate #261
-
Hi, I'm Luiz Janela. I'm working on a new project aiming to create a basic DAW Controller, so I can manage Start, stop, pause and some other features.
I'm using Hairless Midi and loopMIDI to route everything into the DAW. On Hairless Midi logs i see the message below:
And inside Studio One (my DAW) it comprehends that some not is being sent, but as he doesn't understands, he writes as C-2 (i think that is the lowest note, much like a 0). I tried a different code, without your framework and got everything working just setting Baud Rate on Hairless Midi the same as my code. After this the DAW started playing the note i was sending with its VST. Here's is the code:
On Hairless Midi i can see that the note is being recognized too:
Is there a way to setup a custom Baud Rate in MIDI.h ? Thank you so much for your library, great work! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Hi @luizjanela I believe the MEGA defaults to using When going Hairless, please consider: arduino_midi_library/src/serialMIDI.h Lines 35 to 37 in d501f4b As for the a custom BaudRate, you need to override the arduino_midi_library/src/serialMIDI.h Line 33 in 8f8c7cf Taken from #215 and modified to fit the above #include <MIDI.h>
struct CustomBaudRate : public MIDI_NAMESPACE::DefaultSettings {
static const long BaudRate = 38400;
};
MIDI_CREATE_CUSTOM_INSTANCE(HardwareSerial, Serial, MIDI, CustomBaudRate);
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
} Hope this helps @franky47 : i will add the above to the examples |
Beta Was this translation helpful? Give feedback.
-
I was a bit too trigger happy, the above example was overriding That results in: #include <MIDI.h>
// Override the default MIDI baudrate to
// a decoding program such as Hairless MIDI (set baudrate to 115200)
struct CustomBaudRateSettings : public MIDI_NAMESPACE::DefaultSerialSettings {
static const long BaudRate = 115200;
};
#if defined(ARDUINO_SAM_DUE) || defined(USBCON) || defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MKL26Z64__)
// Leonardo, Due and other USB boards use Serial1 by default.
MIDI_NAMESPACE::SerialMIDI<HardwareSerial, CustomBaudRateSettings> serialMIDI(Serial1);
MIDI_NAMESPACE::MidiInterface<MIDI_NAMESPACE::SerialMIDI<HardwareSerial, CustomBaudRateSettings>> MIDI((MIDI_NAMESPACE::SerialMIDI<HardwareSerial, CustomBaudRateSettings>&)serialMIDI);
#else
MIDI_NAMESPACE::SerialMIDI<HardwareSerial, CustomBaudRateSettings> serialMIDI(Serial);
MIDI_NAMESPACE::MidiInterface<MIDI_NAMESPACE::SerialMIDI<HardwareSerial, CustomBaudRateSettings>> MIDI((MIDI_NAMESPACE::SerialMIDI<HardwareSerial, CustomBaudRateSettings>&)serialMIDI);
#endif
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
MIDI.begin(MIDI_CHANNEL_OMNI);
}
void loop() {
if (MIDI.read()) // If we have received a message
{
digitalWrite(LED_BUILTIN, HIGH);
MIDI.sendNoteOn(42, 127, 1); // Send a Note (pitch 42, velo 127 on channel 1)
delay(1000); // Wait for a second
MIDI.sendNoteOff(42, 0, 1); // Stop the note
digitalWrite(LED_BUILTIN, LOW);
}
}
|
Beta Was this translation helpful? Give feedback.
Hi @luizjanela
I believe the MEGA defaults to using
Serial1
and notserial
as in your 2 example above (see #65).Try replacing
MIDI_CREATE_DEFAULT_INSTANCE();
withMIDI_CREATE_INSTANCE(HardwareSerial, Serial, MIDI);
When going Hairless, please consider:
arduino_midi_library/src/serialMIDI.h
Lines 35 to 37 in d501f4b
As for the a custom BaudRate, you need to override the
DefaultSerialSettings
inSerialMIDI.h
arduino_midi_library/src/serialMIDI.h
Line 33 in 8f8c7cf